FILE_SET: Forbid adding header sets to Apple FRAMEWORK libraries

The feature needs a specialized implementation to place headers
in the right place inside frameworks.  To avoid silently doing
the wrong thing, make this case an error for the 3.23 series.

Issue: #23386
This commit is contained in:
Kyle Edwards
2022-04-06 16:40:34 -04:00
committed by Brad King
parent 42bca07cc6
commit f779f8c0ad
7 changed files with 34 additions and 1 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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');

View File

@@ -0,0 +1 @@
1

View File

@@ -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\)$

View File

@@ -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
)

View File

@@ -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)