From fadf458b68fa65ebf933c1e0bea40cde2db893f1 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Wed, 22 Nov 2023 19:45:36 +0800 Subject: [PATCH] Add CMake option BUILD_TESTS (#333) Add an option BUILD_TESTS to decide whether to build S2 unit tests. Default is with tests. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac68f6a..7610f9c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ add_feature_info(SHARED_LIBS BUILD_SHARED_LIBS "builds shared libraries instead of static.") option(BUILD_EXAMPLES "Build s2 documentation examples." ON) +option(BUILD_TESTS "Build s2 unittests." ON) option(WITH_PYTHON "Add python interface" OFF) add_feature_info(PYTHON WITH_PYTHON "provides python interface to S2") @@ -431,8 +432,12 @@ install(TARGETS ${S2_TARGETS} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") -message("GOOGLETEST_ROOT: ${GOOGLETEST_ROOT}") -if (GOOGLETEST_ROOT) +if (BUILD_TESTS) + if (NOT GOOGLETEST_ROOT) + message(FATAL_ERROR "BUILD_TESTS requires GOOGLETEST_ROOT") + endif() + message("GOOGLETEST_ROOT: ${GOOGLETEST_ROOT}") + add_subdirectory(${GOOGLETEST_ROOT}/googlemock build_gmock) include_directories(${GOOGLETEST_ROOT}/googlemock/include) include_directories(${GOOGLETEST_ROOT}/googletest/include)