Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…faq.html#testing

Signed-off-by: Andreas Heinrich <[email protected]>
  • Loading branch information
andistorm committed Feb 5, 2024
1 parent b31d5f9 commit 79b7a11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ find_package(everest-cmake 0.1 REQUIRED
#
option(BUILD_EXAMPLES "enable building of examples" OFF)
option(FSM_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT})

option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" ON)
option(BUILD_TESTING "Build unit tests, used if standalone project" ON)

#
# library declaration
Expand All @@ -39,7 +40,7 @@ endif()
#
# tests
#
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
Expand Down
11 changes: 6 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ if (CODE_COVERAGE)
evc_include(CodeCoverage)
endif()

add_executable(test_state_allocator state_allocator.cpp)
target_link_libraries(test_state_allocator
set(TEST_TARGET_NAME ${PROJECT_NAME}_tests)
add_executable(${TEST_TARGET_NAME} state_allocator.cpp)
target_link_libraries(${TEST_TARGET_NAME}
PRIVATE
fsm::fsm
Catch2::Catch2WithMain
)

if (CODE_COVERAGE)
append_coverage_compiler_flags_to_target(test_state_allocator)
append_coverage_compiler_flags_to_target(${TEST_TARGET_NAME})
setup_target_for_coverage_gcovr_html(
NAME coverage
EXECUTABLE test_state_allocator
EXECUTABLE ${TEST_TARGET_NAME}
BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/include"
)
endif()

catch_discover_tests(test_state_allocator)
catch_discover_tests(${TEST_TARGET_NAME})

0 comments on commit 79b7a11

Please sign in to comment.