xref: /freebsd/contrib/googletest/CMakeLists.txt (revision 3a56015a2f5d630910177fa79a522bb95511ccf7)
1# Note: CMake support is community-based. The maintainers do not use CMake
2# internally.
3
4cmake_minimum_required(VERSION 3.13)
5
6project(googletest-distribution)
7set(GOOGLETEST_VERSION 1.15.2)
8
9if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
10  set(CMAKE_CXX_EXTENSIONS OFF)
11endif()
12
13enable_testing()
14
15include(CMakeDependentOption)
16include(GNUInstallDirs)
17
18# Note that googlemock target already builds googletest.
19option(BUILD_GMOCK "Builds the googlemock subproject" ON)
20option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
21option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF)
22
23if(GTEST_HAS_ABSL)
24  if(NOT TARGET absl::base)
25    find_package(absl REQUIRED)
26  endif()
27  if(NOT TARGET re2::re2)
28    find_package(re2 REQUIRED)
29  endif()
30endif()
31
32if(BUILD_GMOCK)
33  add_subdirectory( googlemock )
34else()
35  add_subdirectory( googletest )
36endif()
37