diff --git a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake index c99b6cdea5..9165be9771 100644 --- a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake +++ b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake @@ -11,6 +11,7 @@ macro(InitializeFreeCADBuildOptions) option(FREECAD_USE_EXTERNAL_FMT "Use system installed fmt library if available instead of fetching the source." ON) option(FREECAD_USE_EXTERNAL_ONDSELSOLVER "Use system installed OndselSolver instead of git submodule." OFF) option(FREECAD_USE_EXTERNAL_E57FORMAT "Use system installed libE57Format instead of the bundled." OFF) + option(FREECAD_USE_EXTERNAL_GTEST "Use system installed Google Test and Google Mock" OFF) option(FREECAD_USE_FREETYPE "Builds the features using FreeType libs" ON) option(FREECAD_BUILD_DEBIAN "Prepare for a build of a Debian package" OFF) option(FREECAD_CHECK_PIVY "Check for pivy version using Python at build time" ON) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6feae931e7..069498dfa8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,10 +1,10 @@ -if ( EXISTS "${CMAKE_SOURCE_DIR}/tests/lib/googletest" ) - include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googletest/include/ ) - include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googlemock/include/ ) +if(FREECAD_USE_EXTERNAL_GTEST) + find_package(GTest REQUIRED) + set(Google_Tests_LIBS ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES}) else() - find_package(GTest) - if( GTest_FOUND ) - message( STATUS "Found Google Test: version ${GTest_VERSION}" ) + if ( EXISTS "${CMAKE_SOURCE_DIR}/tests/lib/googletest" ) + include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googletest/include/ ) + include_directories( ${CMAKE_SOURCE_DIR}/tests/lib/googlemock/include/ ) else() message( SEND_ERROR "The Google Test submodule is not available. Please run git submodule update --init" ) endif() @@ -124,7 +124,7 @@ foreach (exe ${TestExecutables}) add_executable(${exe}) endforeach() -if ( EXISTS "${CMAKE_SOURCE_DIR}/tests/lib/googletest" ) +if ( NOT FREECAD_USE_EXTERNAL_GTEST ) add_subdirectory(lib) endif() add_subdirectory(src)