This commit is contained in:
zjyhjqs 2025-03-27 23:37:51 +08:00 committed by GitHub
commit 0c8557cb5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,8 +3,17 @@
cmake_minimum_required(VERSION 3.16)
project(googletest-distribution)
set(GOOGLETEST_VERSION 1.16.0)
project(googletest-distribution
VERSION ${GOOGLETEST_VERSION}
DESCRIPTION "Google's C++ test framework"
HOMEPAGE_URL "https://google.github.io/googletest"
LANGUAGES CXX
)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
set(PROJECT_IS_TOP_LEVEL TRUE)
endif()
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
set(CMAKE_CXX_EXTENSIONS OFF)
@ -17,7 +26,7 @@ include(GNUInstallDirs)
# Note that googlemock target already builds googletest.
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ${PROJECT_IS_TOP_LEVEL})
option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF)
if(GTEST_HAS_ABSL)
@ -34,3 +43,12 @@ if(BUILD_GMOCK)
else()
add_subdirectory( googletest )
endif()
if(PROJECT_IS_TOP_LEVEL)
set(CPACK_PACKAGE_NAME "GTest") # same as the name in `find_package`
set(CPACK_PACKAGE_VENDOR "Google")
set(CPACK_GENERATOR "TGZ")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
include(CPack)
endif()