aboutsummaryrefslogtreecommitdiffstats
path: root/googletest/cmake
diff options
context:
space:
mode:
authorJacob Schloss <jschloss@swiftengineering.com>2018-08-22 12:55:43 -0700
committerGitHub <noreply@github.com>2018-08-22 12:55:43 -0700
commit6de39826aa190a07179a8104c00ad11ea20d8679 (patch)
tree3413eb72b75b6aad6392407713f5596c0f477fd6 /googletest/cmake
parent6e7980164593bfe888d6e94ee52d4d08bdddb412 (diff)
parent1d9a1912e7f42e8ae66ea365b5b8508fecb31509 (diff)
downloadgoogletest-6de39826aa190a07179a8104c00ad11ea20d8679.tar.gz
googletest-6de39826aa190a07179a8104c00ad11ea20d8679.tar.bz2
googletest-6de39826aa190a07179a8104c00ad11ea20d8679.zip
Merge branch 'master' into issue_1735
Diffstat (limited to 'googletest/cmake')
-rw-r--r--googletest/cmake/Config.cmake.in9
-rw-r--r--googletest/cmake/internal_utils.cmake40
2 files changed, 48 insertions, 1 deletions
diff --git a/googletest/cmake/Config.cmake.in b/googletest/cmake/Config.cmake.in
new file mode 100644
index 00000000..12be4498
--- /dev/null
+++ b/googletest/cmake/Config.cmake.in
@@ -0,0 +1,9 @@
+@PACKAGE_INIT@
+include(CMakeFindDependencyMacro)
+if (@GTEST_HAS_PTHREAD@)
+ set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@)
+ find_dependency(Threads)
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
+check_required_components("@project_name@")
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index dc9186e9..8c1f9ba9 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -38,6 +38,11 @@ macro(fix_default_compiler_settings_)
# We prefer more strict warning checking for building Google Test.
# Replaces /W3 with /W4 in defaults.
string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
+
+ # Prevent D9025 warning for targets that have exception handling
+ # turned off (/EHs-c- flag). Where required, exceptions are explicitly
+ # re-enabled using the cxx_exception_flags variable.
+ string(REPLACE "/EHsc" "" ${flag_var} "${${flag_var}}")
endforeach()
endif()
endmacro()
@@ -166,9 +171,18 @@ function(cxx_library_with_type name type cxx_flags)
set_target_properties(${name}
PROPERTIES
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
+ if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
+ target_compile_definitions(${name} INTERFACE
+ $<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
+ endif()
endif()
if (DEFINED GTEST_HAS_PTHREAD)
- target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
+ if ("${CMAKE_VERSION}" VERSION_LESS "3.1.0")
+ set(threads_spec ${CMAKE_THREAD_LIBS_INIT})
+ else()
+ set(threads_spec Threads::Threads)
+ endif()
+ target_link_libraries(${name} PUBLIC ${threads_spec})
endif()
endfunction()
@@ -278,3 +292,27 @@ function(py_test name)
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
endif(PYTHONINTERP_FOUND)
endfunction()
+
+# install_project(targets...)
+#
+# Installs the specified targets and configures the associated pkgconfig files.
+function(install_project)
+ if(INSTALL_GTEST)
+ install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+ # Install the project targets.
+ install(TARGETS ${ARGN}
+ EXPORT ${targets_export_name}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+ # Configure and install pkgconfig files.
+ foreach(t ${ARGN})
+ set(configured_pc "${generated_dir}/${t}.pc")
+ configure_file("${PROJECT_SOURCE_DIR}/cmake/${t}.pc.in"
+ "${configured_pc}" @ONLY)
+ install(FILES "${configured_pc}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ endforeach()
+ endif()
+endfunction()