Skip to content

Commit

Permalink
CMake: handle emscripten and macOS app install
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 30, 2023
1 parent d5a48fb commit d4cff6c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/hello_imgui_cmake/utils/cache_hello_imgui_path
include(hello_imgui_add_app)

# HELLOIMGUI_ADD_APP_WITH_INSTALL: if ON, hello_imgui_add_app will add install() instructions for the app.
# (this works under Windows, Linux, macOS, and emscripten)
# On desktop platforms, it will install the "app exe" and the "assets" folder in the install folder.
# (this works under Windows, Linux; and macOS if HELLOIMGUI_MACOS_NO_BUNDLE is ON)
option(HELLOIMGUI_ADD_APP_WITH_INSTALL "Add cmake install() instructions with hello_imgui_add_app" ON)


Expand Down
5 changes: 5 additions & 0 deletions hello_imgui_cmake/apple/hello_imgui_apple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ function(hello_imgui_platform_customization app_name assets_location)
hello_imgui_ios_copy_resources(${app_name} ${assets_location})
hello_imgui_ios_add_icons(${app_name} ${assets_location})
endif()

# Install app to install directory
if (MACOSX AND HELLOIMGUI_ADD_APP_WITH_INSTALL)
install(TARGETS ${app_name} DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endfunction()
11 changes: 11 additions & 0 deletions hello_imgui_cmake/assets/him_assets_emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ function(hello_imgui_bundle_assets_from_folder app_name assets_folder)
else()
message(WARNING "hello_imgui_bundle_assets_from_folder: ignoring missing folder ${assets_folder}")
endif()

if (HELLOIMGUI_ADD_APP_WITH_INSTALL)
hello_imgui_get_real_output_directory(${app_name} real_output_directory)
install(FILES
${real_output_directory}/${app_name}.html
${real_output_directory}/${app_name}.data
${real_output_directory}/${app_name}.js
${real_output_directory}/${app_name}.wasm
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
endif()
endfunction()
7 changes: 7 additions & 0 deletions hello_imgui_cmake/emscripten/hello_imgui_emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function(_hello_imgui_emscripten_add_js_css_resources app_name assets_location)
# copy all files to the output directory (no configure_file here)
foreach(resource_file ${resources_files})
file(COPY ${resource_file} DESTINATION ${real_output_directory})
if(HELLOIMGUI_ADD_APP_WITH_INSTALL)
install(FILES ${resource_file} DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endforeach()
endfunction()

Expand Down Expand Up @@ -115,6 +118,10 @@ function(_hello_imgui_create_emscripten_ico app_name assets_location)
configure_file(${user_provided_app_png_icon} ${final_icon} COPYONLY)
endif()

if (HELLOIMGUI_ADD_APP_WITH_INSTALL)
install(FILES ${final_icon} DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()

endfunction()


Expand Down

0 comments on commit d4cff6c

Please sign in to comment.