diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d82cd880d4adfa44d55a2fbf937cf3c04c215f3..d473fb79a80f45214da6e9c29a91fa69b0057052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ enable_language (Fortran) # ignore many irrelevant Up-to-date messages during install set (CMAKE_INSTALL_MESSAGE LAZY) +# TEMPORARY: this should be removed, the sanitizers should be always enabled +option(CORSIKA_SANITIZERS_ENABLED "temporary way to globally disable sanitizers until the currently failing tests are fixed" OFF) + # directory for local cmake modules set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) include (CorsikaUtilities) # a few cmake function diff --git a/CMakeModules/CorsikaUtilities.cmake b/CMakeModules/CorsikaUtilities.cmake index ece233ed9fa4cb3fd8c6953de4ab94ba19385614..ba083a98c2a87fb2a23745ae0219ad2aff9ede17 100644 --- a/CMakeModules/CorsikaUtilities.cmake +++ b/CMakeModules/CorsikaUtilities.cmake @@ -119,7 +119,10 @@ function (CORSIKA_ADD_TEST) target_compile_options(${name} PRIVATE -g) # do not skip asserts target_include_directories (${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/test_outputs/) - target_compile_options(${name} PRIVATE -fno-omit-frame-pointer -fsanitize=${sanitize} -fno-sanitize-recover=all) - set_target_properties(${name} PROPERTIES LINK_FLAGS "-fsanitize=${sanitize}") + if (CORSIKA_SANITIZERS_ENABLED) + # -O1 is suggested in clang docs to get reasonable performance + target_compile_options(${name} PRIVATE -O1 -fno-omit-frame-pointer -fsanitize=${sanitize} -fno-sanitize-recover=all) + set_target_properties(${name} PROPERTIES LINK_FLAGS "-fsanitize=${sanitize}") + endif() add_test (NAME ${name} COMMAND ${name} -o ${PROJECT_BINARY_DIR}/test_outputs/junit-${name}.xml -r junit) endfunction (CORSIKA_ADD_TEST) diff --git a/Processes/UrQMD/CMakeLists.txt b/Processes/UrQMD/CMakeLists.txt index 897492b2e808cd9c743a33bb8b4f66f5ee9a9d79..ca8cc4e01192afb56bceae368cbedeeb137f9684 100644 --- a/Processes/UrQMD/CMakeLists.txt +++ b/Processes/UrQMD/CMakeLists.txt @@ -83,11 +83,7 @@ install ( # -------------------- # code unit testing -add_executable (testUrQMD - testUrQMD.cc - ${MODEL_HEADERS} - ) - +CORSIKA_ADD_TEST(testUrQMD SOURCES testUrQMD.cc ${MODEL_HEADERS}) target_link_libraries ( testUrQMD ProcessUrQMD @@ -96,5 +92,4 @@ target_link_libraries ( CORSIKAgeometry CORSIKAunits CORSIKAthirdparty # for catch2 - ) -CORSIKA_ADD_TEST(testUrQMD) + ) \ No newline at end of file