Avoid running expensive icon-bundling code on every CMake re-configuration

This commit is contained in:
Martchus 2023-03-23 22:08:57 +01:00
parent 0e151b3cc6
commit 5430edc5fc
1 changed files with 125 additions and 119 deletions

View File

@ -508,6 +508,13 @@ if (REQUIRED_ICONS)
option(BUILTIN_ICON_THEMES_IN_LIBRARIES "specifies whether icon themes should also be built-in when building libraries"
OFF)
if (BUILTIN_ICON_THEMES AND (BUILTIN_ICON_THEMES_IN_LIBRARIES OR (NOT "${META_PROJECT_TYPE}" STREQUAL "library")))
set(BUILTIN_ICON_THEMES_QRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/icons/${META_PROJECT_NAME}_builtinicons.qrc")
list(APPEND RES_FILES "${BUILTIN_ICON_THEMES_QRC_FILE}")
if (EXISTS "${BUILTIN_ICON_THEMES_QRC_FILE}")
message(STATUS "Using existing \"${BUILTIN_ICON_THEMES_QRC_FILE}\" to bundle icon themes for ${META_PROJECT_NAME}. "
"Remove this file to force re-generation of the resource file.")
else ()
set(ICON_THEME_FILES)
set(ICON_SEARCH_PATHS ${BUILTIN_ICON_THEMES_SEARCH_PATH})
@ -630,12 +637,11 @@ if (REQUIRED_ICONS)
message(FATAL_ERROR "The specified icon theme \"${ICON_THEME}\" could not be found.")
endif ()
endforeach ()
set(BUILTIN_ICON_THEMES_QRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/icons/${META_PROJECT_NAME}_builtinicons.qrc")
list(REMOVE_DUPLICATES ICON_THEME_FILES)
string(CONCAT BUILTIN_ICON_THEMES_QRC_FILE_CONTENT "<RCC><qresource prefix=\"/icons\">" ${ICON_THEME_FILES}
"</qresource></RCC>")
file(WRITE "${BUILTIN_ICON_THEMES_QRC_FILE}" "${BUILTIN_ICON_THEMES_QRC_FILE_CONTENT}")
list(APPEND RES_FILES "${BUILTIN_ICON_THEMES_QRC_FILE}")
endif ()
endif ()
endif ()