summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-05-16 10:11:38 -0400
committerCMake Topic Stage <kwrobot@kitware.com>2016-05-16 10:11:38 -0400
commit856804f9a9d32339578ff7760f5e9bd89df8e1bb (patch)
treef5abeaeac43461c45fbbaa6b9fd0ce35720c74be /Tests
parentd3db070e9eb7890958ae2b9d91085f5c7c6770f8 (diff)
parentdf97b9793fac50a3ec533f26b05dea7d745b080c (diff)
downloadcmake-856804f9a9d32339578ff7760f5e9bd89df8e1bb.tar.gz
Merge topic 'findpkgconfig-target'
df97b979 FindPkgConfig: optionally create imported target for the found libraries
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake26
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake1
2 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
new file mode 100644
index 0000000000..00cbb7b38a
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(FindPkgConfig_IMPORTED_TARGET C)
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses)
+
+if (NCURSES_FOUND)
+ set(tgt PkgConfig::NCURSES)
+ if (NOT TARGET ${tgt})
+ message(FATAL_ERROR "FindPkgConfig found ncurses, but did not create an imported target for it")
+ endif ()
+ set(prop_found FALSE)
+ foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_COMPILE_OPTIONS)
+ get_target_property(value ${tgt} ${prop})
+ if (value)
+ message(STATUS "Found property ${prop} on target: ${value}")
+ set(prop_found TRUE)
+ endif ()
+ endforeach ()
+ if (NOT prop_found)
+ message(FATAL_ERROR "target ${tgt} found, but it has no properties")
+ endif ()
+else ()
+ message(STATUS "skipping test; ncurses not found")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 24089e0a56..e12b52fe48 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -15,4 +15,5 @@ find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_GET_VARIABLE)
run_cmake(FindPkgConfig_cache_variables)
+ run_cmake(FindPkgConfig_IMPORTED_TARGET)
endif ()