128f6c2f2SEnji Cooper# Note: CMake support is community-based. The maintainers do not use CMake 228f6c2f2SEnji Cooper# internally. 3b89a7cc2SEnji Cooper 428f6c2f2SEnji Coopercmake_minimum_required(VERSION 3.13) 5b89a7cc2SEnji Cooper 6b89a7cc2SEnji Cooperproject(googletest-distribution) 7*5ca8c28cSEnji Cooperset(GOOGLETEST_VERSION 1.15.2) 828f6c2f2SEnji Cooper 928f6c2f2SEnji Cooperif(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) 1028f6c2f2SEnji Cooper set(CMAKE_CXX_EXTENSIONS OFF) 1128f6c2f2SEnji Cooperendif() 12b89a7cc2SEnji Cooper 13b89a7cc2SEnji Cooperenable_testing() 14b89a7cc2SEnji Cooper 15b89a7cc2SEnji Cooperinclude(CMakeDependentOption) 16b89a7cc2SEnji Cooperinclude(GNUInstallDirs) 17b89a7cc2SEnji Cooper 18*5ca8c28cSEnji Cooper# Note that googlemock target already builds googletest. 19b89a7cc2SEnji Cooperoption(BUILD_GMOCK "Builds the googlemock subproject" ON) 20b89a7cc2SEnji Cooperoption(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) 2128f6c2f2SEnji Cooperoption(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) 22b89a7cc2SEnji Cooper 23*5ca8c28cSEnji Cooperif(GTEST_HAS_ABSL) 24*5ca8c28cSEnji Cooper if(NOT TARGET absl::base) 25*5ca8c28cSEnji Cooper find_package(absl REQUIRED) 26*5ca8c28cSEnji Cooper endif() 27*5ca8c28cSEnji Cooper if(NOT TARGET re2::re2) 28*5ca8c28cSEnji Cooper find_package(re2 REQUIRED) 29*5ca8c28cSEnji Cooper endif() 30*5ca8c28cSEnji Cooperendif() 31*5ca8c28cSEnji Cooper 32b89a7cc2SEnji Cooperif(BUILD_GMOCK) 33b89a7cc2SEnji Cooper add_subdirectory( googlemock ) 34b89a7cc2SEnji Cooperelse() 35b89a7cc2SEnji Cooper add_subdirectory( googletest ) 36b89a7cc2SEnji Cooperendif() 37