This repository has been archived by the owner on Jun 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMacBundle.cmake
41 lines (36 loc) · 1.79 KB
/
MacBundle.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# COLLECT all assets inside 'res/' folder into a list
list(APPEND ASSET_FILES "")
# start recursing the directory tree
file(GLOB_RECURSE my_assets "${CMAKE_SOURCE_DIR}/res/*")
foreach(FILE ${my_assets})
get_filename_component(FILENAME ${FILE} NAME)
if(NOT FILENAME STREQUAL ".DS_Store")
# skip .DS_Store
file(RELATIVE_PATH NEW_FILE "${CMAKE_SOURCE_DIR}/" ${FILE})
get_filename_component(REL_DIR ${NEW_FILE} DIRECTORY) # parent dir
get_filename_component(END_FILE ${NEW_FILE} NAME) # filename (end of path)
list(APPEND ASSET_FILES "${REL_DIR}/${END_FILE}")
set_source_files_properties(${REL_DIR}/${END_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION
"Resources/${REL_DIR}")
endif()
endforeach()
# icon
set(application_icon "${CMAKE_SOURCE_DIR}/res/macos_icon.icns")
set_source_files_properties(${application_icon} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
# build executable as MACOSX BUNDLE
add_executable(${CMAKE_PROJECT_NAME} MACOSX_BUNDLE
${GAME_SRC} "${CMAKE_PROJECT_DIR}/src/ResourcePath.mm" ${application_icon} ${ASSET_FILES})
# Metadata for Apple info.plist
set_target_properties(
${CMAKE_PROJECT_NAME}
PROPERTIES BUNDLE TRUE
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS
"@executable_path/../Frameworks"
MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.mirceanton.${CMAKE_PROJECT_NAME}"
MACOSX_BUNDLE_COPYRIGHT "(c) 2022, mirceanton"
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
RESOURCE ${ASSET_FILES})