-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
300 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
if (ANDROID) | ||
|
||
function (hello_imgui_platform_customization app_name assets_location) | ||
endfunction() | ||
|
||
endif(ANDROID) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
string(REGEX MATCH "SIMULATOR.*" IOS_IS_SIMULATOR ${PLATFORM}) | ||
|
||
function(hello_imgui_ios_set_dev_team app_name) | ||
if (IOS_IS_SIMULATOR) | ||
return() | ||
endif() | ||
set_target_properties( ${app_name} PROPERTIES | ||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM} | ||
) | ||
endfunction() | ||
|
||
|
||
# Check CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM | ||
function(hello_imgui_ios_check_development_team) | ||
if (IOS_IS_SIMULATOR) | ||
return() | ||
endif() | ||
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM OR ${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM} STREQUAL "123456789A") | ||
if(DEFINED ENV{CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}) | ||
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM $ENV{CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM} CACHE STRING "iOS Devel Team id" FORCE) | ||
else() | ||
message(FATAL_ERROR "Please set CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM") | ||
endif() | ||
endif() | ||
message(VERBOSE "CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}") | ||
endfunction() | ||
|
||
# Handle icons (and conversion if necessary) | ||
function(hello_imgui_ios_add_icons app_name assets_location) | ||
# Default HelloImGui icons | ||
set(icons_assets_folder ${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/apple/ios_icons) | ||
set(found_custom_icon OFF) | ||
|
||
# First possible custom icons folder, in ios/icons | ||
set(custom_icons_assets_folder ${CMAKE_CURRENT_SOURCE_DIR}/ios/icons) | ||
if ((NOT found_custom_icon) AND (IS_DIRECTORY ${custom_icons_assets_folder})) | ||
message(STATUS "hello_imgui_ios_add_icons: found ios/icons specific icons folder for app ${app_name} ") | ||
set(icons_assets_folder ${custom_icons_assets_folder}) | ||
set(found_custom_icon ON) | ||
endif() | ||
|
||
# Second possible custom icon, in assets/app_settings/icon.png | ||
set(custom_app_png_icon ${assets_location}/app_settings/icon.png) | ||
if ((NOT found_custom_icon) AND (EXISTS ${custom_app_png_icon})) | ||
# find python program | ||
find_program(PYTHON_EXECUTABLE NAMES python3 python) | ||
if (NOT PYTHON_EXECUTABLE) | ||
message(WARNING " | ||
${app_name}: can't create iOS icon from ${custom_app_png_icon} | ||
(did not find python) | ||
This is not a fatal error, but the iOS app will not have the correct icon. | ||
") | ||
return() | ||
endif() | ||
|
||
# We need to convert icon.png to an icon folder | ||
set(script_png_icon_to_icon_folder "${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/apple/ios_png_icon_to_icon_folder.py") | ||
message(STATUS "hello_imgui_ios_add_icons: converting ${custom_app_png_icon} to icon folder for app ${app_name} ") | ||
set(custom_icons_assets_folder ${CMAKE_CURRENT_BINARY_DIR}/custom_icons) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} ${script_png_icon_to_icon_folder} ${custom_app_png_icon} ${custom_icons_assets_folder} | ||
RESULT_VARIABLE script_png_icon_to_icon_folder_result | ||
) | ||
if (NOT ${script_png_icon_to_icon_folder_result} EQUAL 0) | ||
message(WARNING " | ||
${app_name}: failed to create iOS icon from ${custom_app_icon} | ||
Tried to run: | ||
${PYTHON_EXECUTABLE} ${script_png_icon_to_icon_folder} ${custom_app_png_icon} ${custom_icons_assets_folder} | ||
This is not a fatal error, but the app will not have a custom icon. | ||
") | ||
return() | ||
endif() | ||
|
||
set(icons_assets_folder ${custom_icons_assets_folder}) | ||
set(found_custom_icon ON) | ||
endif() | ||
|
||
hello_imgui_apple_bundle_add_files_from_folder(${app_name} ${icons_assets_folder} "") | ||
endfunction() | ||
|
||
|
||
function(hello_imgui_ios_copy_resources app_name assets_location) | ||
# if assets_location/app_settings/apple/Resources/ios exists, copy it to the bundle Resources folder | ||
set(custom_resources_folder ${assets_location}/app_settings/apple/Resources/ios) | ||
if (EXISTS ${custom_resources_folder}) | ||
message(STATUS "hello_imgui_ios_copy_resources: found custom iOS resources folder ${custom_resources_folder} for app ${app_name} ") | ||
hello_imgui_apple_bundle_add_files_from_folder(${app_name} ${custom_resources_folder} "Resources") | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
######################################################## | ||
# Specific functions for MACOSX | ||
######################################################## | ||
# Handle icons (and conversion if necessary) | ||
function(hello_imgui_macos_add_icons app_name assets_location) | ||
# Default HelloImGui icon | ||
set(app_icon ${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/apple/mac_icons/icon.icns) | ||
set(found_custom_icon OFF) | ||
|
||
# First possible custom icon in macos/icon.icns | ||
set(custom_app_icon ${CMAKE_CURRENT_SOURCE_DIR}/macos/${HELLO_IMGUI_BUNDLE_ICON_FILE}) | ||
if ((NOT found_custom_icon) AND (EXISTS ${custom_app_icon})) | ||
set(app_icon ${custom_app_icon}) | ||
set(found_custom_icon ON) | ||
message(STATUS "hello_imgui_macos_add_icons: found app specific icon at ${custom_app_icon} for app ${app_name} ") | ||
endif() | ||
|
||
# Second possible custom icon, in assets/app_settings/icon.png (which we need to convert to icon.icns) | ||
set(custom_app_png_icon ${assets_location}/app_settings/icon.png) | ||
if ((NOT found_custom_icon) AND (EXISTS ${custom_app_png_icon})) | ||
# find python program | ||
find_program(PYTHON_EXECUTABLE NAMES python3 python) | ||
if (NOT PYTHON_EXECUTABLE) | ||
message(WARNING " | ||
${app_name}: can't create a macOS icons from ${custom_app_png_icon} | ||
(did not find python) | ||
This is not a fatal error, but the app will not have a custom icon. | ||
") | ||
return() | ||
endif() | ||
|
||
# We need to convert icon.png to icon.icns | ||
set(script_png_to_icns "${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/apple/macos_png_icon_to_icns.py") | ||
message(VERBOSE "hello_imgui_macos_add_icons: converting ${custom_app_png_icon} to icns for app ${app_name}") | ||
set(custom_app_icon ${CMAKE_CURRENT_BINARY_DIR}/icon.icns) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} ${script_png_to_icns} ${custom_app_png_icon} ${custom_app_icon} | ||
RESULT_VARIABLE script_png_to_icns_result | ||
) | ||
if (NOT ${script_png_to_icns_result} EQUAL 0) | ||
message(WARNING " | ||
${app_name}: failed to create macOS icon from ${custom_app_icon} | ||
Tried to run: | ||
${PYTHON_EXECUTABLE} ${script_png_to_icns} ${custom_app_png_icon} ${custom_app_icon} | ||
This is not a fatal error, but the app will not have a custom icon. | ||
") | ||
return() | ||
endif() | ||
|
||
set(app_icon ${custom_app_icon}) | ||
set(found_custom_icon ON) | ||
message(VERBOSE "found custom icon at ${custom_app_icon} for app ${app_name} ") | ||
endif() | ||
|
||
# Add icon to target | ||
target_sources(${app_name} PRIVATE ${app_icon}) | ||
set_source_files_properties(${app_icon} | ||
PROPERTIES | ||
MACOSX_PACKAGE_LOCATION "Resources" | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,60 @@ | ||
# if we are under windows | ||
if (WIN32) | ||
|
||
function(_hello_imgui_create_windows_ico assets_location) | ||
set(custom_app_png_icon ${assets_location}/app_settings/icon.png) | ||
if (NOT EXISTS ${custom_app_png_icon}) | ||
return() | ||
endif() | ||
|
||
# find python program | ||
find_program(PYTHON_EXECUTABLE NAMES python3 python) | ||
# if python is not found, we can't create the ico file | ||
if (NOT PYTHON_EXECUTABLE) | ||
message(WARNING " | ||
${app_name}: can't create a windows ico file from ${custom_app_png_icon} | ||
(did not find python) | ||
This is not a fatal error, but the web app will not have a favicon. | ||
") | ||
return() | ||
endif() | ||
|
||
# We need to convert icon.png to a windows ico file | ||
set(script_png_to_ico "${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/windows/windows_png_icon_to_ico.py") | ||
message(VERBOSE "_hello_imgui_create_ico: converting ${custom_app_png_icon} to windows ico for app ${app_name}") | ||
set(custom_app_icon ${CMAKE_CURRENT_BINARY_DIR}/icon.ico) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} ${script_png_to_ico} ${custom_app_png_icon} ${custom_app_icon} | ||
RESULT_VARIABLE script_png_to_ico_result | ||
) | ||
if (NOT ${script_png_to_ico_result} EQUAL 0) | ||
message(WARNING " | ||
${app_name}: failed to create a Windows ico file from ${custom_app_icon} | ||
Tried to run: | ||
${PYTHON_EXECUTABLE} ${script_png_to_ico} ${custom_app_png_icon} ${custom_app_icon} | ||
This is not a fatal error, but the app will not have a custom icon. | ||
In order to have a custom icon, you need to have python with the Pillow package: | ||
pip install Pillow | ||
") | ||
return() | ||
endif() | ||
endfunction() | ||
|
||
function(_hello_imgui_add_windows_icon app_name assets_location) | ||
_hello_imgui_create_windows_ico(${assets_location}) | ||
set(custom_app_icon ${CMAKE_CURRENT_BINARY_DIR}/icon.ico) | ||
if (NOT EXISTS ${custom_app_icon}) | ||
return() | ||
endif() | ||
|
||
# Create rc file | ||
set(icon_rc_file "${CMAKE_CURRENT_BINARY_DIR}/app_${app_name}.rc") | ||
set(icon_rc_file_contents "IDI_ICON1 ICON DISCARDABLE \"${custom_app_icon}\"") | ||
file(WRITE ${icon_rc_file} ${icon_rc_file_contents}) | ||
|
||
# Add the rc file to the executable | ||
target_sources(${app_name} PRIVATE ${icon_rc_file}) | ||
endfunction() | ||
|
||
|
||
function(hello_imgui_platform_customization app_name assets_location) | ||
_hello_imgui_add_windows_icon(${app_name} ${assets_location}) | ||
endfunction() | ||
endif(WIN32) | ||
|
||
|
||
|
||
function(_hello_imgui_create_windows_ico assets_location) | ||
set(custom_app_png_icon ${assets_location}/app_settings/icon.png) | ||
if (NOT EXISTS ${custom_app_png_icon}) | ||
return() | ||
endif() | ||
|
||
# find python program | ||
find_program(PYTHON_EXECUTABLE NAMES python3 python) | ||
# if python is not found, we can't create the ico file | ||
if (NOT PYTHON_EXECUTABLE) | ||
message(WARNING " | ||
${app_name}: can't create a windows ico file from ${custom_app_png_icon} | ||
(did not find python) | ||
This is not a fatal error, but the web app will not have a favicon. | ||
") | ||
return() | ||
endif() | ||
|
||
# We need to convert icon.png to a windows ico file | ||
set(script_png_to_ico "${HELLOIMGUI_BASEPATH}/hello_imgui_cmake/windows/windows_png_icon_to_ico.py") | ||
message(VERBOSE "_hello_imgui_create_ico: converting ${custom_app_png_icon} to windows ico for app ${app_name}") | ||
set(custom_app_icon ${CMAKE_CURRENT_BINARY_DIR}/icon.ico) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} ${script_png_to_ico} ${custom_app_png_icon} ${custom_app_icon} | ||
RESULT_VARIABLE script_png_to_ico_result | ||
) | ||
if (NOT ${script_png_to_ico_result} EQUAL 0) | ||
message(WARNING " | ||
${app_name}: failed to create a Windows ico file from ${custom_app_icon} | ||
Tried to run: | ||
${PYTHON_EXECUTABLE} ${script_png_to_ico} ${custom_app_png_icon} ${custom_app_icon} | ||
This is not a fatal error, but the app will not have a custom icon. | ||
In order to have a custom icon, you need to have python with the Pillow package: | ||
pip install Pillow | ||
") | ||
return() | ||
endif() | ||
endfunction() | ||
|
||
function(_hello_imgui_add_windows_icon app_name assets_location) | ||
_hello_imgui_create_windows_ico(${assets_location}) | ||
set(custom_app_icon ${CMAKE_CURRENT_BINARY_DIR}/icon.ico) | ||
if (NOT EXISTS ${custom_app_icon}) | ||
return() | ||
endif() | ||
|
||
# Create rc file | ||
set(icon_rc_file "${CMAKE_CURRENT_BINARY_DIR}/app_${app_name}.rc") | ||
set(icon_rc_file_contents "IDI_ICON1 ICON DISCARDABLE \"${custom_app_icon}\"") | ||
file(WRITE ${icon_rc_file} ${icon_rc_file_contents}) | ||
|
||
# Add the rc file to the executable | ||
target_sources(${app_name} PRIVATE ${icon_rc_file}) | ||
endfunction() | ||
|
||
|
||
function(hello_imgui_platform_customization app_name assets_location) | ||
_hello_imgui_add_windows_icon(${app_name} ${assets_location}) | ||
endfunction() |