From 50055790dd338aabf23cdbbd9cc3c75d296f1411 Mon Sep 17 00:00:00 2001 From: Maksym Kucherov Date: Wed, 16 Aug 2023 17:32:48 +0300 Subject: [PATCH 1/2] Add and respect `BUILD_TESTING` option. --- CMakeLists.txt | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e51aa36b..f3409998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10) set (CMAKE_C_STANDARD 11) set (CMAKE_CXX_STANDARD 17) +option(BUILD_TESTING "Enable testing" ON) + # Minimum required versions for MSVC set (MIN_VS_TOOLSET_VERSION 142) set (MIN_VS_PLATFORM_VERSION 10.0.18362.0) @@ -169,21 +171,23 @@ include(GoogleTest) # Tests -set(COM_TEST ${CMAKE_CURRENT_LIST_DIR}/tests) -FILE(GLOB COM_TEST_SRC ${COM_TEST}/*.cpp) -FILE(GLOB COM_TEST_H ${COM_TEST}/*.hpp) -add_executable(CommonTests ${COM_TEST_SRC} ${COM_TEST_H}) -if (MSVC) - target_compile_options(CommonTests PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") - target_link_options(CommonTests PRIVATE "/WX") -else () - target_compile_options(CommonTests PRIVATE ${COMPILE_OPTION_DEBUG}) -endif() +if(BUILD_TESTING) + set(COM_TEST ${CMAKE_CURRENT_LIST_DIR}/tests) + FILE(GLOB COM_TEST_SRC ${COM_TEST}/*.cpp) + FILE(GLOB COM_TEST_H ${COM_TEST}/*.hpp) + add_executable(CommonTests ${COM_TEST_SRC} ${COM_TEST_H}) + if (MSVC) + target_compile_options(CommonTests PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") + target_link_options(CommonTests PRIVATE "/WX") + else () + target_compile_options(CommonTests PRIVATE ${COMPILE_OPTION_DEBUG}) + endif() -target_link_libraries(CommonTests fiftyone-common-cxx gtest_main) -gtest_discover_tests(CommonTests PROPERTIES TEST_DISCOVERY_TIMEOUT 600) -set_target_properties(CommonTests PROPERTIES FOLDER "Tests") + target_link_libraries(CommonTests fiftyone-common-cxx gtest_main) + gtest_discover_tests(CommonTests PROPERTIES TEST_DISCOVERY_TIMEOUT 600) + set_target_properties(CommonTests PROPERTIES FOLDER "Tests") -if (CMAKE_COMPILER_IS_GNUCC) - target_compile_options(CommonTests PRIVATE "-Wall" "-Werror" "-Wno-unused-variable" "-Wno-unused-result" "-Wno-unused-but-set-variable") + if (CMAKE_COMPILER_IS_GNUCC) + target_compile_options(CommonTests PRIVATE "-Wall" "-Werror" "-Wno-unused-variable" "-Wno-unused-result" "-Wno-unused-but-set-variable") + endif() endif() From 55efb904fe81444bf3249ae03104ab1c5a1f2901 Mon Sep 17 00:00:00 2001 From: Maksym Kucherov Date: Fri, 18 Aug 2023 16:20:00 +0300 Subject: [PATCH 2/2] Remove unnecessary redeclaration of CTest's `BUILD_TESTING` option. --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3409998..1d55bc8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.10) set (CMAKE_C_STANDARD 11) set (CMAKE_CXX_STANDARD 17) -option(BUILD_TESTING "Enable testing" ON) - # Minimum required versions for MSVC set (MIN_VS_TOOLSET_VERSION 142) set (MIN_VS_PLATFORM_VERSION 10.0.18362.0)