mirror of https://github.com/lammps/lammps.git
try to work around linker issues with older CMake versions and using coverage or sanitizers
This commit is contained in:
parent
f78671c1a4
commit
e934f7bac3
|
@ -243,8 +243,16 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
|||
option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF)
|
||||
mark_as_advanced(ENABLE_COVERAGE)
|
||||
if(ENABLE_COVERAGE)
|
||||
target_compile_options(lammps PUBLIC --coverage)
|
||||
target_link_options(lammps PUBLIC --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"))
|
||||
|
@ -255,8 +263,16 @@ 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")
|
||||
target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
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()
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@ else()
|
|||
endif()
|
||||
# propagate sanitizer options to test tools
|
||||
if (NOT ENABLE_SANITIZER STREQUAL "none")
|
||||
target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER})
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue