diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2018-07-05 16:20:26 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2018-07-22 11:33:04 (GMT) |
commit | 7aa26cf0e9319be3f7785763eb3699823453eb60 (patch) | |
tree | 6a83e198c9c7768fbb837b21769ab7f02182c549 /Tests | |
parent | c2d22dc4b44c8a5115fbe6797bb44ae478971601 (diff) | |
download | CMake-7aa26cf0e9319be3f7785763eb3699823453eb60.zip CMake-7aa26cf0e9319be3f7785763eb3699823453eb60.tar.gz CMake-7aa26cf0e9319be3f7785763eb3699823453eb60.tar.bz2 |
FindPkgConfig: allow to create global imported targets
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 1150568..24e7202 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(FindPkgConfig_IMPORTED_TARGET C) find_package(PkgConfig REQUIRED) pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses) +message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}") + if (NCURSES_FOUND) set(tgt PkgConfig::NCURSES) if (NOT TARGET ${tgt}) @@ -66,6 +68,16 @@ if (NOT TARGET PkgConfig::FakePackage1) message(FATAL_ERROR "No import target for fake package 1 with prefix path") endif() +# 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") +endif() + +if (NOT TARGET PkgConfig::FakePackage1_global) + message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory") +endif() + # And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH} # combination unset(CMAKE_PREFIX_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt new file mode 100644 index 0000000..2171ef6 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt @@ -0,0 +1,5 @@ +# a target with visibility only in this directory +pkg_check_modules(FakePackage1_dir REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1) + +# the same with global visibility +pkg_check_modules(FakePackage1_global REQUIRED QUIET IMPORTED_TARGET GLOBAL cmakeinternalfakepackage1) |