CMake: Apply AUTO{MOC,UIC,RCC} more selectively.

Set CMAKE_AUTO{MOC,UIC,RCC} if we're running CMake 3.20.0 or 3.20.1 in
order to work around CMake issue 22085, otherwise set the AUTOMOC,
AUTOUIC, and AUTORCC properties for the qtui target. The latter is
preferred since it keeps us from running Qt's meta-object, user
interface, or resource compilers on code outside of ui/qt. Ping #17314.
This commit is contained in:
Gerald Combs 2021-05-06 15:48:02 -07:00
parent 0c3db4c9fd
commit 826e03c9f4
2 changed files with 11 additions and 7 deletions

View File

@ -1151,7 +1151,8 @@ ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
# Build the Qt GUI?
if(BUILD_wireshark)
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
if(CMAKE_VERSION VERSION_GREATER "3.19.999" AND CMAKE_VERSION VERSION_LESS "3.20.2")
# https://gitlab.kitware.com/cmake/cmake/-/issues/22085
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

View File

@ -632,12 +632,6 @@ set(WIRESHARK_QT_QRC
${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc
)
if(CMAKE_VERSION VERSION_LESS "3.10.0")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
endif()
if(NOT Qt5Widgets_VERSION VERSION_LESS "5.9")
# Drop the file modification time of source files from generated files
# to help with reproducible builds. We do not use QFileInfo.lastModified
@ -739,6 +733,15 @@ set_target_properties(qtui PROPERTIES
# Ensure .qm files are generated before autogenerating i18n.qrc
AUTOGEN_TARGET_DEPENDS "${WIRESHARK_QT_QM}"
)
if (NOT CMAKE_AUTOMOC) # Set in the top-level CMakeLists.txt if we're using CMake 3.20.0 or .1
set_target_properties(qtui PROPERTIES
AUTOMOC ON
AUTOUIC ON
AUTORCC ON
)
endif()
if(MSVC)
set_target_properties(qtui PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
endif()