summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2016-05-11 21:45:26 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2016-05-14 07:31:41 (GMT)
commitdf97b9793fac50a3ec533f26b05dea7d745b080c (patch)
treeffb333ec100fa42ab718736fdc9173cf3d400f10 /Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
parentb952336902e9206ba51e1d77b8e489bdd759f73f (diff)
downloadCMake-df97b9793fac50a3ec533f26b05dea7d745b080c.zip
CMake-df97b9793fac50a3ec533f26b05dea7d745b080c.tar.gz
CMake-df97b9793fac50a3ec533f26b05dea7d745b080c.tar.bz2
FindPkgConfig: optionally create imported target for the found libraries
Diffstat (limited to 'Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake26
1 files changed, 26 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 0000000..00cbb7b
--- /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 ()