Browse Source

Apple: Add CFBundleName to framework Info.plist files

Fixes: #26046
Brad King 1 year ago
parent
commit
8a06f173d9

+ 8 - 0
Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst

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

+ 6 - 0
Help/release/dev/apple-framework-bundle-name.rst

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

+ 2 - 0
Modules/MacOSXFrameworkInfo.plist.in

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

+ 1 - 0
Source/cmLocalGenerator.cxx

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

+ 24 - 0
Tests/RunCMake/Framework/FrameworkLayout-check-common.cmake

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

+ 4 - 0
Tests/RunCMake/Framework/FrameworkLayout.cmake

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

+ 2 - 0
Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake

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

+ 2 - 0
Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake

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