cppcheck/lib/CMakeLists.txt
Oliver Stöneberg 1388e9385b
cleaned up setting of compiler options and a few more things in CMake (#2599)
* cleaned up compiler options related code in CMake

* moved cmake_minimum_required() and raised to latest 2.8.x version

* use proper compiler version check / print compiler version

* fixed linking of sanitized builds

* added proper version checks to newer Clang warnings and enabled them / moved tinyxml_objs flags to proper compiler

* disabled -Wdeprecated-declarations for Clang

* compileroptions.cmake: removed unnecessary check for clang++ existence - CMAKE_CXX_COMPILER_ID is determined by CMake

* printInfo.cmake: removed unnecessary message for ANALYZE_ADDRESS - LSAN is part of ASAN and enabled by default

* cleaned up if() comparisons in CMake

* added/adjusted TODOs
2020-04-22 11:04:19 +02:00

44 lines
1.4 KiB
CMake

include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
include_directories(${PROJECT_SOURCE_DIR}/externals/simplecpp/)
file(GLOB_RECURSE hdrs "*.h")
file(GLOB_RECURSE srcs "*.cpp")
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 MATCHES "Verify")
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()
foreach(file ${srcs})
build_src(srcs_build ${file})
endforeach()
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
set(srcs_lib ${srcs_build})
else()
set(srcs_lib ${srcs})
endif()
add_library(lib_objs OBJECT ${srcs_lib} ${hdrs})
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(lib_objs_sanitized OBJECT EXCLUDE_FROM_ALL ${srcs_lib} ${hdrs})
target_compile_options(lib_objs_sanitized PRIVATE -fsanitize=address)
endif()