summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-02-28 00:15:23 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-02-28 10:26:10 (GMT)
commit028f3134e55576ff7879d159568b9a475ebb3626 (patch)
tree756757da5e426b6c98e89ac1c3720bca66d0c2a7 /Tests
parentfebe479570e96302bd4041cd1104fb95bc99e66d (diff)
downloadCMake-028f3134e55576ff7879d159568b9a475ebb3626.zip
CMake-028f3134e55576ff7879d159568b9a475ebb3626.tar.gz
CMake-028f3134e55576ff7879d159568b9a475ebb3626.tar.bz2
cmExportFileGenerator: only export include paths for HEADERS file sets
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/CMakeLists.txt48
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/test/CMakeLists.txt17
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/CMakeLists.txt51
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/test/CMakeLists.txt17
7 files changed, 147 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index ece190c..c2c00d2 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -260,6 +260,7 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(export-interface-no-properties-build)
run_cxx_module_test(export-interface-build)
run_cxx_module_test(export-include-directories-build)
+ run_cxx_module_test(export-include-directories-old-cmake-build)
run_cxx_module_test(export-usage-build)
run_cxx_module_test(export-bmi-and-interface-build)
run_cxx_module_test(export-transitive-targets-build)
@@ -300,6 +301,7 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(export-interface-no-properties-install)
run_cxx_module_test(export-interface-install)
run_cxx_module_test(export-include-directories-install)
+ run_cxx_module_test(export-include-directories-old-cmake-install)
run_cxx_module_test(export-usage-install)
run_cxx_module_test(export-bmi-and-interface-install)
run_cxx_module_test(export-transitive-targets-install)
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/CMakeLists.txt
new file mode 100644
index 0000000..5254117
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/CMakeLists.txt
@@ -0,0 +1,48 @@
+cmake_minimum_required(VERSION 3.24...3.28)
+project(cxx_modules_export_include_directories_old_cmake CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(export_include_directories_old_cmake)
+target_sources(export_include_directories_old_cmake
+ PUBLIC
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx
+ )
+target_compile_features(export_include_directories_old_cmake PUBLIC cxx_std_20)
+
+install(TARGETS export_include_directories_old_cmake
+ EXPORT CXXModules
+ FILE_SET modules DESTINATION "lib/cxx/miu")
+export(EXPORT CXXModules
+ NAMESPACE CXXModules::
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories_old_cmake-targets.cmake"
+ CXX_MODULES_DIRECTORY "export_include_directories_old_cmake-cxx-modules")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories_old_cmake-config.cmake"
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_include_directories_old_cmake-targets.cmake\")
+set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
+")
+
+set(generator
+ -G "${CMAKE_GENERATOR}")
+if (CMAKE_GENERATOR_TOOLSET)
+ list(APPEND generator
+ -T "${CMAKE_GENERATOR_TOOLSET}")
+endif ()
+if (CMAKE_GENERATOR_PLATFORM)
+ list(APPEND generator
+ -A "${CMAKE_GENERATOR_PLATFORM}")
+endif ()
+
+add_test(NAME export_include_directories_old_cmake_build
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}"
+ "-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}"
+ "-Dexport_include_directories_old_cmake_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+ ${generator}
+ -S "${CMAKE_CURRENT_SOURCE_DIR}/test"
+ -B "${CMAKE_CURRENT_BINARY_DIR}/test")
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/importable.cxx
new file mode 100644
index 0000000..607680a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/test/CMakeLists.txt
new file mode 100644
index 0000000..3e9cd31
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-build/test/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.22)
+project(cxx_modules_library NONE)
+
+set(CMAKE_VERSION "3.22.0") # Trigger non-fileset export code.
+find_package(export_include_directories_old_cmake REQUIRED)
+
+if (NOT TARGET CXXModules::export_include_directories_old_cmake)
+ message(FATAL_ERROR
+ "Missing imported target")
+endif ()
+
+get_property(include_directories TARGET CXXModules::export_include_directories_old_cmake
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+if (include_directories)
+ message(FATAL_ERROR
+ "Exported include directory on C++ module interface CXXModules::export_include_directories_old_cmake:\n ${include_directories}")
+endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/CMakeLists.txt
new file mode 100644
index 0000000..18092c2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/CMakeLists.txt
@@ -0,0 +1,51 @@
+cmake_minimum_required(VERSION 3.24...3.28)
+project(cxx_modules_export_include_directories_old_cmake CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(export_include_directories_old_cmake)
+target_sources(export_include_directories_old_cmake
+ PUBLIC
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx
+ )
+target_compile_features(export_include_directories_old_cmake PUBLIC cxx_std_20)
+
+install(TARGETS export_include_directories_old_cmake
+ EXPORT CXXModules
+ FILE_SET modules DESTINATION "lib/cxx/miu")
+install(EXPORT CXXModules
+ NAMESPACE CXXModules::
+ DESTINATION "lib/cmake/export_include_directories_old_cmake"
+ FILE "export_include_directories_old_cmake-targets.cmake"
+ CXX_MODULES_DIRECTORY "export_include_directories_old_cmake-cxx-modules")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories_old_cmake-config.cmake"
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_include_directories_old_cmake-targets.cmake\")
+set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
+")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_include_directories_old_cmake-config.cmake"
+ DESTINATION "lib/cmake/export_include_directories_old_cmake")
+
+set(generator
+ -G "${CMAKE_GENERATOR}")
+if (CMAKE_GENERATOR_TOOLSET)
+ list(APPEND generator
+ -T "${CMAKE_GENERATOR_TOOLSET}")
+endif ()
+if (CMAKE_GENERATOR_PLATFORM)
+ list(APPEND generator
+ -A "${CMAKE_GENERATOR_PLATFORM}")
+endif ()
+
+add_test(NAME export_include_directories_old_cmake_build
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
+ "-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi"
+ "-Dexport_include_directories_old_cmake_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_include_directories_old_cmake"
+ ${generator}
+ -S "${CMAKE_CURRENT_SOURCE_DIR}/test"
+ -B "${CMAKE_CURRENT_BINARY_DIR}/test")
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/importable.cxx
new file mode 100644
index 0000000..607680a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/test/CMakeLists.txt
new file mode 100644
index 0000000..db580ef
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-include-directories-old-cmake-install/test/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.24...3.28)
+project(cxx_modules_library NONE)
+
+set(CMAKE_VERSION "3.22.0") # Trigger non-fileset export code.
+find_package(export_include_directories_old_cmake REQUIRED)
+
+if (NOT TARGET CXXModules::export_include_directories_old_cmake)
+ message(FATAL_ERROR
+ "Missing imported target")
+endif ()
+
+get_property(include_directories TARGET CXXModules::export_include_directories_old_cmake
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+if (include_directories)
+ message(FATAL_ERROR
+ "Exported include directory on C++ module interface CXXModules::export_include_directories_old_cmake:\n ${include_directories}")
+endif ()