@@ -205,26 +205,28 @@ if(APPLE)
205205 set_source_files_properties (${wxTools_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" )
206206 target_sources (wxTools PRIVATE ${wxTools_ICON} )
207207
208+ # Set the resource files for the macOS bundle
208209 set (RESOURCE_FILES "${CMAKE_SOURCE_DIR} /res/apple/macos/Assets.xcassets" )
209210 set_source_files_properties (${RESOURCE_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" )
210211 target_sources (wxTools PRIVATE ${RESOURCE_FILES} )
211212
212- # Remove the last section from WXT_VERSION, such "1.0.0" -> "1.0"
213- string (REGEX REPLACE "\\ .[0-9]+$" "" short_ver ${WXT_VERSION} )
214- set (WX_TOOLS_BUNDLE_VERSION ${WXT_VERSION} )
215- set (WXT_SHORT_VERSION "${short_ver} " )
216-
213+ # Configure the Info.plist file for the macOS bundle
217214 string (TIMESTAMP WXT_CURRENT_YEAR "%Y" )
218215 message (STATUS "Current year: ${WXT_CURRENT_YEAR} " )
219216 string (TIMESTAMP WXT_BUNDLE_VERSION "%Y%m%d%H%M" )
220217 message (STATUS "[wxTools] WXT_BUNDLE_VERSION: ${WXT_BUNDLE_VERSION} " )
221- # cmake-format: off
222- set (WX_TOOLS_YYYY "${WXT_CURRENT_YEAR} " CACHE STRING "The current year" )
223- # cmake-format: on
218+ set (WXT_PLIST "${CMAKE_BINARY_DIR} /wxTools.plist" )
224219 set (wxt_entitlements "${CMAKE_SOURCE_DIR} /res/apple/macos/wxTools.entitlements" )
220+ configure_file (res/apple/macos/wxTools.plist.in ${WXT_PLIST} )
221+
222+ set_target_properties (wxTools PROPERTIES MACOSX_BUNDLE TRUE )
223+ set_target_properties (wxTools PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${WXT_PLIST} )
224+ if (DEFINED BUNDLE_ID_OPTION)
225+ set_target_properties (wxTools PROPERTIES ${BUNDLE_ID_OPTION} )
226+ endif ()
225227
228+ # cmake-format: off
226229 if (CMAKE_GENERATOR STREQUAL "Xcode" )
227- # cmake-format: off
228230 # set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "<Your Team ID>")
229231 set (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Automatic" )
230232 set (CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${WXT_APP_ID} " )
@@ -235,69 +237,42 @@ if(APPLE)
235237 # * set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION
236238 # * set(CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION
237239 set (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${wxt_entitlements} " )
238- # cmake-format: on
239240 else ()
240- set_target_properties (wxTools PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS
241- "${wxt_entitlements} " )
241+ set_target_properties (wxTools PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${wxt_entitlements} " )
242+ set_target_properties (wxTools PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH "/Applications" )
243+ set_target_properties (wxTools PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Automatic" )
244+ set_target_properties (wxTools PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${wxt_entitlements} " )
242245 endif ()
243-
244- # cmake-format: off
245- configure_file (res/apple/macos/wxTools.plist.in ${CMAKE_BINARY_DIR} /wxTools.plist )
246- set_target_properties (wxTools PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR} /wxTools.plist )
247- set_target_properties (wxTools PROPERTIES CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH "/Applications" )
248- set_target_properties (wxTools PROPERTIES CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Automatic" )
249- set_target_properties (wxTools PROPERTIES CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${wxt_entitlements} " )
250- # cmake-format: on
251- set_target_properties (wxTools PROPERTIES MACOSX_BUNDLE TRUE )
252- # Set the bundle properties
253- # cmake-format: off
254- if (BUNDLE_ID_OPTION)
255- set_target_properties (wxTools PROPERTIES ${BUNDLE_ID_OPTION} )
256- endif ()
257-
258- # * set_target_properties(wxTools PROPERTIES
259- # * MACOSX_BUNDLE TRUE
260- # * MACOSX_BUNDLE_BUNDLE_NAME "wxTools"
261- # * MACOSX_BUNDLE_GUI_IDENTIFIER "${WXT_APP_ID}"
262- # * MACOSX_BUNDLE_BUNDLE_VERSION "${WXT_VERSION}"
263- # * MACOSX_BUNDLE_SHORT_VERSION_STRING "${WXT_SHORT_VERSION}"
264- # * MACOSX_BUNDLE_LONG_VERSION_STRING "${WXT_VERSION}"
265- # * MACOSX_BUNDLE_SHORT_VERSION_STRING "${WXT_SHORT_VERSION}"
266- # * MACOSX_BUNDLE_INFO_STRING "${CMAKE_PROJECT_DESCRIPTION}"
267- # * MACOSX_BUNDLE_COPYRIGHT "Copyright (C) 2024-${WXT_CURRENT_YEAR} x-tools@outlook.com. All rights reserved."
268- # * )
269246 # cmake-format: on
270247
271- # Make pkg and dmg
248+ # Set the bundle properties Make pkg and dmg
272249 # cmake-format: off
273250 add_custom_target (wxTools_pkg_dmg VERBATIM COMMENT "Making pkg and dmg..."
274251 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /assets/wxTools
275252 COMMAND pkgbuild --root wxTools.app --identifier ${WXT_APP_ID} --version ${WXT_VERSION} --install-location /Applications/wxTools.app ${WXT_ASSETS_NAME} .pkg
276253 COMMAND hdiutil create -volname "wxTools" -srcfolder "wxTools.app" -ov -format UDZO "${WXT_ASSETS_NAME} .dmg"
277254 )
278- # cmake-format: on
279255 add_dependencies (wxTools_pkg_dmg wxTools )
256+ # cmake-format: on
280257
281- if ( TRUE )
282-
283- if (EXISTS "${CMAKE_SOURCE_DIR} /private.cmake" )
284- include (${CMAKE_SOURCE_DIR} /private.cmake )
285- message (STATUS "[wxTools-apple] WX_TOOLS_DEV_ID_APP: ${WX_TOOLS_DEV_ID_APP} " )
286- message (STATUS "[wxTools-apple] WX_TOOLS_DEV_ID_INSTALLER: ${WX_TOOLS_DEV_ID_INSTALLER} " )
287- endif ()
258+ # You can set WX_TOOLS_DEV_ID_APP and WX_TOOLS_DEV_ID_INSTALLER in private.cmake to avoid exposing
259+ # your Apple Developer ID in a public repository.
260+ if (EXISTS "${CMAKE_SOURCE_DIR} /private.cmake" )
261+ include (${CMAKE_SOURCE_DIR} /private.cmake )
262+ message (STATUS "[wxTools-apple] WX_TOOLS_DEV_ID_APP: ${WX_TOOLS_DEV_ID_APP} " )
263+ message (STATUS "[wxTools-apple] WX_TOOLS_DEV_ID_INSTALLER: ${WX_TOOLS_DEV_ID_INSTALLER} " )
264+ endif ()
288265
289- if (NOT DEFINED WX_TOOLS_DEV_ID_APP OR NOT DEFINED WX_TOOLS_DEV_ID_INSTALLER)
290- # cmake-format: off
266+ if (NOT DEFINED WX_TOOLS_DEV_ID_APP OR NOT DEFINED WX_TOOLS_DEV_ID_INSTALLER)
267+ # cmake-format: off
291268 set (WX_TOOLS_DEV_ID_APP "xxx_id_developer" CACHE STRING "The app's developer ID" )
292269 set (WX_TOOLS_DEV_ID_INSTALLER "xxx_id_installer" CACHE STRING "The installer's developer ID" )
293270 # cmake-format: on
294- endif ()
295-
296- include (cmake/MacOS/MacOS.cmake )
297- wxt_make_pkg (wxTools ${WX_TOOLS_DEV_ID_APP} ${WX_TOOLS_DEV_ID_INSTALLER} )
298- wxt_make_dmg (wxTools ${WX_TOOLS_DEV_ID_APP} ${WX_TOOLS_DEV_ID_INSTALLER} )
299-
300271 endif ()
272+
273+ include (cmake/MacOS/MacOS.cmake )
274+ wxt_make_pkg (wxTools ${WX_TOOLS_DEV_ID_APP} ${WX_TOOLS_DEV_ID_INSTALLER} )
275+ wxt_make_dmg (wxTools ${WX_TOOLS_DEV_ID_APP} ${WX_TOOLS_DEV_ID_INSTALLER} )
301276endif ()
302277
303278# --------------------------------------------------------------------------------------------------
0 commit comments