Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/cmake/ActsForceAssertions.cmake is written in an unsupported language. File is not indexed.

0001 # Force assertions regardless of build type when ACTS_FORCE_ASSERTIONS is set.
0002 #
0003 # This is shared by ACTS and the in-tree Detray and Traccc projects, so that
0004 # their standalone builds honour the same option. It only affects targets
0005 # created in the including directory and below, so it has to be included
0006 # before any targets are set up. The include guard makes nested inclusions a
0007 # no-op: a project added via add_subdirectory() inherits the settings from the
0008 # directory that included this first.
0009 include_guard(GLOBAL)
0010 
0011 if(ACTS_FORCE_ASSERTIONS)
0012     message(
0013         STATUS
0014         "Injecting headers to force assertions. This can have side-effects, USE WITH CAUTION!"
0015     )
0016     include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/assert_include)
0017 
0018     # Add assertions to standard libraries. These go into the flags rather than
0019     # the directory compile definitions, which ROOT_GENERATE_DICTIONARY copies
0020     # into a custom command where a $<COMPILE_LANGUAGE> restriction is invalid.
0021     string(APPEND CMAKE_CXX_FLAGS " -D_GLIBCXX_ASSERTIONS -D_LIBCPP_DEBUG")
0022 endif()
0023 
0024 # Register death tests that check the forced assertions actually fire. Each
0025 # probe is built with NDEBUG defined and must fail with an assertion message.
0026 #
0027 #   acts_add_assertion_tests([CUDA])
0028 #
0029 # CUDA adds a probe for device-side assert(). Every probe is added only once per
0030 # build, so ACTS, Detray and Traccc can all call this when built together.
0031 function(acts_add_assertion_tests)
0032     if(NOT ACTS_FORCE_ASSERTIONS)
0033         return()
0034     endif()
0035 
0036     cmake_parse_arguments(PARSE_ARGV 0 _args "CUDA" "" "")
0037 
0038     set(_probes AssertProbe.cpp StdlibAssertProbe.cpp)
0039     if(_args_CUDA)
0040         list(APPEND _probes CudaAssertProbe.cu)
0041     endif()
0042 
0043     foreach(_source IN LISTS _probes)
0044         get_filename_component(_name ${_source} NAME_WE)
0045         get_property(_added GLOBAL PROPERTY _ACTS_ASSERTION_TEST_${_name})
0046         if(_added)
0047             continue()
0048         endif()
0049         set_property(GLOBAL PROPERTY _ACTS_ASSERTION_TEST_${_name} TRUE)
0050 
0051         set(_target ActsForceAssertions${_name})
0052         add_executable(
0053             ${_target}
0054             ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/assert_check/${_source}
0055         )
0056         target_compile_definitions(${_target} PRIVATE NDEBUG)
0057         add_test(
0058             NAME ForceAssertions.${_name}
0059             COMMAND
0060                 ${CMAKE_COMMAND} -DPROBE=$<TARGET_FILE:${_target}> -P
0061                 ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/assert_check/RunAssertProbe.cmake
0062         )
0063         set_tests_properties(
0064             ForceAssertions.${_name}
0065             PROPERTIES SKIP_REGULAR_EXPRESSION "ACTS_ASSERTION_PROBE_SKIPPED"
0066         )
0067     endforeach()
0068 endfunction()