diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 97852f7c12460b3db8b8e0551556d61ce585547f..36543fd770d0e0a5bfd74550411e7105ef16d3c0 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 a84d34abaf751528310a12d252accdb4613cf5f4..fff4c0c70c990b1c90e1374d896473a44e8b34d5 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 a5f64b15d2505027748e4772f448cc230ede136c..38ed1f491f6e3bb6a70ad536ffc47182cf19b716 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: