From ba7ee445c61b9833c318b7cdeaada88bf8ae3e82 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 13 May 2019 14:52:26 +0200 Subject: [PATCH] CMake: switch to using autouic on plugins - Use autouic so that we can also pass in --include to add a code-warning-suppression to the generated code, just like we can do with moc. --- CMakeLists.txt | 1 + CMakeModules/CalamaresAddLibrary.cmake | 10 ++++------ CMakeModules/CalamaresAutomoc.cmake | 13 ++++++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 050191c1f..843e8bc69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" ) + set( CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h ) else() set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" ) diff --git a/CMakeModules/CalamaresAddLibrary.cmake b/CMakeModules/CalamaresAddLibrary.cmake index e731e2b15..0829d919e 100644 --- a/CMakeModules/CalamaresAddLibrary.cmake +++ b/CMakeModules/CalamaresAddLibrary.cmake @@ -61,11 +61,6 @@ function(calamares_add_library) include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(LIBRARY_UI) - qt5_wrap_ui(LIBRARY_UI_SOURCES ${LIBRARY_UI}) - list(APPEND LIBRARY_SOURCES ${LIBRARY_UI_SOURCES}) - endif() - # add resources from current dir if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_RESOURCES}") qt5_add_resources(LIBRARY_RC_SOURCES "${LIBRARY_RESOURCES}") @@ -83,7 +78,10 @@ function(calamares_add_library) endif() calamares_automoc(${target}) - + if(LIBRARY_UI) + calamares_autouic(${target} ${LIBRARY_UI}) + endif() + if(LIBRARY_EXPORT_MACRO) set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO}) endif() diff --git a/CMakeModules/CalamaresAutomoc.cmake b/CMakeModules/CalamaresAutomoc.cmake index 0ca5cd89a..f8aa7faef 100644 --- a/CMakeModules/CalamaresAutomoc.cmake +++ b/CMakeModules/CalamaresAutomoc.cmake @@ -18,7 +18,7 @@ # ### # -# Helper function for doing automoc on a target. +# Helper function for doing automoc on a target, and autoui on a .ui file. # # Sets AUTOMOC TRUE for a target. # @@ -27,6 +27,8 @@ # 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. function(calamares_automoc TARGET) set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE ) @@ -34,3 +36,12 @@ function(calamares_automoc TARGET) set_target_properties( ${TARGET} PROPERTIES AUTOMOC_MOC_OPTIONS "${CALAMARES_AUTOMOC_OPTIONS}" ) endif() endfunction() + +function(calamares_autouic TARGET) + set_target_properties( ${TARGET} PROPERTIES AUTOUIC TRUE ) + if ( CALAMARES_AUTOUIC_OPTIONS ) + foreach(S ${ARGN}) + set_property(SOURCE ${S} PROPERTY AUTOUIC_OPTIONS "${CALAMARES_AUTOUIC_OPTIONS}") + endforeach() + endif() +endfunction()