diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8796669..a85bcf930 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,10 +38,10 @@ endif() option(CREATE_SYMLINKS "Create symlinks to javascript modules and auxillary files - for development purposes" OFF) option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) -option(BUILD_TESTING "Run unit tests" OFF) option(ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES "Automatically generate and install certificates for development purposes" ON) option(EVEREST_ENABLE_RUN_SCRIPT_GENERATION "Enables the generation of run scripts (convenience scripts for starting available configurations)" ON) - +option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" OFF) +option(BUILD_TESTING "Build unit tests, used if standalone project" OFF) # This is a flag for building development tests, but not necessarily to run them, for expample in case # tests requires hardware. option(BUILD_DEV_TESTS "Build dev tests" OFF) @@ -121,8 +121,9 @@ if(DOXYGEN_FOUND) endif() # testing -if(BUILD_TESTING) +if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING) include(CTest) + enable_testing() set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) evc_include(CodeCoverage) @@ -132,13 +133,13 @@ if(BUILD_TESTING) add_subdirectory(tests) setup_target_for_coverage_gcovr_html( - NAME gcovr_coverage + NAME ${PROJECT_NAME}_gcovr_coverage EXECUTABLE test_config DEPENDENCIES test_config everest ) setup_target_for_coverage_lcov( - NAME lcov_coverage + NAME ${PROJECT_NAME}_lcov_coverage EXECUTABLE test_config DEPENDENCIES test_config everest )