diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index daccd0e3bc..1a0bb0d47e 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -302,3 +302,18 @@ ${include_compiled_header_dir}/${pch_file_name}.${PCH_EXTENSION}" endif() endforeach() endfunction() + + +# Macro for finding a system provided library +# that fulfills the required minimum version +# or else including the vendored library +# from a local git subdirectory +macro(find_package_or_fallback_to_3party PACKAGE_NAME MIN_REQUIRED_VERSION SUBDIRECTORY) + find_package(${PACKAGE_NAME} ${MIN_REQUIRED_VERSION} QUIET) + if (NOT ${${PACKAGE_NAME}_FOUND} OR ("${${PACKAGE_NAME}_VERSION}" VERSION_LESS "${MIN_REQUIRED_VERSION}")) + message(STATUS "Using ${PACKAGE_NAME} from submodule: ${SUBDIRECTORY}") + add_subdirectory(${SUBDIRECTORY} ${ARGN}) + else() + message(STATUS "Found ${PACKAGE_NAME} ${${PACKAGE_NAME}_VERSION} (minimum required version ${MIN_REQUIRED_VERSION})") + endif() +endmacro() diff --git a/drape/drape_tests/CMakeLists.txt b/drape/drape_tests/CMakeLists.txt index 2744456496..5a6473af74 100644 --- a/drape/drape_tests/CMakeLists.txt +++ b/drape/drape_tests/CMakeLists.txt @@ -31,7 +31,12 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE GTEST_DONT_DEFINE_TEST WITH_GL_MOCK ) -add_subdirectory(../../3party/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest) +find_package_or_fallback_to_3party( + "GTest" + "1.12.0" + "${CMAKE_CURRENT_LIST_DIR}/../../3party/googletest" + "${CMAKE_CURRENT_BINARY_DIR}/googletest" +) target_link_libraries(${PROJECT_NAME} qt_tstfrm