summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmExportFileGenerator.cxx5
-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
8 files changed, 151 insertions, 1 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 64448f1..944e703 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -9,6 +9,7 @@
#include <utility>
#include <cm/memory>
+#include <cm/string_view>
#include <cmext/string_view>
#include "cmsys/FStream.hxx"
@@ -1451,7 +1452,9 @@ void cmExportFileGenerator::GenerateTargetFileSets(cmGeneratorTarget* gte,
return;
}
- os << "\n " << this->GetFileSetDirectories(gte, fileSet, te);
+ if (fileSet->GetType() == "HEADERS"_s) {
+ os << "\n " << this->GetFileSetDirectories(gte, fileSet, te);
+ }
}
os << "\n )\nendif()\n\n";
}
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 ()