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

Packed resources #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ if (DESKTOP_APP_USE_PACKAGED_RLOTTIE)
)
endif()

if (DESKTOP_APP_USE_PACKED_RESOURCES)
target_compile_definitions(common_options
INTERFACE
DESKTOP_APP_USE_PACKED_RESOURCES
)
endif()

if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "")
target_compile_definitions(common_options
INTERFACE
Expand Down
16 changes: 11 additions & 5 deletions target_prepare_qrc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL

function(target_add_resource target_name)
set(list ${ARGV})
list(REMOVE_AT list 0)
set(list ${ARGN})

target_sources(${target_name} PRIVATE ${list})
get_target_property(existing_resources ${target_name} RESOURCE)
if (NOT "${existing_resources}" STREQUAL "existing_resources-NOTFOUND")
Expand All @@ -18,7 +18,13 @@ function(target_add_resource target_name)
endfunction()

function(target_prepare_qrc target_name)
if (NOT APPLE)
if (ARGC GREATER 1)
set(rcc_file ${ARGV1})
else()
set(rcc_file ${target_name}.rcc)
endif()

if (NOT DESKTOP_APP_USE_PACKED_RESOURCES)
set_target_properties(${target_name} PROPERTIES AUTORCC ON)
else()
set(rcc_flags --binary "$<TARGET_PROPERTY:${target_name},AUTORCC_OPTIONS>")
Expand All @@ -31,12 +37,12 @@ function(target_prepare_qrc target_name)
elseif (LINUX)
set(qrc_files "$<FILTER:${qrc_files_all},EXCLUDE,(win|mac|darwin|osx)\\.>")
endif()
set(rcc_file ${target_name}.rcc)
set(rcc_path "${CMAKE_BINARY_DIR}/${rcc_file}")
source_group(TREE ${CMAKE_BINARY_DIR} PREFIX Resources FILES ${rcc_path})
set(cmd_run "$<IF:$<BOOL:${qrc_files}>,,true>") # do nothing if qrc_files are empty
add_custom_command(OUTPUT ${rcc_path}
DEPENDS ${qrc_files}
COMMAND Qt::rcc ${rcc_flags} -o ${rcc_path} ${qrc_files}
COMMAND ${cmd_run} Qt::rcc ${rcc_flags} -o ${rcc_path} ${qrc_files}
COMMAND_EXPAND_LISTS VERBATIM
)
target_add_resource(${target_name} ${rcc_path})
Expand Down
1 change: 1 addition & 0 deletions variables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cmake_dependent_option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation
cmake_dependent_option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages." OFF LINUX OFF)
option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled patched ones." OFF)
option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled patched one." OFF)
option(DESKTOP_APP_USE_PACKED_RESOURCES "Whether to pack resources into a separate archive." ${APPLE})
option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF)
option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target})
option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate})
Expand Down