aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: a0e6b9d27b7dbc435c355e777692092472f6d287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.1.0)
project(smolbote)

# Options
option(CompilerWarnings "Compiler warnings" ON)
option(QtDeprecatedWarnings "Qt deprecated warnings" ON)
option(UseLibCpp "Use libc++ over stdlibc++ (requires clang)" OFF)
option(CLikeConfig "Use a C-like style for the config" ON)

# Libraries
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qt5WebEngineWidgets REQUIRED)
find_package(libconfig++ REQUIRED)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Global C++ settings
set(CMAKE_CXX_STANDARD 17)

if(CompilerWarnings)
    if(CMAKE_COMPILER_IS_GNUCC)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
    endif()
    if(MSVC)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
    endif()
endif(CompilerWarnings)

if(QtDeprecatedWarnings)
    add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050900)
endif(QtDeprecatedWarnings)

# link to libc++
if (UseLibCpp)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
endif (UseLibCpp)

add_subdirectory(lib/settings)
add_subdirectory(lib/bookmarks)
add_subdirectory(lib/downloads)
add_subdirectory(lib/navigation)

add_subdirectory(plugins/ProfileEditor)

# configure a header file to pass version information
# if you don't have git, or are building this off the source tarball, define versions in version.h.in
execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion  OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hg identify --id                     WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit   OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hg identify --num                    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND hg identify --branch                 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBranch   OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(src/version.h.in "${PROJECT_BINARY_DIR}/version.h")

set(SourceCode
        # main
        "src/main.cpp"
        "src/singleapplication.cpp"
        "src/singleapplication.h"
        "src/browser.cpp"
        "src/browser.h"

        # main window
        # todo: move all to src/mainwindow
        src/mainwindow/mainwindow.cpp
        src/mainwindow/mainwindow.h
        src/mainwindow/mainwindow.ui
        src/mainwindow/widgets/loadingbar.cpp
        src/mainwindow/widgets/loadingbar.h
        "src/widgets/mainwindowmenubar.cpp"
        "src/widgets/mainwindowmenubar.h"
        "src/widgets/mainwindowtabbar.cpp"
        "src/widgets/mainwindowtabbar.h"
        # todo: move to src/mainwindow
        "src/forms/searchform.cpp"
        "src/forms/searchform.h"
        "src/forms/searchform.ui"
        "data/resources.qrc"

        # webengine
        src/webengine/cookieinterceptor.cpp
        src/webengine/cookieinterceptor.h
        "src/webengine/urlinterceptor.cpp"
        "src/webengine/urlinterceptor.h"
        "src/webengine/webengineprofile.cpp"    # todo: rename to profile
        "src/webengine/webengineprofile.h"
        "src/webengine/webpage.cpp"
        "src/webengine/webpage.h"
        "src/webengine/webview.cpp"
        "src/webengine/webview.h"

        # forms
        "src/forms/aboutdialog.cpp"
        "src/forms/aboutdialog.h"
        "src/forms/aboutdialog.ui"
        # todo: move to src/webengine
        "src/forms/cookiesform.cpp"
        "src/forms/cookiesform.h"
        "src/forms/cookiesform.ui"

        # plugin interfaces
        plugins/interfaces.h
        src/mainwindow/widgets/navigationbar.cpp src/mainwindow/widgets/navigationbar.h)

add_executable(poi ${SourceCode})

target_include_directories(poi
        PRIVATE src lib
        PRIVATE plugins)

target_link_libraries(poi Qt5::Core Qt5::Widgets Qt5::Concurrent Qt5::WebEngineWidgets)
target_link_libraries(poi configuration)
target_link_libraries(poi bookmarks downloads navigation)

install(TARGETS poi RUNTIME DESTINATION bin CONFIGURATIONS Release)