diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c3894bc6..f0390befd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.16) project(imhex VERSION 1.5.0) +if (APPLE) + option (CREATE_BUNDLE "Create a bundle on macOS" OFF) +endif() + set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) set(CMAKE_CXX_STANDARD 20) @@ -82,7 +86,29 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGIT_BRANCH=\"\\\"${GIT_BRANCH}\"\\\"") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}\"\\\"") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DIMHEX_VERSION=\"\\\"${PROJECT_VERSION}-Debug\"\\\"") +set(install_dest RUNTIME) + +if (WIN32) + set(application_type WIN32) + set(imhex_icon resource.rc) +elseif (APPLE) + set (imhex_icon "${PROJECT_SOURCE_DIR}/res/mac/AppIcon.icns") + + if (CREATE_BUNDLE) + set(application_type MACOSX_BUNDLE) + set_source_files_properties(${imhex_icon} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + set(MACOSX_BUNDLE_ICON_FILE "AppIcon.icns") + set(MACOSX_BUNDLE_INFO_STRING ${CPACK_PACKAGE_VENDOR}) + set(MACOSX_BUNDLE_GUI_IDENTIFIER "WerWolv.ImHex") + set(MACOSX_BUNDLE_LONG_VERSION_STRING ${CPACK_PACKAGE_VERSION}) + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") + set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2020 WerWolv. All rights reserved." ) + set(install_dest BUNDLE) + endif() +endif() + add_executable(imhex + ${application_type} source/main.cpp source/window.cpp @@ -115,7 +141,7 @@ add_executable(imhex source/views/view_patches.cpp source/views/view_command_palette.cpp - resource.rc + ${imhex_icon} ) set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden) @@ -128,4 +154,4 @@ elseif (UNIX) target_link_libraries(imhex magic crypto ${CMAKE_DL_LIBS} capstone LLVMDemangle imgui libimhex ${Python_LIBRARIES} nlohmann_json::nlohmann_json dl) endif() -install(TARGETS imhex DESTINATION bin) +install(TARGETS imhex ${install_dest} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/icon.ico b/res/icon.ico similarity index 100% rename from icon.ico rename to res/icon.ico diff --git a/res/icon.png b/res/icon.png new file mode 100644 index 000000000..42b6c1fa3 Binary files /dev/null and b/res/icon.png differ diff --git a/res/mac/AppIcon.icns b/res/mac/AppIcon.icns new file mode 100644 index 000000000..8da693d15 Binary files /dev/null and b/res/mac/AppIcon.icns differ diff --git a/resource.rc b/resource.rc index ba196a06e..5befe687a 100644 --- a/resource.rc +++ b/resource.rc @@ -1 +1 @@ -GLFW_ICON ICON icon.ico \ No newline at end of file +GLFW_ICON ICON res/icon.ico \ No newline at end of file