Apple: Add CFBundleName to framework Info.plist files

Fixes: #26046
This commit is contained in:
Brad King
2024-06-18 08:24:23 -04:00
parent 7c1a18655b
commit 8a06f173d9
8 changed files with 49 additions and 0 deletions

View File

@@ -12,12 +12,20 @@ file name which may be a full path.
The following target properties may be set to specify content to be
configured into the file:
``MACOSX_FRAMEWORK_BUNDLE_NAME``
.. versionadded:: 3.31
Sets ``CFBundleName``.
``MACOSX_FRAMEWORK_BUNDLE_VERSION``
Sets ``CFBundleVersion``.
``MACOSX_FRAMEWORK_ICON_FILE``
Sets ``CFBundleIconFile``.
``MACOSX_FRAMEWORK_IDENTIFIER``
Sets ``CFBundleIdentifier``.
``MACOSX_FRAMEWORK_SHORT_VERSION_STRING``
Sets ``CFBundleShortVersionString``.

View File

@@ -0,0 +1,6 @@
apple-framework-bundle-name
---------------------------
* The :prop_tgt:`MACOSX_FRAMEWORK_BUNDLE_NAME <MACOSX_FRAMEWORK_INFO_PLIST>`
target property was added to set the ``CFBundleName`` key in an Apple
:prop_tgt:`FRAMEWORK`'s ``Info.plist`` file.

View File

@@ -12,6 +12,8 @@
<string>${MACOSX_FRAMEWORK_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${MACOSX_FRAMEWORK_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>

View File

@@ -4369,6 +4369,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_NAME");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION");
mf->ConfigureFile(inFile, fname, false, false, false);
}

View File

@@ -0,0 +1,24 @@
macro(check_plist key expect)
execute_process(
COMMAND plutil -extract "${key}" xml1 "${plist-file}" -o -
RESULT_VARIABLE result
OUTPUT_VARIABLE actual
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(actual MATCHES "<string>([^<>]*)</string>")
set(actual "${CMAKE_MATCH_1}")
endif()
if(NOT "${actual}" STREQUAL "${expect}")
string(CONCAT RunCMake_TEST_FAILED
"Framework Info.plist key \"${key}\" has value:\n"
" \"${actual}\"\n"
"but we expected:\n"
" \"${expect}\""
)
endif()
endmacro()
check_plist(CFBundleIdentifier MyFrameworkId)
check_plist(CFBundleName MyFrameworkBundleName)
check_plist(CFBundleVersion 3.2.1)
check_plist(CFBundleShortVersionString 3)

View File

@@ -15,6 +15,10 @@ if("${CMAKE_FRAMEWORK}" STREQUAL "")
FRAMEWORK TRUE)
endif()
set_target_properties(Framework PROPERTIES
MACOSX_FRAMEWORK_BUNDLE_NAME MyFrameworkBundleName
MACOSX_FRAMEWORK_BUNDLE_VERSION 3.2.1
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 3
MACOSX_FRAMEWORK_IDENTIFIER MyFrameworkId
PUBLIC_HEADER foo.h
RESOURCE "res.txt")
set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

View File

@@ -58,3 +58,5 @@ if(NOT EXISTS ${framework-header})
set(RunCMake_TEST_FAILED "Framework header file not found at \n ${framework-header}")
return()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FrameworkLayout-check-common.cmake)

View File

@@ -58,3 +58,5 @@ if(NOT EXISTS ${framework-header})
set(RunCMake_TEST_FAILED "Framework headers not found at\n ${framework-header}")
return()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FrameworkLayout-check-common.cmake)