2015-02-13 19:00:14 +01:00
|
|
|
file(GLOB_RECURSE hdrs "*.h")
|
|
|
|
file(GLOB_RECURSE srcs "*.cpp")
|
|
|
|
|
2015-07-23 10:49:53 +02:00
|
|
|
function(build_src output filename)
|
|
|
|
get_filename_component(file ${filename} NAME)
|
|
|
|
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file})
|
|
|
|
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
2022-07-11 10:46:18 +02:00
|
|
|
if (USE_MATCHCOMPILER STREQUAL "Verify")
|
2015-07-23 10:49:53 +02:00
|
|
|
set(verify_option "--verify")
|
|
|
|
endif()
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${outfile}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
|
|
|
|
--read-dir="${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
--prefix="mc_"
|
|
|
|
--line
|
|
|
|
${verify_option}
|
|
|
|
${file}
|
|
|
|
DEPENDS ${file}
|
|
|
|
DEPENDS ${PROJECT_SOURCE_DIR}/tools/matchcompiler.py
|
|
|
|
)
|
|
|
|
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
|
|
|
endfunction()
|
|
|
|
|
2022-07-11 10:46:18 +02:00
|
|
|
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
|
2022-09-24 11:59:13 +02:00
|
|
|
foreach(file ${srcs})
|
|
|
|
build_src(srcs_build ${file})
|
|
|
|
endforeach()
|
|
|
|
|
2015-07-23 10:49:53 +02:00
|
|
|
set(srcs_lib ${srcs_build})
|
|
|
|
else()
|
|
|
|
set(srcs_lib ${srcs})
|
|
|
|
endif()
|
|
|
|
|
2023-01-26 22:13:07 +01:00
|
|
|
if (BUILD_CORE_DLL)
|
|
|
|
add_library(cppcheck-core SHARED ${srcs_lib} ${hdrs} $<TARGET_OBJECTS:tinyxml2_objs> $<TARGET_OBJECTS:simplecpp_objs> version.rc)
|
|
|
|
target_compile_definitions(cppcheck-core PRIVATE CPPCHECKLIB_EXPORT TINYXML2_EXPORT SIMPLECPP_EXPORT)
|
|
|
|
else()
|
|
|
|
add_library(cppcheck-core OBJECT ${srcs_lib} ${hdrs})
|
|
|
|
endif()
|
|
|
|
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/)
|
2021-10-30 09:08:07 +02:00
|
|
|
if(USE_BUNDLED_TINYXML2)
|
2023-01-26 22:13:07 +01:00
|
|
|
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
|
2022-09-06 18:30:59 +02:00
|
|
|
else()
|
2023-01-26 22:13:07 +01:00
|
|
|
target_include_directories(cppcheck-core SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
|
2021-10-30 09:08:07 +02:00
|
|
|
endif()
|
2023-01-26 22:13:07 +01:00
|
|
|
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
|
|
|
|
target_include_directories(cppcheck-core PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
|
2021-10-30 09:08:07 +02:00
|
|
|
if (HAVE_RULES)
|
2023-01-26 22:13:07 +01:00
|
|
|
target_include_directories(cppcheck-core SYSTEM PRIVATE ${PCRE_INCLUDE})
|
2021-10-30 09:08:07 +02:00
|
|
|
endif()
|
2022-03-20 10:13:32 +01:00
|
|
|
if (Boost_FOUND)
|
2023-01-26 22:13:07 +01:00
|
|
|
target_include_directories(cppcheck-core SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
2022-03-20 10:13:32 +01:00
|
|
|
endif()
|
2021-10-30 09:08:07 +02:00
|
|
|
|
2020-06-25 01:41:16 +02:00
|
|
|
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
2023-01-26 22:13:07 +01:00
|
|
|
target_precompile_headers(cppcheck-core PRIVATE precompiled.h)
|
2020-06-16 19:55:15 +02:00
|
|
|
endif()
|
2022-09-06 18:30:59 +02:00
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
# -Wfloat-equal is generated by picojson.h
|
2022-09-24 11:59:13 +02:00
|
|
|
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
|
|
|
|
set_source_files_properties(mc_cppcheck.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
set_source_files_properties(mc_importproject.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
set_source_files_properties(mc_settings.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
else()
|
|
|
|
set_source_files_properties(cppcheck.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
set_source_files_properties(importproject.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
set_source_files_properties(settings.cpp PROPERTIES COMPILE_FLAGS -Wno-float-equal)
|
|
|
|
endif()
|
2022-09-06 18:30:59 +02:00
|
|
|
endif()
|