diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index b98ef919f3a8dd28560fe3c9d9c339915ae6c2e5..d274189cf781c723f34ef8f3ef0914b8a47877ed 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -14,7 +14,7 @@ build:ubuntu_cpp: - export CMAKE_PREFIX_PATH=../install_cpp - mkdir -p build_cpp - cd build_cpp - - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON .. + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. - make -j4 all install artifacts: diff --git a/CMakeLists.txt b/CMakeLists.txt index d973a04ec5136347c3ddc7fc92989e65b0f34a42..2ee0634ff6de0d227dc69faac963d6b897e5a1e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,17 @@ include(PybindModuleCreation) # Define options option(PYBIND "python binding" ON) option(WERROR "Warning as error" OFF) +option(TEST "Enable tests" ON) +option(COVERAGE "Enable coverage" OFF) + +############################################## +# Import utils CMakeLists +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") +include(PybindModuleCreation) + +if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) + Include(CodeCoverage) +endif() ############################################## # Find system dependencies @@ -79,6 +90,10 @@ else() /W4>) endif() +if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) + append_coverage_compiler_flags() +endif() + ############################################## # Installation instructions @@ -129,6 +144,7 @@ export(EXPORT ${project}-targets ############################################## ## Add test -enable_testing() -add_subdirectory(unit_tests) - +if(TEST) + enable_testing() + add_subdirectory(unit_tests) +endif()