cppcheck/lib/CMakeLists.txt

66 lines
2.5 KiB
CMake
Raw Normal View History

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)
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()
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
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()
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
if(USE_BUNDLED_TINYXML2)
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
else()
target_include_directories(lib_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
endif()
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
target_include_directories(lib_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
if (HAVE_RULES)
target_include_directories(lib_objs SYSTEM PRIVATE ${PCRE_INCLUDE})
endif()
if (Boost_FOUND)
target_include_directories(lib_objs SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
endif()
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
target_precompile_headers(lib_objs PRIVATE precompiled.h)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# -Wfloat-equal is generated by picojson.h
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()
endif()