Warning, /JETSCAPE/external_packages/trento/test/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # Create a meta-target which will depend on all the actual testing targets.
0002 # Target 'test' is reserved by CMake.
0003 add_custom_target(tests)
0004
0005 # Run the compiled executable normally and let the sanitizers do their thing.
0006 # Even if compiled without sanitizers, this won't hurt.
0007 add_custom_target(sanitizer COMMAND ${PROJECT_NAME} p Pb 10 > /dev/null VERBATIM)
0008 add_dependencies(tests sanitizer)
0009
0010 # Download the Catch test header automatically.
0011 set(CATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/catch.hpp")
0012 set(SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/download_catch.cmake")
0013 file(WRITE ${SCRIPT_FILE}
0014 "message(STATUS \"Downloading Catch test header\")
0015
0016 file(DOWNLOAD
0017 \"https://raw.github.com/catchorg/Catch2/master/single_include/catch.hpp\"
0018 \"${CATCH_FILE}\"
0019 TIMEOUT 20
0020 STATUS status
0021 TLS_VERIFY ON)
0022
0023 list(GET status 0 status_code)
0024 list(GET status 1 status_string)
0025
0026 if(NOT status_code EQUAL 0)
0027 message(FATAL_ERROR
0028 \"download failed: code \${status_code} \${status_string}\")
0029 endif()
0030 ")
0031 add_custom_command(OUTPUT ${CATCH_FILE} COMMAND ${CMAKE_COMMAND} -P ${SCRIPT_FILE})
0032
0033 # Compile the Catch test executable.
0034 set(TEST_EXE "test-${PROJECT_NAME}")
0035 add_executable(${TEST_EXE} EXCLUDE_FROM_ALL
0036 catch.hpp
0037 catch.cxx
0038 util.cxx
0039 test_collider.cxx
0040 test_event.cxx
0041 test_fast_exp.cxx
0042 test_nucleon.cxx
0043 test_nucleus.cxx
0044 test_output.cxx
0045 )
0046 target_link_libraries(${TEST_EXE} ${LIBRARY_NAME} ${Boost_LIBRARIES} ${HDF5_LIBRARIES})
0047
0048 # Add a target to actually run the tests.
0049 add_custom_target(catch COMMAND ${TEST_EXE})
0050 add_dependencies(tests catch)
0051
0052 # Coverage.
0053 find_program(GCOVR gcovr)
0054 if(GCOVR)
0055 add_custom_target(cov
0056 COMMAND ${GCOVR}
0057 --root=${CMAKE_SOURCE_DIR}
0058 --exclude=${CMAKE_CURRENT_SOURCE_DIR}
0059 --exclude=${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}.cxx
0060 VERBATIM
0061 DEPENDS catch)
0062 add_dependencies(tests cov)
0063 endif()