summaryrefslogtreecommitdiffstats
path: root/googletest/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/CMakeLists.txt')
-rw-r--r--googletest/CMakeLists.txt77
1 files changed, 29 insertions, 48 deletions
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index 3ab964f..2ac9aa0 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -85,10 +85,30 @@ include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.
+# Create the CMake package file descriptors.
+if (INSTALL_GTEST)
+ include(CMakePackageConfigHelpers)
+ set(cmake_package_name GTest)
+ set(targets_export_name ${cmake_package_name}Targets CACHE INTERNAL "")
+ set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated" CACHE INTERNAL "")
+ set(cmake_files_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${cmake_package_name}")
+ set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake")
+ write_basic_package_version_file(${version_file} COMPATIBILITY AnyNewerVersion)
+ install(EXPORT ${targets_export_name}
+ NAMESPACE ${cmake_package_name}::
+ DESTINATION ${cmake_files_install_dir})
+ set(config_file "${generated_dir}/${cmake_package_name}Config.cmake")
+ configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in"
+ "${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir})
+ install(FILES ${version_file} ${config_file}
+ DESTINATION ${cmake_files_install_dir})
+endif()
+
# Where Google Test's .h files can be found.
-include_directories(
+set(gtest_build_include_dirs
"${gtest_SOURCE_DIR}/include"
"${gtest_SOURCE_DIR}")
+include_directories(${gtest_build_include_dirs})
# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
@@ -112,62 +132,23 @@ endif()
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
-target_link_libraries(gtest_main gtest)
-
# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
- target_include_directories(gtest SYSTEM
- INTERFACE
- $<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>
- $<BUILD_INTERFACE:${gtest_SOURCE_DIR}>
- $<INSTALL_INTERFACE:include>)
- target_include_directories(gtest_main SYSTEM
- INTERFACE
- $<BUILD_INTERFACE:${gtest_SOURCE_DIR}/include>
- $<BUILD_INTERFACE:${gtest_SOURCE_DIR}>
- $<INSTALL_INTERFACE:include>)
+ target_include_directories(gtest SYSTEM INTERFACE
+ "$<BUILD_INTERFACE:${gtest_build_include_dirs}>"
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+ target_include_directories(gtest_main SYSTEM INTERFACE
+ "$<BUILD_INTERFACE:${gtest_build_include_dirs}>"
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()
+target_link_libraries(gtest_main PUBLIC gtest)
########################################################################
#
# Install rules
-if(INSTALL_GTEST)
- install(TARGETS gtest
- EXPORT gtestConfigInternal
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
- install(EXPORT gtestConfigInternal
- DESTINATION "${INSTALL_CMAKE_DIR}"
- NAMESPACE googletest_)
- install(TARGETS gtest_main
- EXPORT gtest_mainConfigInternal
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
- install(EXPORT gtest_mainConfigInternal
- DESTINATION "${INSTALL_CMAKE_DIR}"
- NAMESPACE googletest_)
- set(googletest_install_targets
- ${googletest_install_targets} gtest gtest_main PARENT_SCOPE)
-
- install(DIRECTORY "${gtest_SOURCE_DIR}/include/gtest"
- DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
-
- # configure and install pkgconfig files
- configure_file(
- cmake/gtest.pc.in
- "${gtest_BINARY_DIR}/gtest.pc"
- @ONLY)
- configure_file(
- cmake/gtest_main.pc.in
- "${gtest_BINARY_DIR}/gtest_main.pc"
- @ONLY)
- install(FILES "${gtest_BINARY_DIR}/gtest.pc" "${gtest_BINARY_DIR}/gtest_main.pc"
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif()
+install_project(gtest gtest_main)
########################################################################
#