diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aec5d2e..3d25a6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,6 +66,22 @@ build-dependencies: # # Stage: build +build-mcg-no-tests: + <<: *job-setup + stage: build + script: + - module load clang/$LLVM + - cmake -S . -B $MCG_BUILD-no-tests -G Ninja -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_INSTALL_PREFIX=/tmp/metacg/$MCG_BUILD-no-tests + -DCUBE_LIB=$(dirname $(which cube_info))/../lib + -DCUBE_INCLUDE=$(dirname $(which cube_info))/../include/cubelib + -DEXTRAP_INCLUDE=./extern/install/extrap/include + -DEXTRAP_LIB=./extern/install/extrap/lib + -DSPDLOG_BUILD_SHARED=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON + -DMETACG_BUILD_UNIT_TESTS=OFF + - cmake --build $MCG_BUILD-no-tests --parallel + - module purge + build-mcg-stripped-all: <<: *job-setup stage: build diff --git a/CMakeLists.txt b/CMakeLists.txt index 77c50ac..a2845fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,14 @@ list( set(METACG_Directory ${CMAKE_CURRENT_SOURCE_DIR}) +# Whether the GoogleTest-based unit tests should be built and GoogleTest is downloaded as dependency This needs to be +# here, so ToolchainOptions already "sees" the option's value +option( + METACG_BUILD_UNIT_TESTS + "On or Off" + ON +) + # This also downloads and builds googletest include(ToolchainOptions) # Making packaging easier diff --git a/cmake/ToolchainOptions.cmake b/cmake/ToolchainOptions.cmake index 6561af7..c72d159 100644 --- a/cmake/ToolchainOptions.cmake +++ b/cmake/ToolchainOptions.cmake @@ -88,45 +88,47 @@ function(target_project_compile_definitions target) endif() endfunction() -# Download and unpack googletest at configure time -configure_file(cmake/GoogleTest.cmake.in googletest-download/CMakeLists.txt) -execute_process( - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download -) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() -execute_process( - COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download -) -if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") -endif() +if(METACG_BUILD_UNIT_TESTS) + # Download and unpack googletest at configure time + configure_file(cmake/GoogleTest.cmake.in googletest-download/CMakeLists.txt) + execute_process( + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") + endif() -# Prevent overriding the parent project's compiler/linker settings on Windows -set(gtest_force_shared_crt - ON - CACHE BOOL - "" - FORCE -) - -# Add googletest directly to our build. This defines the gtest and gtest_main targets. -add_subdirectory( - ${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL -) - -# The gtest/gtest_main targets carry header search path dependencies automatically when using CMake 2.8.11 or later. -# Otherwise we have to add them here ourselves. -if(CMAKE_VERSION - VERSION_LESS - 2.8.11 -) - include_directories("${gtest_SOURCE_DIR}/include") + # Prevent overriding the parent project's compiler/linker settings on Windows + set(gtest_force_shared_crt + ON + CACHE BOOL + "" + FORCE + ) + + # Add googletest directly to our build. This defines the gtest and gtest_main targets. + add_subdirectory( + ${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL + ) + + # The gtest/gtest_main targets carry header search path dependencies automatically when using CMake 2.8.11 or later. + # Otherwise we have to add them here ourselves. + if(CMAKE_VERSION + VERSION_LESS + 2.8.11 + ) + include_directories("${gtest_SOURCE_DIR}/include") + endif() endif() diff --git a/graph/CMakeLists.txt b/graph/CMakeLists.txt index b4e84b0..f95891d 100644 --- a/graph/CMakeLists.txt +++ b/graph/CMakeLists.txt @@ -63,4 +63,6 @@ add_config_include(metacg) add_json(metacg) add_spdlog_libraries(metacg) -add_subdirectory(test/unit) +if(METACG_BUILD_UNIT_TESTS) + add_subdirectory(test/unit) +endif() diff --git a/pgis/CMakeLists.txt b/pgis/CMakeLists.txt index 85ebd75..0c0e247 100644 --- a/pgis/CMakeLists.txt +++ b/pgis/CMakeLists.txt @@ -7,4 +7,6 @@ enable_testing() add_subdirectory(lib) add_subdirectory(tool) -add_subdirectory(test/unit) +if(METACG_BUILD_UNIT_TESTS) + add_subdirectory(test/unit) +endif()