mirror of
https://github.com/google/googletest.git
synced 2025-12-07 01:06:50 +08:00
Add CMake interface library GTest::gtest_prod
Production code that contains `#include <gtest/gtest_prod.h>` should link against this interface library: it sets the correct include path for the compiler but does not instruct the linker to pull in any GoogleTest library code.
This commit is contained in:
parent
46b4e2552a
commit
310635492d
@ -116,10 +116,14 @@ include_directories(${gtest_build_include_dirs})
|
|||||||
#
|
#
|
||||||
# Defines the gtest & gtest_main libraries. User tests should link
|
# Defines the gtest & gtest_main libraries. User tests should link
|
||||||
# with one of them.
|
# with one of them.
|
||||||
|
# Production code that includes <gtest/gtest_prod.h> should link with the
|
||||||
|
# interface library gtest_prod.
|
||||||
|
|
||||||
# Google Test libraries. We build them using more strict warnings than what
|
# Google Test libraries. We build them using more strict warnings than what
|
||||||
# are used for other targets, to ensure that gtest can be compiled by a user
|
# are used for other targets, to ensure that gtest can be compiled by a user
|
||||||
# aggressive about warnings.
|
# aggressive about warnings.
|
||||||
|
add_library_and_alias(gtest_prod INTERFACE)
|
||||||
|
set_target_properties(gtest_prod PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
||||||
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
|
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
|
||||||
set_target_properties(gtest PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
set_target_properties(gtest PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
||||||
if(GTEST_HAS_ABSL)
|
if(GTEST_HAS_ABSL)
|
||||||
@ -138,6 +142,9 @@ endif()
|
|||||||
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
|
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
|
||||||
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
||||||
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
|
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
|
||||||
|
target_include_directories(gtest_prod SYSTEM INTERFACE
|
||||||
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(gtest SYSTEM INTERFACE
|
target_include_directories(gtest SYSTEM INTERFACE
|
||||||
"$<BUILD_INTERFACE:${dirs}>"
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
@ -152,7 +159,7 @@ target_link_libraries(gtest_main PUBLIC gtest)
|
|||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
# Install rules.
|
# Install rules.
|
||||||
install_project(gtest gtest_main)
|
install_project(gtest_prod gtest gtest_main)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
|
|||||||
7
googletest/cmake/gtest_prod.pc.in
Normal file
7
googletest/cmake/gtest_prod.pc.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||||
|
|
||||||
|
Name: gtest_prod
|
||||||
|
Description: GoogleTest (header for production code)
|
||||||
|
Version: @PROJECT_VERSION@
|
||||||
|
URL: https://github.com/google/googletest
|
||||||
|
Cflags: -I${includedir}
|
||||||
Loading…
x
Reference in New Issue
Block a user