1- cmake_minimum_required (VERSION 3.7.0 )
1+ cmake_minimum_required (VERSION 3.16 )
22
33project (otter-browser)
44
@@ -64,40 +64,35 @@ 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 )
72+ option (ENABLE_CRASH_REPORTS "Enable built-in crash reporting (official builds only)" OFF )
73+ option (ENABLE_DBUS "Enable D-Bus based integration for notifications (only freedesktop.org compatible platforms)" ON )
74+ option (ENABLE_SPELLCHECK "Enable Hunspell based spell checking" OFF )
7575option (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 )
7678
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)
79+ if (NOT ENABLE_QT6)
80+ set (QT_MAJOR_VERSION Qt5)
81+ set (QT_MINIMUM_VERSION 5.15)
82+ set (QT_MINIMUM_VERSION_WEBKIT 5.212)
8283else ()
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 )
84+ set (QT_MAJOR_VERSION Qt6)
85+ set (QT_MINIMUM_VERSION 6.2)
86+ find_package (${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core5Compat)
8987endif ()
9088
91- option (ENABLE_CRASH_REPORTS "Enable built-in crash reporting (official builds only)" OFF )
92- option (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 )
89+ find_package (${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core Gui Multimedia Network PrintSupport Qml Svg Widgets)
9490
9591if (ENABLE_SPELLCHECK)
9692 find_package (Hunspell 1.5.0 REQUIRED)
93+ set_package_properties(Hunspell PROPERTIES URL "https://hunspell.github.io/" DESCRIPTION "Generic spell checking support" TYPE OPTIONAL )
9794endif ()
9895
99- set_package_properties(Hunspell PROPERTIES URL "https://hunspell.github.io/" DESCRIPTION "Generic spell checking support" TYPE OPTIONAL )
100-
10196set (OTTER_SOURCES
10297 src/main.cpp
10398 src/core/ActionExecutor.cpp
@@ -308,7 +303,7 @@ set(OTTER_SOURCES
308303 3rdparty/qrcodegen/qrcodegen.cpp
309304)
310305
311- set (OTTER_UI_SOURCES
306+ qt_wrap_ui (OTTER_UI
312307 src/ui/AcceptCookieDialog.ui
313308 src/ui/ActionParametersDialog.ui
314309 src/ui/AuthenticationDialog.ui
@@ -382,41 +377,17 @@ set(OTTER_UI_SOURCES
382377 src/modules/windows/windows/WindowsContentsWidget.ui
383378)
384379
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 ()
380+ qt_add_resources(OTTER_RESOURCES
381+ resources/resources.qrc
382+ )
402383
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 ()
384+ foreach (_dir ${QT_MAJOR_VERSION} Widgets_PRIVATE_INCLUDE_DIRS})
385+ if (EXISTS "${_dir} /private/qpixmapfilter_p.h" )
386+ add_definitions (-DOTTER_ENABLE_STARTPAGEBLUR)
387+ include_directories (${QT_MAJOR_VERSION} Widgets_PRIVATE_INCLUDE_DIRS})
388+ break ()
389+ endif ()
390+ endforeach ()
420391
421392if (ENABLE_QTWEBENGINE)
422393 include (src/modules/backends/web/qtwebengine/CMakeLists.txt)
@@ -489,10 +460,6 @@ endif ()
489460if (WIN32 )
490461 add_definitions (-DUNICODE -D_UNICODE)
491462
492- if (NOT ENABLE_QT6)
493- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS WinExtras)
494- endif ()
495-
496463 if (MSVC )
497464 set (CMAKE_PREFIX_PATH $ENV{QTDIR} )
498465 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP" )
@@ -513,10 +480,6 @@ if (WIN32)
513480 src/modules/platforms/windows/WindowsPlatformStyle.cpp
514481 )
515482elseif (APPLE )
516- if (NOT ENABLE_QT6)
517- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS MacExtras)
518- endif ()
519-
520483 set (CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
521484 set (MACOSX_BUNDLE_BUNDLE_NAME "Otter Browser" )
522485 set (MACOSX_BUNDLE_BUNDLE_VERSION ${MAJOR_VERSION} .${MINOR_VERSION} .${PATCH_VERSION} )
@@ -534,16 +497,8 @@ elseif (APPLE)
534497
535498 set_source_files_properties (resources/icons/otter-browser.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
536499elseif (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 ()
500+ if (TARGET ${QT_MAJOR_VERSION} ::DBus AND ENABLE_DBUS)
501+ add_definitions (-DOTTER_ENABLE_DBUS)
547502 endif ()
548503
549504 set (OTTER_SOURCES
@@ -616,27 +571,13 @@ foreach (_library ${OTTER_LINK_LIBRARIES})
616571 target_link_libraries (otter-browser ${_library} )
617572endforeach ()
618573
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-
633574if (TARGET Hunspell::Hunspell AND ENABLE_SPELLCHECK)
634575 target_link_libraries (otter-browser Hunspell::Hunspell)
635576endif ()
636577
637578if (WIN32 )
638579 if (NOT ENABLE_QT6)
639- target_link_libraries (Qt5 ::WinExtras)
580+ target_link_libraries (${QT_MAJOR_VERSION} ::WinExtras)
640581 endif ()
641582 target_link_libraries (otter-browser ole32 shell32 advapi32 user32)
642583elseif (APPLE )
@@ -646,29 +587,33 @@ elseif (APPLE)
646587 set_target_properties (otter-browser PROPERTIES OUTPUT_NAME "Otter Browser" )
647588
648589 if (NOT ENABLE_QT6)
649- target_link_libraries (otter-browser Qt5 ::MacExtras ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
590+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::MacExtras ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
650591 endif ()
651592 target_link_libraries (otter-browser ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
652593elseif (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 ()
594+ if (TARGET ${QT_MAJOR_VERSION} ::DBus AND ENABLE_DBUS)
595+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::DBus)
661596 endif ()
662597
663598 if (ENABLE_CRASH_REPORTS)
664599 target_link_libraries (otter-browser -lpthread)
665600 endif ()
666601endif ()
667602
603+ target_link_libraries (
604+ otter-browser
605+ ${QT_MAJOR_VERSION} ::Core
606+ ${QT_MAJOR_VERSION} ::Gui
607+ ${QT_MAJOR_VERSION} ::Multimedia
608+ ${QT_MAJOR_VERSION} ::Network
609+ ${QT_MAJOR_VERSION} ::PrintSupport
610+ ${QT_MAJOR_VERSION} ::Qml
611+ ${QT_MAJOR_VERSION} ::Svg
612+ ${QT_MAJOR_VERSION} ::Widgets
613+ )
614+
668615if (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)
616+ target_link_libraries (otter-browser ${QT_MAJOR_VERSION} ::Core5Compat)
672617endif ()
673618
674619set (XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} /share/applications CACHE FILEPATH "Install path for .desktop files" )
0 commit comments