真的没有人有这个问题吗?
我试图进一步调试这个问题,所以我修改了 Qt5WidgetsMacros.cmake以输出它使用的每个变量。我的Qt5WidgetsMacros.cmake现在看起来像这样:
function(PRINT_LIST caption items)
set(i 1)
foreach (item ${items})
message(${caption} " " ${i} ": " ${item})
math(EXPR i "${i}+1")
endforeach()
endfunction()
# qt5_wrap_ui(outfiles inputfile ... )
function(QT5_WRAP_UI outfiles )
set(options)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
cmake_parse_arguments(_WRAP_UI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(ui_files ${_WRAP_UI_UNPARSED_ARGUMENTS})
set(ui_options ${_WRAP_UI_OPTIONS})
PRINT_LIST("Option" "${options}")
PRINT_LIST("oneValueArg" "${oneValueArgs}")
PRINT_LIST("multiValueArg" "${multiValueArgs}")
PRINT_LIST("ARGN" "${ARGN}")
PRINT_LIST("UI file" "${ui_files}")
PRINT_LIST("UI option" "${ui_options}")
foreach(it ${ui_files})
get_filename_component(outfile ${it} NAME_WE)
message("outfile: " ${outfile})
get_filename_component(infile ${it} ABSOLUTE)
message("infile: " ${infile})
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
message("outfile: " ${outfile})
message("Qt5Widgets_UIC_EXECUTABLE: " ${Qt5Widgets_UIC_EXECUTABLE})
add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
ARGS ${ui_options} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} VERBATIM)
list(APPEND ${outfiles} ${outfile})
endforeach()
PRINT_LIST("Outfile" "${outfiles}")
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
PRINT_LIST("Outfile" "${outfiles}")
endfunction()
我原始帖子中链接的CMakeLists.txt文件的输出- https://github.com/euler0/mini-cmake-qt/blob/master/CMakeLists.txt - 是:
multiValueArg 1: OPTIONS
ARGN 1: ./ui/mainwindow.ui
UI file 1: ./ui/mainwindow.ui
outfile: mainwindow
infile: C:/t/test/ui/mainwindow.ui
outfile: C:/t/test/out/ui_mainwindow.h
Qt5Widgets_UIC_EXECUTABLE: Qt5::uic
Outfile 1: UI_HEADERS
Outfile 1: UI_HEADERS
我会说看起来不错,但仍然:没有 ui_mainwindow.h
为了完整起见,这是我的 qt 设置:
QT_SYSROOT:
QT_INSTALL_PREFIX:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_INSTALL_ARCHDATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_INSTALL_DATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\
QT_INSTALL_DOCS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\doc
QT_INSTALL_HEADERS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\include
QT_INSTALL_LIBS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\lib
QT_INSTALL_LIBEXECS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\libexec
QT_INSTALL_BINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\bin
QT_INSTALL_TESTS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\tests
QT_INSTALL_PLUGINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\plugins
QT_INSTALL_IMPORTS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\imports
QT_INSTALL_QML:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\qml
QT_INSTALL_TRANSLATIONS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\examples
QT_INSTALL_DEMOS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\examples
QT_HOST_PREFIX:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_HOST_DATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_HOST_BINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\bin
QT_HOST_LIBS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\lib
QMAKE_SPEC:win32-msvc2012
QMAKE_XSPEC:win32-msvc2012
QMAKE_VERSION:3.0
QT_VERSION:5.1.0
有任何想法吗?