From 28a486f0ffcff681480df66a9bb5626907a87246 Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Mon, 26 Aug 2024 11:28:23 +0200 Subject: [PATCH] cmake: add option BUILD_TESTS (by default ON) --- CMakeLists.txt | 19 ++++++++++++++----- libticables/trunk/CMakeLists.txt | 4 +++- libticalcs/trunk/CMakeLists.txt | 4 +++- libticonv/trunk/CMakeLists.txt | 4 +++- libtifiles/trunk/CMakeLists.txt | 4 +++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10571ae4..88868921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ endif() project(tilibs C CXX) +option(BUILD_TESTS "Whether to build tests" ON) option(BUILD_SHARED_LIBS "Whether to build shared libs instead of static ones" ON) # Our modules @@ -183,8 +184,16 @@ add_subdirectory(libticables/trunk) add_subdirectory(libticalcs/trunk) add_subdirectory(tifileutil) -add_custom_target(check - DEPENDS ticonv_check tifiles2_check ticables2_check ticalcs2_check - COMMENT "Run all torture tests" - EXCLUDE_FROM_ALL -) +if (BUILD_TESTS) + add_custom_target(check + DEPENDS ticonv_check tifiles2_check ticables2_check ticalcs2_check + COMMENT "Run all torture tests" + EXCLUDE_FROM_ALL + ) +else() + add_custom_target(check + COMMAND ${CMAKE_COMMAND} -E echo "BUILD_TESTS was OFF, so no tests to run" + COMMENT "Run all torture tests" + EXCLUDE_FROM_ALL + ) +endif() diff --git a/libticables/trunk/CMakeLists.txt b/libticables/trunk/CMakeLists.txt index 472fd5b3..a9577452 100644 --- a/libticables/trunk/CMakeLists.txt +++ b/libticables/trunk/CMakeLists.txt @@ -108,4 +108,6 @@ else() endif() # tests -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif() diff --git a/libticalcs/trunk/CMakeLists.txt b/libticalcs/trunk/CMakeLists.txt index 8ec5c45a..8be65c26 100644 --- a/libticalcs/trunk/CMakeLists.txt +++ b/libticalcs/trunk/CMakeLists.txt @@ -96,4 +96,6 @@ endif() target_compile_definitions(ticalcs2 PUBLIC TICALCS_EXPORTS) # tests -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif() diff --git a/libticonv/trunk/CMakeLists.txt b/libticonv/trunk/CMakeLists.txt index 487396a9..e11fa382 100644 --- a/libticonv/trunk/CMakeLists.txt +++ b/libticonv/trunk/CMakeLists.txt @@ -52,4 +52,6 @@ endif() target_compile_definitions(ticonv PUBLIC TICONV_EXPORTS) # tests -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif() diff --git a/libtifiles/trunk/CMakeLists.txt b/libtifiles/trunk/CMakeLists.txt index 60b0718a..0717afce 100644 --- a/libtifiles/trunk/CMakeLists.txt +++ b/libtifiles/trunk/CMakeLists.txt @@ -74,4 +74,6 @@ endif() target_compile_definitions(tifiles2 PUBLIC TIFILES_EXPORTS) # tests -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif()