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)