summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorPaweł Bylica <chfast@gmail.com>2020-01-23 20:29:56 (GMT)
committerBrad King <brad.king@kitware.com>2020-01-24 15:18:36 (GMT)
commitfbd3ea2047bf1a09ff24d9a04078b75438ebd46b (patch)
tree7f71b1308d06085023f2e47798a51f8683c6656c /Modules
parentab2fc918216011a03f0fe7696e7bba67fc2627b3 (diff)
downloadCMake-fbd3ea2047bf1a09ff24d9a04078b75438ebd46b.zip
CMake-fbd3ea2047bf1a09ff24d9a04078b75438ebd46b.tar.gz
CMake-fbd3ea2047bf1a09ff24d9a04078b75438ebd46b.tar.bz2
FindGTest: Add GTest::{gtest,gtest_main} library names
This introduces 2 new INTERFACE IMPORTED libraries: GTest::gtest and GTest::gtest_main. They link to GTest::GTest and GTest::Main targets respectively, therefore working as aliases. These new names map the names of the targets from upstream GTest's CMake package config. Fixes: #20255
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindGTest.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index e015a98..53cab1a 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -240,4 +240,15 @@ if(GTEST_FOUND)
__gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "RELEASE")
__gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "DEBUG")
endif()
+
+ # Add targets mapping the same library names as defined in
+ # GTest's CMake package config.
+ if(NOT TARGET GTest::gtest)
+ add_library(GTest::gtest INTERFACE IMPORTED)
+ target_link_libraries(GTest::gtest INTERFACE GTest::GTest)
+ endif()
+ if(NOT TARGET GTest::gtest_main)
+ add_library(GTest::gtest_main INTERFACE IMPORTED)
+ target_link_libraries(GTest::gtest_main INTERFACE GTest::Main)
+ endif()
endif()