try to work around linker issues with older CMake versions and using coverage or sanitizers
This commit is contained in:
@ -243,10 +243,18 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF)
|
||||
mark_as_advanced(ENABLE_COVERAGE)
|
||||
if(ENABLE_COVERAGE)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.13)
|
||||
if(CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(lammps PUBLIC --coverage)
|
||||
target_link_options(lammps PUBLIC --coverage)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
|
||||
set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)")
|
||||
mark_as_advanced(ENABLE_SANITIZER)
|
||||
@ -255,10 +263,18 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQU
|
||||
validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES)
|
||||
string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER)
|
||||
if (NOT ENABLE_SANITIZER STREQUAL "none")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.13)
|
||||
if(CMAKE_CXX_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
|
||||
enable_language(C)
|
||||
|
||||
@ -17,9 +17,11 @@ else()
|
||||
endif()
|
||||
# propagate sanitizer options to test tools
|
||||
if (NOT ENABLE_SANITIZER STREQUAL "none")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
||||
target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# unit test for error stats class
|
||||
add_executable(test_error_stats test_error_stats.cpp)
|
||||
|
||||
Reference in New Issue
Block a user