From 253ff439e7a019dd6add5854bd20dc158fe7c20a Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> Date: Fri, 17 Jan 2025 11:13:51 +0100 Subject: [PATCH] cmake: run examples as tests --- .gitlab-ci.yml | 1 - CMakeLists.txt | 6 +----- examples/CMakeLists.txt | 2 ++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97852f7..36543fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -358,7 +358,6 @@ Generate HTML pages: -DCMAKE_Fortran_COMPILER=gfortran -DBUILD_TESTING:BOOL=OFF -DMTIME_ENABLE_PYTHON:BOOL=OFF - -DMTIME_BUILD_EXAMPLES:BOOL=OFF -DMTIME_BUILD_DOCS:BOOL=ON -DDOXYGEN_GENERATE_LATEX:BOOL=OFF -DDOXYGEN_GENERATE_MAN:BOOL=OFF diff --git a/CMakeLists.txt b/CMakeLists.txt index a84d34a..fff4c0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,6 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(BUILD_TESTING "Build tests" ON) option(MTIME_ENABLE_PYTHON "Enable the Python interface" OFF) -option(MTIME_BUILD_EXAMPLES "Build examples" ON) option(MTIME_BUILD_DOCS "Build documentation" OFF) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) @@ -47,12 +46,9 @@ if(MTIME_BUILD_DOCS) add_subdirectory(doc) endif() -if(MTIME_BUILD_EXAMPLES) - add_subdirectory(examples) -endif() - include(CTest) if(BUILD_TESTING) + add_subdirectory(examples) add_subdirectory(test) else() # Allow for 'make test' even if the tests are disabled: diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a5f64b1..38ed1f4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,6 +23,7 @@ set(examples_Fortran foreach(example IN LISTS examples_Fortran) add_executable(${example} ${example}.f90) + add_test(NAME ${example} COMMAND ${example}) endforeach() set(examples_C @@ -34,6 +35,7 @@ set(examples_C foreach(example IN LISTS examples_C) add_executable(${example} ${example}.c) + add_test(NAME ${example} COMMAND ${example}) endforeach() # Additional sources of the example executables: -- GitLab