summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-11 13:54:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-11 13:54:36 (GMT)
commit96b7ca357602f8ba8d8a621075a0eb5c70c3d472 (patch)
tree30f505203e1cd7bb83b7a6633dfe00d30ed12012 /Tests
parentedee7c18e8881557366b34ee7d4edecef0181478 (diff)
parent2f1ffa003c07d5fe7ca10c4ee06e81dd55f5e415 (diff)
downloadCMake-96b7ca357602f8ba8d8a621075a0eb5c70c3d472.zip
CMake-96b7ca357602f8ba8d8a621075a0eb5c70c3d472.tar.gz
CMake-96b7ca357602f8ba8d8a621075a0eb5c70c3d472.tar.bz2
Merge topic 'find_package-global-imported'
2f1ffa003c find_package: Add support for default GLOBAL imported targets Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6862
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt31
-rw-r--r--Tests/RunCMake/find_package/GlobalImportTarget.cmake57
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake3
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake3
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake7
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake7
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake5
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake5
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake2
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake5
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake5
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake5
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake3
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake1
14 files changed, 139 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt
new file mode 100644
index 0000000..bd06873
--- /dev/null
+++ b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt
@@ -0,0 +1,31 @@
+-- IMPORTED TARGET imported_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET Foo1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET Foo2 has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_lib has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_explicit_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_local_lib has GLOBAL scope: FALSE
+-- IMPORTED TARGET imported_implied_local_ex has GLOBAL scope: FALSE
+-- IMPORTED TARGET imported_no_var_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET not_imported_not_global has GLOBAL scope: FALSE
+-- IMPORTED TARGET PackName has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackNameExe has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackName1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackNameExe1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_lib_glob has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_exe_glob has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_lib has GLOBAL scope: FALSE
+-- IMPORTED TARGET local_exe has GLOBAL scope: FALSE
+-- IMPORTED TARGET LT1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT2 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT3 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT4 has GLOBAL scope: TRUE
diff --git a/Tests/RunCMake/find_package/GlobalImportTarget.cmake b/Tests/RunCMake/find_package/GlobalImportTarget.cmake
new file mode 100644
index 0000000..7e6d2b8
--- /dev/null
+++ b/Tests/RunCMake/find_package/GlobalImportTarget.cmake
@@ -0,0 +1,57 @@
+function (assess_target_property target)
+ get_target_property(target_val "${target}" IMPORTED_GLOBAL)
+ message(STATUS "IMPORTED TARGET ${target} has GLOBAL scope: ${target_val}")
+endfunction ()
+
+list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
+
+find_package(GlobalTarget GLOBAL REQUIRED)
+assess_target_property(imported_local_target)
+assess_target_property(imported_global_target)
+assess_target_property(imported_local_ex)
+assess_target_property(imported_global_ex)
+assess_target_property(Foo1)
+assess_target_property(Foo2)
+
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
+find_package(GlobalVarTarget)
+assess_target_property(imported_var_local_target)
+assess_target_property(imported_var_global_target)
+assess_target_property(imported_var_local_ex)
+assess_target_property(imported_var_global_ex)
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL OFF)
+
+find_package(LocalTarget)
+assess_target_property(imported_global_lib)
+assess_target_property(imported_explicit_global_ex)
+assess_target_property(imported_local_lib)
+assess_target_property(imported_implied_local_ex)
+
+find_package(GlobalTargetNoVar GLOBAL)
+assess_target_property(imported_no_var_local_target)
+assess_target_property(imported_no_var_global_target)
+assess_target_property(imported_no_var_local_ex)
+assess_target_property(imported_no_var_global_ex)
+assess_target_property(not_imported_not_global)
+
+set(Baz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Baz GLOBAL REQUIRED)
+assess_target_property(PackName)
+assess_target_property(PackNameExe)
+assess_target_property(PackName1)
+assess_target_property(PackNameExe1)
+
+set(Biz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Biz REQUIRED)
+assess_target_property(local_lib_glob)
+assess_target_property(local_exe_glob)
+assess_target_property(local_lib)
+assess_target_property(local_exe)
+
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
+set(Simple_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Simple REQUIRED)
+assess_target_property(LT1)
+assess_target_property(LT2)
+assess_target_property(LT3)
+assess_target_property(LT4)
diff --git a/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake
new file mode 100644
index 0000000..cca95a2
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(PackName PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake
new file mode 100644
index 0000000..5b0e398
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(LocalPack PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake
new file mode 100644
index 0000000..9e34613
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake
@@ -0,0 +1,7 @@
+add_library(imported_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_global_ex IMPORTED GLOBAL)
+
+add_library(imported_local_target SHARED IMPORTED)
+add_executable(imported_local_ex IMPORTED)
+
+find_package(SimpleTarget)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake
new file mode 100644
index 0000000..a156f90
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake
@@ -0,0 +1,7 @@
+add_library(imported_no_var_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_no_var_global_ex IMPORTED GLOBAL)
+
+add_library(imported_no_var_local_target SHARED IMPORTED)
+add_executable(imported_no_var_local_ex IMPORTED)
+
+add_library(not_imported_not_global INTERFACE)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake
new file mode 100644
index 0000000..2e96a6c
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake
@@ -0,0 +1,5 @@
+add_library(imported_var_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_var_global_ex IMPORTED GLOBAL)
+
+add_library(imported_var_local_target SHARED IMPORTED)
+add_executable(imported_var_local_ex IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake
new file mode 100644
index 0000000..d533405
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake
@@ -0,0 +1,5 @@
+add_library(imported_global_lib SHARED IMPORTED GLOBAL)
+add_executable(imported_explicit_global_ex IMPORTED GLOBAL)
+
+add_library(imported_local_lib SHARED IMPORTED)
+add_executable(imported_implied_local_ex IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake
new file mode 100644
index 0000000..cd58004
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake
@@ -0,0 +1,2 @@
+add_library(Foo1 SHARED IMPORTED)
+add_executable(Foo2 IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake
new file mode 100644
index 0000000..f451eb6
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake
@@ -0,0 +1,5 @@
+add_library(LT1 INTERFACE IMPORTED)
+add_executable(LT2 IMPORTED)
+
+add_library(LT3 INTERFACE IMPORTED GLOBAL)
+add_executable(LT4 IMPORTED GLOBAL)
diff --git a/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake
new file mode 100644
index 0000000..a962849
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake
@@ -0,0 +1,5 @@
+add_library(local_lib_glob SHARED IMPORTED GLOBAL)
+add_executable(local_exe_glob IMPORTED GLOBAL)
+
+add_library(local_lib SHARED IMPORTED)
+add_executable(local_exe IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake
new file mode 100644
index 0000000..38dd2f8
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake
@@ -0,0 +1,5 @@
+add_library(PackName INTERFACE IMPORTED GLOBAL)
+add_executable(PackNameExe IMPORTED GLOBAL)
+
+add_library(PackName1 INTERFACE IMPORTED)
+add_executable(PackNameExe1 IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake
new file mode 100644
index 0000000..44059c6
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(LT PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index 5f4c6cb..2b5fb1f 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -6,6 +6,7 @@ run_cmake(ComponentRequiredAndOptional)
run_cmake(FromPATHEnv)
run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved)
run_cmake(FromPrefixPath)
+run_cmake(GlobalImportTarget)
run_cmake(MissingNormal)
run_cmake(MissingNormalForceRequired)
run_cmake(MissingNormalRequired)