summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/target_sources.rst4
-rw-r--r--Source/cmTargetSourcesCommand.cxx3
-rw-r--r--Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported-stderr.txt6
-rw-r--r--Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported.cmake8
-rw-r--r--Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt6
-rw-r--r--Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported.cmake8
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
7 files changed, 33 insertions, 3 deletions
diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst
index 0c4323c..4699a08 100644
--- a/Help/command/target_sources.rst
+++ b/Help/command/target_sources.rst
@@ -89,7 +89,7 @@ files within those directories. The acceptable types include:
Sources which contain C++ interface module or partition units (i.e., those
using the ``export`` keyword). This file set type may not have an
- ``INTERFACE`` scope.
+ ``INTERFACE`` scope except on ``IMPORTED`` targets.
``CXX_MODULE_HEADER_UNITS``
@@ -98,7 +98,7 @@ files within those directories. The acceptable types include:
Experimental. Gated by ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
C++ header sources which may be imported by other C++ source code. This file
- set type may not have an ``INTERFACE`` scope.
+ set type may not have an ``INTERFACE`` scope except on ``IMPORTED`` targets.
The optional default file sets are named after their type. The target may not
be a custom target or :prop_tgt:`FRAMEWORK` target.
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 76b0384..74945fa 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -269,7 +269,8 @@ bool TargetSourcesImpl::HandleOneFileSet(
}
if (cmFileSetVisibilityIsForInterface(visibility) &&
- !cmFileSetVisibilityIsForSelf(visibility)) {
+ !cmFileSetVisibilityIsForSelf(visibility) &&
+ !this->Target->IsImported()) {
if (type == "CXX_MODULES"_s || type == "CXX_MODULE_HEADER_UNITS"_s) {
this->SetError(
R"(File set TYPEs "CXX_MODULES" and "CXX_MODULE_HEADER_UNITS" may not have "INTERFACE" visibility)");
diff --git a/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported-stderr.txt
new file mode 100644
index 0000000..1b4ba5d
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported-stderr.txt
@@ -0,0 +1,6 @@
+CMake Warning \(dev\) at FileSetModuleHeaderUnitsInterfaceImported.cmake:2 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:6 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported.cmake b/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported.cmake
new file mode 100644
index 0000000..9ff5606
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/FileSetModuleHeaderUnitsInterfaceImported.cmake
@@ -0,0 +1,8 @@
+add_library(module-header SHARED IMPORTED)
+target_sources(module-header
+ INTERFACE
+ FILE_SET fs TYPE CXX_MODULE_HEADER_UNITS FILES
+ sources/module-header.h)
+target_compile_features(module-header
+ INTERFACE
+ cxx_std_20)
diff --git a/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt
new file mode 100644
index 0000000..4420bbc
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported-stderr.txt
@@ -0,0 +1,6 @@
+CMake Warning \(dev\) at FileSetModulesInterfaceImported.cmake:2 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:6 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported.cmake b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported.cmake
new file mode 100644
index 0000000..6640ae9
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/FileSetModulesInterfaceImported.cmake
@@ -0,0 +1,8 @@
+add_library(module SHARED IMPORTED)
+target_sources(module
+ INTERFACE
+ FILE_SET fs TYPE CXX_MODULES FILES
+ sources/module.cxx)
+target_compile_features(module
+ INTERFACE
+ cxx_std_20)
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index 68fdcae..d459972 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -60,6 +60,7 @@ foreach (fileset_type IN LISTS fileset_types)
foreach (scope IN LISTS scopes)
run_cmake("FileSet${fileset_type}${scope}")
endforeach ()
+ run_cmake("FileSet${fileset_type}InterfaceImported")
# Test the error message when a non-C++ source file is found in the source
# list.