Add PROJECT_IS_TOP_LEVEL
variable, to decide whether need to install/package
This commit is contained in:
parent
3d4a95e32e
commit
35a66c88dc
@ -11,6 +11,10 @@ project(googletest-distribution
|
||||
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)
|
||||
endif()
|
||||
@ -22,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)
|
||||
@ -40,7 +44,7 @@ else()
|
||||
add_subdirectory( googletest )
|
||||
endif()
|
||||
|
||||
if(INSTALL_GTEST)
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user