summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorAlex Birch <51103-Birchlabs@users.noreply.gitlab.kitware.com>2021-12-31 16:48:56 (GMT)
committerBrad King <brad.king@kitware.com>2022-05-20 13:25:07 (GMT)
commit3c5cc79adbbe8524eb712b8c36d5d29a1d968d75 (patch)
tree6a8df089f6909395359a75a749d8087707db013e /Tests
parent5cfbc763716c1e15ee20a24c503b9b7371a2da28 (diff)
downloadCMake-3c5cc79adbbe8524eb712b8c36d5d29a1d968d75.zip
CMake-3c5cc79adbbe8524eb712b8c36d5d29a1d968d75.tar.gz
CMake-3c5cc79adbbe8524eb712b8c36d5d29a1d968d75.tar.bz2
Tests: De-duplicate some code in RunCMake.FindPkgConfig
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake22
1 files changed, 14 insertions, 8 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
index d697fc6..f149d99 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -49,12 +49,15 @@ set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig)
# find targets in subdir and check their visibility
add_subdirectory(target_subdir)
-if (TARGET PkgConfig::FakePackage1_dir)
- message(FATAL_ERROR "imported target PkgConfig::FakePackage1_dir is visible outside it's directory")
+
+set(tgt PkgConfig::FakePackage1_dir)
+if (TARGET ${tgt})
+ message(FATAL_ERROR "imported target \"${tgt}\" is visible outside its directory")
endif()
-if (NOT TARGET PkgConfig::FakePackage1_global)
- message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory")
+set(tgt PkgConfig::FakePackage1_global)
+if (NOT TARGET ${tgt})
+ message(FATAL_ERROR "imported target \"${tgt}\" is not visible outside its directory")
endif()
# And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH}
@@ -104,10 +107,13 @@ Cflags: -I/special -isystem /other -isystem/more -DA-isystem/foo
set(expected_link_options -e dummy_main)
pkg_check_modules(FakeLinkOptionsPackage REQUIRED QUIET IMPORTED_TARGET fakelinkoptionspackage)
-if (NOT TARGET PkgConfig::FakeLinkOptionsPackage)
+
+set(tgt PkgConfig::FakeLinkOptionsPackage)
+message(STATUS "Verifying target \"${tgt}\"")
+if (NOT TARGET ${tgt})
message(FATAL_ERROR "No import target for fake link options package")
endif()
-get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS)
+get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS)
if (NOT link_options STREQUAL expected_link_options)
message(FATAL_ERROR
"Additional link options not present in INTERFACE_LINK_OPTIONS property\n"
@@ -115,7 +121,7 @@ if (NOT link_options STREQUAL expected_link_options)
)
endif()
-get_target_property(inc_dirs PkgConfig::FakeLinkOptionsPackage INTERFACE_INCLUDE_DIRECTORIES)
+get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES)
set(expected_inc_dirs "/special" "/other" "/more")
if (NOT inc_dirs STREQUAL expected_inc_dirs)
@@ -125,7 +131,7 @@ if (NOT inc_dirs STREQUAL expected_inc_dirs)
)
endif ()
-get_target_property(c_opts PkgConfig::FakeLinkOptionsPackage INTERFACE_COMPILE_OPTIONS)
+get_target_property(c_opts ${tgt} INTERFACE_COMPILE_OPTIONS)
set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase
if (NOT c_opts STREQUAL expected_c_opts)
message(FATAL_ERROR