1- cmake_minimum_required (VERSION 3.7.0 )
1+ cmake_minimum_required (VERSION 3.16 )
22
33project (otter-browser)
44
@@ -64,39 +64,19 @@ set(CMAKE_AUTOMOC ON)
6464set (CMAKE_CXX_EXTENSIONS OFF )
6565set (CMAKE_CXX_STANDARD 11)
6666set (CMAKE_CXX_STANDARD_REQUIRED ON )
67- set (MIN_VERSION_QT5 5.15)
68- set (MIN_VERSION_QT6 6.2)
69- set (MIN_VERSION_QTWEBKIT 5.212)
7067
7168include (FeatureSummary)
7269include (GNUInstallDirs)
7370
7471option (ALLOW_WITHOUT_WEB_BACKENDS "Allow to build without any web backends (build testing only)" OFF )
75- option (ENABLE_QT6 "Build using Qt 6" ON )
76-
77- if (ENABLE_QT6)
78- if (NOT ALLOW_WITHOUT_WEB_BACKENDS)
79- option (ENABLE_QTWEBENGINE "Enable QtWebEngine backend (requires QtWebEngine version ${MIN_VERSION_QT6} or higher)" ON )
80- endif ()
81- find_package (Qt6 ${MIN_VERSION_QT6} REQUIRED COMPONENTS Core Core5Compat Gui Multimedia Network PrintSupport Qml Svg WebEngineWidgets Widgets)
82- else ()
83- if (NOT ALLOW_WITHOUT_WEB_BACKENDS)
84- option (ENABLE_QTWEBENGINE "Enable QtWebEngine backend (requires QtWebEngine ${MIN_VERSION_QT5} )" ON )
85- option (ENABLE_QTWEBKIT "Enable QtWebKit backend (requires QtWebKit ${MIN_VERSION_QTWEBKIT} )" ON )
86- endif ()
87- find_package (Qt5 ${MIN_VERSION_QT5} REQUIRED COMPONENTS Core Gui Multimedia Network PrintSupport Qml Svg Widgets)
88- find_package (Qt5WebKitWidgets ${MIN_VERSION_QTWEBKIT} QUIET )
89- endif ()
90-
9172option (ENABLE_CRASH_REPORTS "Enable built-in crash reporting (official builds only)" OFF )
9273option (ENABLE_DBUS "Enable D-Bus based integration for notifications (only freedesktop.org compatible platforms)" ON )
93- option (ENABLE_SPELLCHECK "Enable Hunspell based spell checking" ON )
94-
95- if (ENABLE_SPELLCHECK)
96- find_package (Hunspell 1.5.0 REQUIRED)
97- endif ()
74+ option (ENABLE_SPELLCHECK "Enable Hunspell based spell checking" OFF )
75+ option (ENABLE_QT6 "Build using Qt 6" ON )
76+ option (ENABLE_QTWEBENGINE "Enable QtWebEngine backend (requires Qt WebEngine version ${QT_MINIMUM_VERSION} or higher)" ON )
77+ option (ENABLE_QTWEBKIT "Enable QtWebKit backend (requires QtWebKit ${QT_MINIMUM_VERSION_WEBKIT} )" OFF )
9878
99- set_package_properties(Hunspell PROPERTIES URL "https://hunspell.github.io/" DESCRIPTION "Generic spell checking support" TYPE OPTIONAL )
79+ include (cmake/Dependencies.cmake )
10080
10181set (OTTER_SOURCES
10282 src/main.cpp
@@ -308,7 +288,7 @@ set(OTTER_SOURCES
308288 3rdparty/qrcodegen/qrcodegen.cpp
309289)
310290
311- set (OTTER_UI_SOURCES
291+ qt_wrap_ui (OTTER_UI
312292 src/ui/AcceptCookieDialog.ui
313293 src/ui/ActionParametersDialog.ui
314294 src/ui/AuthenticationDialog.ui
@@ -382,41 +362,17 @@ set(OTTER_UI_SOURCES
382362 src/modules/windows/windows/WindowsContentsWidget.ui
383363)
384364
385- if (ENABLE_QT6)
386- qt6_add_resources(OTTER_RESOURCES
387- resources/resources.qrc
388- )
389-
390- qt6_wrap_ui(OTTER_UI
391- ${OTTER_UI_SOURCES}
392- )
393- else ()
394- qt5_add_resources(OTTER_RESOURCES
395- resources/resources.qrc
396- )
397-
398- qt5_wrap_ui(OTTER_UI
399- ${OTTER_UI_SOURCES}
400- )
401- endif ()
365+ qt_add_resources(OTTER_RESOURCES
366+ resources/resources.qrc
367+ )
402368
403- if (ENABLE_QT6)
404- foreach (_current_dir ${Qt6Widgets_PRIVATE_INCLUDE_DIRS} )
405- if (EXISTS "${_current_dir} /private/qpixmapfilter_p.h" )
406- add_definitions (-DOTTER_ENABLE_STARTPAGEBLUR)
407- include_directories (${Qt6Widgets_PRIVATE_INCLUDE_DIRS} )
408- break ()
409- endif ()
410- endforeach ()
411- else ()
412- foreach (_dir ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} )
413- if (EXISTS "${_dir} /private/qpixmapfilter_p.h" )
414- add_definitions (-DOTTER_ENABLE_STARTPAGEBLUR)
415- include_directories (${Qt5Widgets_PRIVATE_INCLUDE_DIRS} )
416- break ()
417- endif ()
418- endforeach ()
419- endif ()
369+ foreach (_dir ${QT_MAJOR_VERSION} Widgets_PRIVATE_INCLUDE_DIRS})
370+ if (EXISTS "${_dir} /private/qpixmapfilter_p.h" )
371+ add_definitions (-DOTTER_ENABLE_STARTPAGEBLUR)
372+ include_directories (${QT_MAJOR_VERSION} Widgets_PRIVATE_INCLUDE_DIRS})
373+ break ()
374+ endif ()
375+ endforeach ()
420376
421377if (ENABLE_QTWEBENGINE)
422378 include (src/modules/backends/web/qtwebengine/CMakeLists.txt)
@@ -489,10 +445,6 @@ endif ()
489445if (WIN32 )
490446 add_definitions (-DUNICODE -D_UNICODE)
491447
492- if (NOT ENABLE_QT6)
493- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS WinExtras)
494- endif ()
495-
496448 if (MSVC )
497449 set (CMAKE_PREFIX_PATH $ENV{QTDIR} )
498450 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP" )
@@ -513,10 +465,6 @@ if (WIN32)
513465 src/modules/platforms/windows/WindowsPlatformStyle.cpp
514466 )
515467elseif (APPLE )
516- if (NOT ENABLE_QT6)
517- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS MacExtras)
518- endif ()
519-
520468 set (CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
521469 set (MACOSX_BUNDLE_BUNDLE_NAME "Otter Browser" )
522470 set (MACOSX_BUNDLE_BUNDLE_VERSION ${MAJOR_VERSION} .${MINOR_VERSION} .${PATCH_VERSION} )
@@ -534,16 +482,8 @@ elseif (APPLE)
534482
535483 set_source_files_properties (resources/icons/otter-browser.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
536484elseif (UNIX )
537- if (ENABLE_QT6)
538- find_package (Qt6 ${MIN_VERSION_QT6} QUIET COMPONENTS DBus)
539- if (TARGET Qt6::DBus AND ENABLE_DBUS)
540- add_definitions (-DOTTER_ENABLE_DBUS)
541- endif ()
542- else ()
543- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS DBus)
544- if (TARGET Qt5::DBus AND ENABLE_DBUS)
545- add_definitions (-DOTTER_ENABLE_DBUS)
546- endif ()
485+ if (TARGET ${QT_MAJOR_VERSION} ::DBus AND ENABLE_DBUS)
486+ add_definitions (-DOTTER_ENABLE_DBUS)
547487 endif ()
548488
549489 set (OTTER_SOURCES
@@ -616,27 +556,13 @@ foreach (_library ${OTTER_LINK_LIBRARIES})
616556 target_link_libraries (otter-browser ${_library} )
617557endforeach ()
618558
619- if (ENABLE_QT6)
620- if (TARGET Qt6::WebEngineWidgets AND ENABLE_QTWEBENGINE)
621- target_link_libraries (otter-browser Qt6::WebEngineCore Qt6::WebEngineWidgets)
622- endif ()
623- else ()
624- if (TARGET Qt5::WebEngineWidgets AND ENABLE_QTWEBENGINE)
625- target_link_libraries (otter-browser Qt5::WebEngineCore Qt5::WebEngineWidgets)
626- endif ()
627- endif ()
628-
629- if (TARGET Qt5::WebKitWidgets AND ENABLE_QTWEBKIT)
630- target_link_libraries (otter-browser Qt5::WebKit Qt5::WebKitWidgets)
631- endif ()
632-
633559if (TARGET Hunspell::Hunspell AND ENABLE_SPELLCHECK)
634560 target_link_libraries (otter-browser Hunspell::Hunspell)
635561endif ()
636562
637563if (WIN32 )
638564 if (NOT ENABLE_QT6)
639- target_link_libraries (Qt5 ::WinExtras)
565+ target_link_libraries (${QT_MAJOR_VERSION} ::WinExtras)
640566 endif ()
641567 target_link_libraries (otter-browser ole32 shell32 advapi32 user32)
642568elseif (APPLE )
@@ -646,29 +572,33 @@ elseif (APPLE)
646572 set_target_properties (otter-browser PROPERTIES OUTPUT_NAME "Otter Browser" )
647573
648574 if (NOT ENABLE_QT6)
649- target_link_libraries (otter-browser Qt5 ::MacExtras ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
575+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::MacExtras ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
650576 endif ()
651577 target_link_libraries (otter-browser ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
652578elseif (UNIX )
653- if (ENABLE_QT6)
654- if (TARGET Qt6::DBus AND ENABLE_DBUS)
655- target_link_libraries (otter-browser Qt6::DBus)
656- endif ()
657- else ()
658- if (TARGET Qt5::DBus AND ENABLE_DBUS)
659- target_link_libraries (otter-browser Qt5::DBus)
660- endif ()
579+ if (TARGET ${QT_MAJOR_VERSION} ::DBus AND ENABLE_DBUS)
580+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::DBus)
661581 endif ()
662582
663583 if (ENABLE_CRASH_REPORTS)
664584 target_link_libraries (otter-browser -lpthread)
665585 endif ()
666586endif ()
667587
588+ target_link_libraries (
589+ otter-browser
590+ ${QT_MAJOR_VERSION} ::Core
591+ ${QT_MAJOR_VERSION} ::Gui
592+ ${QT_MAJOR_VERSION} ::Multimedia
593+ ${QT_MAJOR_VERSION} ::Network
594+ ${QT_MAJOR_VERSION} ::PrintSupport
595+ ${QT_MAJOR_VERSION} ::Qml
596+ ${QT_MAJOR_VERSION} ::Svg
597+ ${QT_MAJOR_VERSION} ::Widgets
598+ )
599+
668600if (ENABLE_QT6)
669- target_link_libraries (otter-browser Qt6::Core Qt6::Core5Compat Qt6::Gui Qt6::Multimedia Qt6::Network Qt6::PrintSupport Qt6::Qml Qt6::Svg Qt6::Widgets)
670- else ()
671- target_link_libraries (otter-browser Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::PrintSupport Qt5::Qml Qt5::Svg Qt5::Widgets)
601+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::Core5Compat)
672602endif ()
673603
674604set (XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} /share/applications CACHE FILEPATH "Install path for .desktop files" )
0 commit comments