diff --git a/cmake/modules/QtHelper.cmake b/cmake/modules/QtHelper.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/QtHelper.cmake @@ -0,0 +1,37 @@ +# Copyright (c) 2019 The Bitcoin developers + +function(qt5_wrap_ui_to_destination outfiles) + set(options) + set(oneValueArgs DESTINATION) + set(multiValueArgs OPTIONS) + + cmake_parse_arguments(_WRAP_UI_TO_DEST + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) + + set(ui_outdir ${_WRAP_UI_TO_DEST_DESTINATION}) + set(ui_files ${_WRAP_UI_TO_DEST_UNPARSED_ARGUMENTS}) + set(ui_options ${_WRAP_UI_TO_DEST_OPTIONS}) + + if(NOT ui_outdir) + set(ui_outdir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + foreach(it ${ui_files}) + get_filename_component(outfile ${it} NAME_WE) + get_filename_component(infile ${it} ABSOLUTE) + set(outfile ${ui_outdir}/ui_${outfile}.h) + add_custom_command(OUTPUT ${outfile} + COMMAND ${Qt5Widgets_UIC_EXECUTABLE} + ARGS ${ui_options} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile} VERBATIM) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOUIC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) + list(APPEND ${outfiles} ${outfile}) + endforeach() + set(${outfiles} ${${outfiles}} PARENT_SCOPE) +endfunction() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -78,7 +78,9 @@ ) # UI elements -qt5_wrap_ui(UI_GENERATED_HEADERS +include(QtHelper) +qt5_wrap_ui_to_destination(UI_GENERATED_HEADERS + DESTINATION forms forms/addressbookpage.ui forms/askpassphrasedialog.ui forms/coincontroldialog.ui