summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ExportImport
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-11-15 20:24:13 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-11-17 14:31:27 (GMT)
commit38cbf5e15ba4720f873d49f60898535e95123a7e (patch)
tree9453bb03ee4c82e5c73987ace9c353d8f71f4dd6 /Tests/RunCMake/ExportImport
parent37b5c78688aabbe179c7bf33409309d5b465a452 (diff)
downloadCMake-38cbf5e15ba4720f873d49f60898535e95123a7e.zip
CMake-38cbf5e15ba4720f873d49f60898535e95123a7e.tar.gz
CMake-38cbf5e15ba4720f873d49f60898535e95123a7e.tar.bz2
Genex: Add $<BUILD_LOCAL_INTERFACE:...> genex
Fixes: #23209
Diffstat (limited to 'Tests/RunCMake/ExportImport')
-rw-r--r--Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-export.cmake14
-rw-r--r--Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-import.cmake9
-rw-r--r--Tests/RunCMake/ExportImport/RunCMakeTest.cmake25
-rw-r--r--Tests/RunCMake/ExportImport/buildlib.c8
-rw-r--r--Tests/RunCMake/ExportImport/installlib.c8
-rw-r--r--Tests/RunCMake/ExportImport/locallib.c8
6 files changed, 72 insertions, 0 deletions
diff --git a/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-export.cmake b/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-export.cmake
new file mode 100644
index 0000000..94076bb
--- /dev/null
+++ b/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-export.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+
+add_library(mainlib STATIC foo.c)
+target_compile_definitions(mainlib INTERFACE
+ $<BUILD_LOCAL_INTERFACE:BUILD_LOCAL_INTERFACE>
+ $<BUILD_INTERFACE:BUILD_INTERFACE>
+ $<INSTALL_INTERFACE:INSTALL_INTERFACE>
+ )
+add_library(locallib STATIC locallib.c)
+target_link_libraries(locallib PRIVATE mainlib)
+
+install(TARGETS mainlib EXPORT export)
+install(EXPORT export DESTINATION lib/cmake/install FILE install-config.cmake NAMESPACE install::)
+export(EXPORT export FILE build-config.cmake NAMESPACE build::)
diff --git a/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-import.cmake b/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-import.cmake
new file mode 100644
index 0000000..3fe5fae
--- /dev/null
+++ b/Tests/RunCMake/ExportImport/BuildInstallInterfaceGenex-import.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+find_package(build REQUIRED)
+find_package(install REQUIRED)
+
+add_library(buildlib STATIC buildlib.c)
+target_link_libraries(buildlib PRIVATE build::mainlib)
+add_library(installlib STATIC installlib.c)
+target_link_libraries(installlib PRIVATE install::mainlib)
diff --git a/Tests/RunCMake/ExportImport/RunCMakeTest.cmake b/Tests/RunCMake/ExportImport/RunCMakeTest.cmake
index d07fca2..b730047 100644
--- a/Tests/RunCMake/ExportImport/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExportImport/RunCMakeTest.cmake
@@ -22,3 +22,28 @@ function(run_ExportImport_test case)
endfunction()
run_ExportImport_test(SharedDep)
+
+function(run_ExportImportBuildInstall_test case)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-export-build)
+ set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ run_cmake(${case}-export)
+ unset(RunCMake_TEST_OPTIONS)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${case}-export-build ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${case}-export-install ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake)
+ unset(RunCMake_TEST_NO_CLEAN)
+
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-import-build)
+ run_cmake_with_options(${case}-import
+ -Dbuild_DIR=${RunCMake_BINARY_DIR}/${case}-export-build
+ -Dinstall_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/install
+ )
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${case}-import-build ${CMAKE_COMMAND} --build . --config Debug)
+ unset(RunCMake_TEST_NO_CLEAN)
+endfunction()
+
+run_ExportImportBuildInstall_test(BuildInstallInterfaceGenex)
diff --git a/Tests/RunCMake/ExportImport/buildlib.c b/Tests/RunCMake/ExportImport/buildlib.c
new file mode 100644
index 0000000..ac19310
--- /dev/null
+++ b/Tests/RunCMake/ExportImport/buildlib.c
@@ -0,0 +1,8 @@
+#if !(!defined(BUILD_LOCAL_INTERFACE) && defined(BUILD_INTERFACE) && \
+ !defined(INSTALL_INTERFACE))
+# error "Incorrect compile definitions"
+#endif
+
+void buildlib(void)
+{
+}
diff --git a/Tests/RunCMake/ExportImport/installlib.c b/Tests/RunCMake/ExportImport/installlib.c
new file mode 100644
index 0000000..00d503c
--- /dev/null
+++ b/Tests/RunCMake/ExportImport/installlib.c
@@ -0,0 +1,8 @@
+#if !(!defined(BUILD_LOCAL_INTERFACE) && !defined(BUILD_INTERFACE) && \
+ defined(INSTALL_INTERFACE))
+# error "Incorrect compile definitions"
+#endif
+
+void installlib(void)
+{
+}
diff --git a/Tests/RunCMake/ExportImport/locallib.c b/Tests/RunCMake/ExportImport/locallib.c
new file mode 100644
index 0000000..f9e3d8d
--- /dev/null
+++ b/Tests/RunCMake/ExportImport/locallib.c
@@ -0,0 +1,8 @@
+#if !(defined(BUILD_LOCAL_INTERFACE) && defined(BUILD_INTERFACE) && \
+ !defined(INSTALL_INTERFACE))
+# error "Incorrect compile definitions"
+#endif
+
+void locallib(void)
+{
+}