diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst index 6ad86e3f8e..1ad6c373e2 100644 --- a/Help/command/target_sources.rst +++ b/Help/command/target_sources.rst @@ -77,7 +77,7 @@ have zero or more named file sets. Each file set has a name, a type, a scope of ``INTERFACE``, ``PUBLIC``, or ``PRIVATE``, one or more base directories, and files within those directories. The only acceptable type is ``HEADERS``. The optional default file sets are named after their type. The target may not be a -custom target. +custom target or :prop_tgt:`FRAMEWORK` target. Files in a ``PRIVATE`` or ``PUBLIC`` file set are marked as source files for the purposes of IDE integration. Additionally, files in ``HEADERS`` file sets diff --git a/Help/release/3.23.rst b/Help/release/3.23.rst index 1a3f53ecc0..257c3d5448 100644 --- a/Help/release/3.23.rst +++ b/Help/release/3.23.rst @@ -264,3 +264,17 @@ Other Changes * :manual:`ccmake(1)` may now be enabled on Windows when building CMake from source. This is experimental, and so is not included in official distributions. + +Updates +======= + +Changes made since CMake 3.23.0 include the following. + +3.23.1 +------ + +* The :command:`target_sources` ``FILE_SET`` feature added in CMake 3.23.0 + does not yet place header files properly in Apple :prop_tgt:`FRAMEWORK` + targets. Pending further work in a future version of CMake, it is now + an error to add a ``FILE_SET`` of type ``HEADERS`` to such targets on + Apple platforms. diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 43a9b3ab31..9173a34a3f 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -230,6 +230,10 @@ bool TargetSourcesImpl::HandleOneFileSet( this->SetError("FILE_SETs may not be added to custom targets"); return false; } + if (this->Target->IsFrameworkOnApple()) { + this->SetError("FILE_SETs may not be added to FRAMEWORK targets"); + return false; + } bool const isDefault = args.Type == args.FileSet || (args.Type.empty() && args.FileSet[0] >= 'A' && args.FileSet[0] <= 'Z'); diff --git a/Tests/RunCMake/target_sources/FileSetFramework-result.txt b/Tests/RunCMake/target_sources/FileSetFramework-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt b/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt new file mode 100644 index 0000000000..ae7026a0e0 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetFramework\.cmake:[0-9]+ \(target_sources\): + target_sources FILE_SETs may not be added to FRAMEWORK targets +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetFramework.cmake b/Tests/RunCMake/target_sources/FileSetFramework.cmake new file mode 100644 index 0000000000..d8a924fe3c --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 SHARED lib1.c) +set_property(TARGET lib1 PROPERTY FRAMEWORK ON) +target_sources(lib1 + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h + ) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index d23bce19f1..743879e7c3 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -40,6 +40,9 @@ run_cmake(FileSetNoExistInstall) run_cmake(FileSetDirectories) run_cmake(FileSetCustomTarget) run_cmake(FileSetBadName) +if(APPLE) + run_cmake(FileSetFramework) +endif() set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0115=NEW) run_cmake(FileSetFileNoExist)