Tests: Add FREECAD_USE_EXTERNAL_GTEST cmake option (#21190)

Add FREECAD_USE_EXTERNAL_GTEST cmake option and fix build with external libraries
This commit is contained in:
FilippoR
2025-05-08 22:41:48 +02:00
committed by GitHub
parent 3d18203403
commit ff4740d082
2 changed files with 8 additions and 7 deletions

View File

@@ -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)

View File

@@ -1,10 +1,10 @@
if(FREECAD_USE_EXTERNAL_GTEST)
find_package(GTest REQUIRED)
set(Google_Tests_LIBS ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
else()
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()
find_package(GTest)
if( GTest_FOUND )
message( STATUS "Found Google Test: version ${GTest_VERSION}" )
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)