Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds proper MacOS bundle and icons for Windows builds #381

Merged
merged 10 commits into from
Jul 4, 2024
Merged
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ if(DETHRACE_INSTALL)

set(CPACK_PACKAGE_DIRECTORY dist)

if(MSVC)
if (APPLE)
set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK "ON")
set(CPACK_GENERATOR "DragNDrop")
elseif(MSVC)
set(CPACK_GENERATOR ZIP)
set(ext ".zip")
else()
Expand Down
Binary file added packaging/macos/dethrace.icns
Binary file not shown.
16 changes: 16 additions & 0 deletions packaging/macos/generate_icns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

ICON_PATH=source.png
rm -r dethrace.iconset || true
mkdir -p dethrace.iconset
sips -z 16 16 $ICON_PATH --out dethrace.iconset/icon_16x16.png
sips -z 32 32 $ICON_PATH --out dethrace.iconset/icon_16x16@2x.png
sips -z 32 32 $ICON_PATH --out dethrace.iconset/icon_32x32.png
sips -z 64 64 $ICON_PATH --out dethrace.iconset/icon_32x32@2x.png
sips -z 128 128 $ICON_PATH --out dethrace.iconset/icon_128x128.png
sips -z 256 256 $ICON_PATH --out dethrace.iconset/icon_128x128@2x.png
sips -z 256 256 $ICON_PATH --out dethrace.iconset/icon_256x256.png
sips -z 512 512 $ICON_PATH --out dethrace.iconset/icon_256x256@2x.png
sips -z 512 512 $ICON_PATH --out dethrace.iconset/icon_512x512.png
sips -z 1024 1024 $ICON_PATH --out dethrace.iconset/icon_512x512@2x.png
iconutil -c icns dethrace.iconset
Binary file added packaging/macos/source.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packaging/windows/dethrace.ico
Binary file not shown.
1 change: 1 addition & 0 deletions packaging/windows/dethrace.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "dethrace.ico"
3 changes: 3 additions & 0 deletions packaging/windows/generate_ico.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

convert -background transparent source.png -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "dethrace.ico"
Binary file added packaging/windows/source.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 34 additions & 2 deletions src/DETHRACE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,31 @@ target_sources(dethrace_obj PRIVATE
)

# Create our main game binary.
add_executable(dethrace)
add_executable(dethrace
WIN32
MACOSX_BUNDLE
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
${CMAKE_SOURCE_DIR}/packaging/windows/dethrace.rc
)

if (APPLE)
set_target_properties(dethrace PROPERTIES
BUNDLE True
MACOSX_BUNDLE_DISPLAY_NAME "Deth Race"
OUTPUT_NAME "Deth Race"
MACOSX_BUNDLE_BUNDLE_VERSION ${DETHRACE_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${DETHRACE_VERSION}
MACOSX_BUNDLE_ICON_FILE dethrace.icns
)
set_source_files_properties(${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
target_sources(dethrace_obj PRIVATE
${CMAKE_SOURCE_DIR}/packaging/macos/dethrace.icns
)

endif()

target_link_libraries(dethrace PRIVATE dethrace_obj compile_with_werror)
target_sources(dethrace PRIVATE main.c)

Expand Down Expand Up @@ -195,8 +219,16 @@ endif()

if (DETHRACE_INSTALL)
install(TARGETS dethrace
RUNTIME DESTINATION "."
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
dethrace-labs marked this conversation as resolved.
Show resolved Hide resolved
)

INSTALL(CODE "
include(BundleUtilities)
fixup_bundle(\"${CMAKE_BINARY_DIR}/Deth Race.app\" \"\" \"/Library/Frameworks\")
"
COMPONENT RUNTIME)

if(MSVC)
INSTALL(FILES $<TARGET_PDB_FILE:dethrace>
DESTINATION "."
Expand Down
Loading