From 23810aae3d8372d225e2ebe142267bc1fa11fde7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jul 2020 11:29:47 +0200 Subject: [PATCH] CMake: switch to autorcc from manual futzing --- CMakeModules/CalamaresAddLibrary.cmake | 9 ++++--- CMakeModules/CalamaresAutomoc.cmake | 36 ++++++++++++++++++++------ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CMakeModules/CalamaresAddLibrary.cmake b/CMakeModules/CalamaresAddLibrary.cmake index 88978e751..901791e30 100644 --- a/CMakeModules/CalamaresAddLibrary.cmake +++ b/CMakeModules/CalamaresAddLibrary.cmake @@ -62,10 +62,8 @@ function(calamares_add_library) include_directories(${CMAKE_CURRENT_BINARY_DIR}) # add resources from current dir - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_RESOURCES}") - qt5_add_resources(LIBRARY_RC_SOURCES "${LIBRARY_RESOURCES}") - list(APPEND LIBRARY_SOURCES ${LIBRARY_RC_SOURCES}) - unset(LIBRARY_RC_SOURCES) + if(LIBRARY_RESOURCES) + list(APPEND LIBRARY_SOURCES ${LIBRARY_RESOURCES}) endif() # add target @@ -81,6 +79,9 @@ function(calamares_add_library) if(LIBRARY_UI) calamares_autouic(${target} ${LIBRARY_UI}) endif() + if(LIBRARY_RESOURCES) + calamares_autorcc(${target} ${LIBRARY_RESOURCES}) + endif() if(LIBRARY_EXPORT_MACRO) set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO}) diff --git a/CMakeModules/CalamaresAutomoc.cmake b/CMakeModules/CalamaresAutomoc.cmake index 3de586ad2..c9a08a20d 100644 --- a/CMakeModules/CalamaresAutomoc.cmake +++ b/CMakeModules/CalamaresAutomoc.cmake @@ -18,17 +18,28 @@ # ### # -# Helper function for doing automoc on a target, and autoui on a .ui file. +# Helper function for doing automoc, autouic, autorcc on targets, +# and on the corresponding .ui or .rcc files. # -# Sets AUTOMOC TRUE for a target. +# calamares_automoc(target) +# Sets AUTOMOC TRUE for a target. # -# If the global variable CALAMARES_AUTOMOC_OPTIONS is set, uses that -# as well to set options passed to MOC. This can be used to add -# libcalamares/utils/moc-warnings.h file to the moc, which in turn -# reduces compiler warnings in generated MOC code. +# If the global variable CALAMARES_AUTOMOC_OPTIONS is set, uses that +# as well to set options passed to MOC. This can be used to add +# libcalamares/utils/moc-warnings.h file to the moc, which in turn +# reduces compiler warnings in generated MOC code. # -# If the global variable CALAMARES_AUTOUIC_OPTIONS is set, adds that -# to the options passed to uic. +# calamares_autouic(target [uifile ..]) +# Sets AUTOUIC TRUE for a target. +# +# If the global variable CALAMARES_AUTOUIC_OPTIONS is set, adds that +# to the options passed to uic for each of the named uifiles. +# +# calamares_autorcc(target [rcfile ..]) +# Sets AUTOUIC TRUE for a target. +# +# If the global variable CALAMARES_AUTORCC_OPTIONS is set, adds that +# to the options passed to rcc for each of the named rcfiles. function(calamares_automoc TARGET) set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE ) @@ -45,3 +56,12 @@ function(calamares_autouic TARGET) endforeach() endif() endfunction() + +function(calamares_autorcc TARGET) + set_target_properties( ${TARGET} PROPERTIES AUTORCC TRUE ) + if ( CALAMARES_AUTORCC_OPTIONS ) + foreach(S ${ARGN}) + set_property(SOURCE ${S} PROPERTY AUTORCC_OPTIONS "${CALAMARES_AUTORCC_OPTIONS}") + endforeach() + endif() +endfunction()