From b6664fd698697942a0986f9b428fe1d5f972d254 Mon Sep 17 00:00:00 2001 From: Stig Helgeland Date: Wed, 2 Mar 2022 15:41:49 +0100 Subject: [PATCH 1/3] build: option to disable testing by setting BUILD_TESTING to OFF Removed enable_testing(), since is called if the tests subdirectory is added --- CMakeLists.txt | 2 +- README.md | 1 + src/CMakeLists.txt | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f257972df..6a478420f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ list(GET VERSION_LIST 1 PROJECT_VERSION_MINOR) list(GET VERSION_LIST 2 PROJECT_VERSION_PATCH) unset(VERSION_LIST) -enable_testing() +option(BUILD_TESTING "Define if tests should be enabled" ON) # Follow GNU conventions for installation directories include(GNUInstallDirs) diff --git a/README.md b/README.md index 733a23a27..3ab9276e8 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ Important options are The minimum required rank to compile this project is 4. Compiling with maximum rank 15 can be resource intensive and requires at least 16 GB of memory to allow parallel compilation or 4 GB memory for sequential compilation. - `-DBUILD_SHARED_LIBS` set to `on` in case you want link your application dynamically against the standard library (default: `off`). +- `-DBUILD_TESTING` set to `off` in case you want to disable the stdlib tests (default: `on`). For example, to configure a build using the Ninja backend while specifying compiler flags `FFLAGS`, generating procedures up to rank 7, and installing to your home directory, use diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7ebd48f0..8da7b5018 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,7 +114,9 @@ else() target_sources(${PROJECT_NAME} PRIVATE f08estop.f90) endif() -add_subdirectory(tests) +if(BUILD_TESTING) + add_subdirectory(tests) +endif() install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets From 16d4ae8510e7fa8514add4808cbd7a963ea25c66 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Wed, 2 Mar 2022 19:34:08 +0100 Subject: [PATCH 2/3] Enable testing when tests are built --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8da7b5018..d48975a4e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,6 +115,7 @@ else() endif() if(BUILD_TESTING) + enable_testing() add_subdirectory(tests) endif() From 61e76070d1c5cbd8cd01472e177a4b7bd03917a9 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Wed, 2 Mar 2022 19:39:40 +0100 Subject: [PATCH 3/3] Use CTest module to define BUILD_TESTING option --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a478420f..17efb8e27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ list(GET VERSION_LIST 1 PROJECT_VERSION_MINOR) list(GET VERSION_LIST 2 PROJECT_VERSION_PATCH) unset(VERSION_LIST) -option(BUILD_TESTING "Define if tests should be enabled" ON) +include(CTest) # Follow GNU conventions for installation directories include(GNUInstallDirs)