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

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