Skip to content

Commit

Permalink
#350: Guard tests and examples with corresponding option checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jul 3, 2024
1 parent 7f6e570 commit a3e095c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()

include (CTest)
enable_testing()

function(deprecated_option old_option new_option description default_value)
option(${new_option} "${description}" ${default_value})
if(DEFINED ${old_option})
Expand Down Expand Up @@ -162,16 +159,23 @@ set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(PROJECT_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples)
set(PROJECT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)

include (CTest)
enable_testing()

add_subdirectory(src)

add_custom_target(magistrate_examples)
add_subdirectory(examples)
if (magistrate_tests_enabled
AND "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
# CTest implies enable_testing() and defines the BUILD_TESTING option.
# The default of BUILD_TESTING is ON.
# Testing is only enabled if the actual project being built is VT.
include(CTest)

add_custom_target(magistrate_tests)
add_subdirectory(tests)
add_custom_target(magistrate_tests)
add_subdirectory(tests)
endif()

if(magistrate_examples_enabled)
add_custom_target(magistrate_examples)
add_subdirectory(examples)
endif()

configure_file(
cmake/checkpointConfig.cmake.in
Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if (magistrate_examples_enabled)
${EXAMPLE}
${PROJECT_EXAMPLE_DIR}/${EXAMPLE}.cc
)
add_dependencies(magistrate_examples ${EXAMPLE})
target_include_directories(${EXAMPLE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../src)

add_test_for_example_magistrate(
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ if (magistrate_tests_enabled)
${PROJECT_TEST_UNIT_DIR}/${TEST}.cc
)

add_dependencies(magistrate_tests ${TEST})
magistrate_link_target(${TEST} 0)

add_test(
Expand Down

0 comments on commit a3e095c

Please sign in to comment.