1
- cmake_minimum_required (VERSION 3.7.0 )
1
+ cmake_minimum_required (VERSION 3.16 )
2
2
3
3
project (otter-browser )
4
4
@@ -64,40 +64,35 @@ set(CMAKE_AUTOMOC ON)
64
64
set (CMAKE_CXX_EXTENSIONS OFF )
65
65
set (CMAKE_CXX_STANDARD 11 )
66
66
set (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 )
70
67
71
68
include (FeatureSummary )
72
69
include (GNUInstallDirs )
73
70
74
71
option (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 )
75
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 )
76
78
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 )
82
83
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 )
84
+ set (QT_MAJOR_VERSION Qt6 )
85
+ set (QT_MINIMUM_VERSION 6.2 )
86
+ find_package (${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core5Compat )
89
87
endif ()
90
88
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 )
94
90
95
91
if (ENABLE_SPELLCHECK )
96
92
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 )
97
94
endif ()
98
95
99
- set_package_properties (Hunspell PROPERTIES URL "https://hunspell.github.io/" DESCRIPTION "Generic spell checking support" TYPE OPTIONAL )
100
-
101
96
set (OTTER_SOURCES
102
97
src/main.cpp
103
98
src/core/ActionExecutor.cpp
@@ -308,7 +303,7 @@ set(OTTER_SOURCES
308
303
3rdparty/qrcodegen/qrcodegen.cpp
309
304
)
310
305
311
- set ( OTTER_UI_SOURCES
306
+ qt_wrap_ui ( OTTER_UI
312
307
src/ui/AcceptCookieDialog.ui
313
308
src/ui/ActionParametersDialog.ui
314
309
src/ui/AuthenticationDialog.ui
@@ -382,41 +377,17 @@ set(OTTER_UI_SOURCES
382
377
src/modules/windows/windows/WindowsContentsWidget.ui
383
378
)
384
379
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
+ )
402
383
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 ()
420
391
421
392
if (ENABLE_QTWEBENGINE )
422
393
include (src/modules/backends/web/qtwebengine/CMakeLists.txt )
@@ -489,10 +460,6 @@ endif ()
489
460
if (WIN32 )
490
461
add_definitions (-DUNICODE -D_UNICODE )
491
462
492
- if (NOT ENABLE_QT6 )
493
- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS WinExtras )
494
- endif ()
495
-
496
463
if (MSVC )
497
464
set (CMAKE_PREFIX_PATH $ENV{QTDIR} )
498
465
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP" )
@@ -513,10 +480,6 @@ if (WIN32)
513
480
src/modules/platforms/windows/WindowsPlatformStyle.cpp
514
481
)
515
482
elseif (APPLE )
516
- if (NOT ENABLE_QT6 )
517
- find_package (Qt5 ${MIN_VERSION_QT5} QUIET COMPONENTS MacExtras )
518
- endif ()
519
-
520
483
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.13 )
521
484
set (MACOSX_BUNDLE_BUNDLE_NAME "Otter Browser" )
522
485
set (MACOSX_BUNDLE_BUNDLE_VERSION ${MAJOR_VERSION} .${MINOR_VERSION}.${PATCH_VERSION} )
@@ -534,16 +497,8 @@ elseif (APPLE)
534
497
535
498
set_source_files_properties (resources/icons/otter-browser.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
536
499
elseif (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 )
547
502
endif ()
548
503
549
504
set (OTTER_SOURCES
@@ -616,27 +571,13 @@ foreach (_library ${OTTER_LINK_LIBRARIES})
616
571
target_link_libraries (otter-browser ${_library} )
617
572
endforeach ()
618
573
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
-
633
574
if (TARGET Hunspell::Hunspell AND ENABLE_SPELLCHECK )
634
575
target_link_libraries (otter-browser Hunspell::Hunspell )
635
576
endif ()
636
577
637
578
if (WIN32 )
638
579
if (NOT ENABLE_QT6 )
639
- target_link_libraries (Qt5 ::WinExtras )
580
+ target_link_libraries (${QT_MAJOR_VERSION} ::WinExtras )
640
581
endif ()
641
582
target_link_libraries (otter-browser ole32 shell32 advapi32 user32 )
642
583
elseif (APPLE )
@@ -646,29 +587,33 @@ elseif (APPLE)
646
587
set_target_properties (otter-browser PROPERTIES OUTPUT_NAME "Otter Browser" )
647
588
648
589
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} )
650
591
endif ()
651
592
target_link_libraries (otter-browser ${FRAMEWORK_Cocoa} ${FRAMEWORK_Foundation} )
652
593
elseif (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 )
661
596
endif ()
662
597
663
598
if (ENABLE_CRASH_REPORTS )
664
599
target_link_libraries (otter-browser -lpthread )
665
600
endif ()
666
601
endif ()
667
602
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
+
668
615
if (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 )
672
617
endif ()
673
618
674
619
set (XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} /share/applications CACHE FILEPATH "Install path for .desktop files" )
0 commit comments