Skip to content

Commit

Permalink
streamline find_package calls to really find Qt6
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Oct 7, 2022
1 parent 0951665 commit e3670b7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 49 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)

set(QT_VERSION_MAJOR "6")
set(REQUIRED_QT_VERSION "5.15.0")

# CfAPI Shell Extensions
set( CFAPI_SHELL_EXTENSIONS_LIB_NAME CfApiShellExtensions )

Expand Down Expand Up @@ -126,11 +129,6 @@ if(APPLE AND BUILD_OWNCLOUD_OSX_BUNDLE)
add_definitions(-DBUILD_OWNCLOUD_OSX_BUNDLE)
endif()

find_package(Qt5 COMPONENTS Core)
if (NOT Qt5Core_FOUND)
find_package(Qt6 COMPONENTS Core)
endif()

option(QUICK_COMPILER "Use QtQuick compiler to improve performance" OFF)

# this option removes Http authentication, keychain, shibboleth etc and is intended for
Expand Down
9 changes: 3 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ endif()

include(ECMEnableSanitizers)

set(QT_VERSION_MAJOR "5")
set(REQUIRED_QT_VERSION "5.15.0")

find_package(Qt${QT_VERSION_MAJOR}Core ${REQUIRED_QT_VERSION} CONFIG QUIET)
set_package_properties(Qt${QT_VERSION_MAJOR}Core PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} Core component."
Expand Down Expand Up @@ -44,10 +41,10 @@ else()
)
endif()

find_package(Qt${QT_VERSION_MAJOR}WebEngine ${REQUIRED_QT_VERSION} CONFIG QUIET)
find_package(Qt${QT_VERSION_MAJOR}WebEngineCore ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(APPLE)
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngine PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngine component."
set_package_properties(Qt${QT_VERSION_MAJOR}WebEngineCore PROPERTIES
DESCRIPTION "Qt${QT_VERSION_MAJOR} WebEngineCore component."
TYPE RECOMMENDED
)
else()
Expand Down
25 changes: 5 additions & 20 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if(QUICK_COMPILER)
endif()

if (NOT TARGET Qt::GuiPrivate)
message(FATAL_ERROR "Could not find GuiPrivate component of Qt5. It might be shipped as a separate package, please check that.")
message(FATAL_ERROR "Could not find GuiPrivate component of Qt. It might be shipped as a separate package, please check that.")
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
Expand Down Expand Up @@ -292,7 +292,7 @@ IF( APPLE )
list(APPEND updater_DEPS ${SPARKLE_LIBRARY})

# Sparkle.framework is installed from here because macdeployqt's CopyFramework breaks on this bundle
# as its logic is tightly tailored around Qt5 frameworks
# as its logic is tightly tailored around Qt frameworks
install(DIRECTORY "${SPARKLE_LIBRARY}"
DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks" USE_SOURCE_PERMISSIONS)

Expand Down Expand Up @@ -332,12 +332,7 @@ else()
list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_win.cpp )
endif()

if (Qt6_FOUND)
find_package(Qt6 COMPONENTS LinguistTools)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS LinguistTools)
endif()
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} COMPONENTS LinguistTools)
if(Qt5LinguistTools_FOUND OR Qt6LinguistTools_FOUND)
qt_add_translation(client_I18N ${TRANSLATIONS})
endif()
Expand Down Expand Up @@ -640,23 +635,13 @@ endif()

## handle DBUS for Fdo notifications
if( UNIX AND NOT APPLE )
if (Qt6_FOUND)
find_package(Qt6 COMPONENTS DBus)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS DBus)
endif()
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} COMPONENTS DBus)
target_link_libraries(nextcloudCore PUBLIC Qt::DBus)
target_compile_definitions(nextcloudCore PUBLIC "USE_FDO_NOTIFICATIONS")
endif()

if (APPLE)
if (Qt6_FOUND)
find_package(Qt6 COMPONENTS MacExtras)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG MacExtras)
endif()
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} COMPONENTS MacExtras)
target_link_libraries(nextcloudCore PUBLIC Qt::MacExtras "-framework UserNotifications")
endif()

Expand Down
14 changes: 2 additions & 12 deletions src/libsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ IF (NOT APPLE)
)
ENDIF(NOT APPLE)

if (Qt6_FOUND)
find_package(Qt6 COMPONENTS REQUIRED WebSockets)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED WebSockets)
endif()
find_package(Qt6 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED WebSockets)

add_library(nextcloudsync SHARED ${libsync_SRCS})
add_library(Nextcloud::sync ALIAS nextcloudsync)
Expand All @@ -188,12 +183,7 @@ target_link_libraries(nextcloudsync
)

if (NOT TOKEN_AUTH_ONLY)
if (Qt6_FOUND)
find_package(Qt6 COMPONENTS REQUIRED Widgets Svg)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED Widgets Svg)
endif()
find_package(Qt6 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED Widgets Svg)
target_link_libraries(nextcloudsync PUBLIC Qt::Widgets Qt::Svg qt5keychain)
endif()

Expand Down
7 changes: 1 addition & 6 deletions test/nextcloud_add_test.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
if (Qt6_FOUND)
find_package(Qt6 COMPONENTS REQUIRED Core Test Xml Network Qml Quick)
else()
set(REQUIRED_QT_VERSION "5.15.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED Core Test Xml Network Qml Quick)
endif()
find_package(Qt6 ${REQUIRED_QT_VERSION} COMPONENTS REQUIRED Core Test Xml Network Qml Quick)

macro(nextcloud_add_test test_class)
set(CMAKE_AUTOMOC TRUE)
Expand Down

0 comments on commit e3670b7

Please sign in to comment.