diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 17c638062707f4eff24f78216e03e5d4b6a38634..39215e37afc26c2212293c896536e17b4faa5831 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -14,14 +14,22 @@ set(EP_ARGS # Use Google Test for a unit testing framework cmake_dependent_option(ADIOS_USE_SYSTEM_GOOGLETEST - "Use a system-supplied Google Test framework" OFF + "Use a system-supplied Google Test framework" ON "BUILD_TESTING" OFF) if(BUILD_TESTING) - if(NOT ADIOS_USE_SYSTEM_GOOGLETEST) - add_subdirectory(googletest) + if(ADIOS_USE_SYSTEM_GOOGLETEST) + find_package(GTest REQUIRED) + if(NOT GTEST_FOUND) + message(WARNING + "Unable to find Google Test framework. " + "Using an internal version") + set(ADIOS_USE_SYSTEM_GOOGLETEST OFF + CACHE BOOL "Use a system-supplied Google Test framework" FORCE) + endif() endif() - find_package(GTest REQUIRED) if(NOT ADIOS_USE_SYSTEM_GOOGLETEST) + add_subdirectory(googletest) + find_package(GTest REQUIRED) add_dependencies(GTest::GTest googletest) add_dependencies(GTest::Main googletest) endif()