From 34ebe520a1736e0b8e68d978e5d43874c67221fa Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Thu, 17 Dec 2015 18:10:43 +0000 Subject: [PATCH] Move DBus/COM checks up to where Qt is being searched for --- CMakeLists.txt | 26 ++++++++++++++++++++++++-- qt/CMakeLists.txt | 25 +++++-------------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed4a06c76..d9eb9ace0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,6 +222,9 @@ if(ENABLE_QT) endif() set(QT_TARGETS) + set(ENABLE_QT_COM_INTEROP OFF) + set(ENABLE_QT_DBUS_INTEROP OFF) + if(USE_QT5) set(QT5_REQUIRED_MODULES Core Gui Widgets Network LinguistTools) set(QT5_OPTIONAL_MODULES DBus AxContainer AxServer) @@ -243,6 +246,12 @@ if(ENABLE_QT) list(APPEND QT_TARGETS Qt5::${M}) endif() endforeach() + if(Qt5AxContainer_FOUND AND Qt5AxServer_FOUND) + set(ENABLE_QT_COM_INTEROP ON) + endif() + if(Qt5DBus_FOUND) + set(ENABLE_QT_DBUS_INTEROP ON) + endif() endif() else() set(QT4_REQUIRED_MODULES QtCore QtGui QtNetwork) @@ -264,13 +273,26 @@ if(ENABLE_QT) list(APPEND QT_TARGETS Qt4::${M}) endif() endforeach() + if(QT_QAXCONTAINER_FOUND AND QT_QAXSERVER_FOUND) + set(ENABLE_QT_COM_INTEROP ON) + endif() + if(QT_QTDBUS_FOUND) + set(ENABLE_QT_DBUS_INTEROP ON) + endif() + endif() + endif() + + if(ENABLE_QT_COM_INTEROP) + find_program(MIDL_EXECUTABLE midl) + if(NOT MIDL_EXECUTABLE) + set(ENABLE_QT_COM_INTEROP OFF) endif() endif() set(QT_FOUND ON) - if(NOT QT_TARGETS) + if(NOT QT_TARGETS OR NOT (ENABLE_QT_COM_INTEROP OR ENABLE_QT_DBUS_INTEROP)) if(QT_IS_REQUIRED) - message(FATAL_ERROR "Unable to find Qt libraries.") + message(FATAL_ERROR "Unable to find required Qt libraries.") endif() set(QT_FOUND OFF) endif() diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 56c4a3751..c8af79d3f 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -22,20 +22,6 @@ else() endmacro() endif() -set(ENABLE_COM_INTEROP OFF) -if(MSVC AND ((Qt5AxContainer_FOUND AND Qt5AxServer_FOUND) OR (QT_QAXCONTAINER_FOUND AND QT_QAXSERVER_FOUND))) - set(ENABLE_COM_INTEROP ON) -endif() - -set(ENABLE_DBUS_INTEROP OFF) -if(Qt5DBus_FOUND OR QT_QTDBUS_FOUND) - set(ENABLE_DBUS_INTEROP ON) -endif() - -if(NOT ENABLE_COM_INTEROP AND NOT ENABLE_DBUS_INTEROP) - message(FATAL_ERROR "Neither D-Bus nor COM interop is possible") -endif() - set(${PROJECT_NAME}_SOURCES AboutDialog.cc AddData.cc @@ -85,10 +71,10 @@ set(${PROJECT_NAME}_SOURCES WatchDir.cc ) -if (NOT ENABLE_COM_INTEROP) +if (NOT ENABLE_QT_COM_INTEROP) set_source_files_properties(ComInteropHelper.cc PROPERTIES HEADER_FILE_ONLY ON) endif() -if (NOT ENABLE_DBUS_INTEROP) +if (NOT ENABLE_QT_DBUS_INTEROP) set_source_files_properties(DBusInteropHelper.cc PROPERTIES HEADER_FILE_ONLY ON) endif() @@ -213,8 +199,7 @@ tr_win32_app_info(${PROJECT_NAME}_WIN32_RC_FILE "transmission-qt.exe" "qtr.ico") -if(ENABLE_COM_INTEROP) - find_program(MIDL_EXECUTABLE midl) +if(ENABLE_QT_COM_INTEROP) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/transmission-qt.tlb @@ -248,8 +233,8 @@ target_link_libraries(${TR_NAME}-qt target_compile_definitions(${TR_NAME}-qt PRIVATE "TRANSLATIONS_DIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${TR_NAME}/translations\"" QT_NO_CAST_FROM_ASCII - $<$:ENABLE_COM_INTEROP> - $<$:ENABLE_DBUS_INTEROP>) + $<$:ENABLE_COM_INTEROP> + $<$:ENABLE_DBUS_INTEROP>) if(MSVC) tr_append_target_property(${TR_NAME}-qt LINK_FLAGS "/ENTRY:mainCRTStartup") -- 2.40.0