forked from Igalia/cog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
237 lines (203 loc) · 7.58 KB
/
CMakeLists.txt
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
cmake_minimum_required (VERSION 3.3)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake")
include(VersioningUtils)
set_project_version(0 9 1)
# Before making a release, the LT_VERSION string should be modified.
# The string is of the form C:R:A.
# - If interfaces have been changed or added, but binary compatibility has
# been preserved, change to C+1:0:A+1
# - If binary compatibility has been broken (eg removed or changed interfaces)
# change to C+1:0:0
# - If the interface is the same as the previous version, change to C:R+1:A
calculate_library_versions_from_libtool_triple(COGCORE 5 0 4)
project(cog VERSION "${PROJECT_VERSION}" LANGUAGES C)
include(DistTargets)
include(GNUInstallDirs)
set(COG_VERSION_EXTRA "")
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
set(COG_VERSION_EXTRA "+git")
find_package(Git)
file(COPY ${CMAKE_SOURCE_DIR}/hooks/pre-commit DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
if (GIT_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-list --max-count=1 --abbrev-commit HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_STATUS
OUTPUT_VARIABLE GIT_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (${GIT_STATUS} EQUAL 0 AND GIT_OUTPUT)
set(COG_VERSION_EXTRA "${COG_VERSION_EXTRA}-${GIT_OUTPUT}")
endif ()
execute_process(
COMMAND "${GIT_EXECUTABLE}" status --porcelain
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_STATUS
OUTPUT_VARIABLE GIT_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (${GIT_STATUS} EQUAL 0 AND GIT_OUTPUT)
set(COG_VERSION_EXTRA "${COG_VERSION_EXTRA}-dirty")
endif ()
unset(GIT_STATUS)
unset(GIT_OUTPUT)
endif ()
message(STATUS "Source tree revision: ${PROJECT_VERSION}${COG_VERSION_EXTRA}")
endif ()
option(COG_DBUS_SYSTEM_BUS "Expose remote control interface on system bus" OFF)
set(COG_DBUS_OWN_USER "" CACHE STRING
"Additional user allowed to own the well-known name on the system bus")
option(COG_PLATFORM_HEADLESS "Build the headless platform module" ON)
option(COG_PLATFORM_WL "Build the Wayland platform module" ON)
option(COG_PLATFORM_DRM "Build the DRM platform module" ON)
option(COG_PLATFORM_X11 "Build the X11 platform module" OFF)
option(COG_PLATFORM_GTK4 "Build the GTK4 platform module" OFF)
option(COG_BUILD_PROGRAMS "Build and install programs as well" ON)
option(INSTALL_MAN_PAGES "Install the man(1) pages if COG_BUILD_PROGRAMS is enabled" ON)
option(COG_WESTON_DIRECT_DISPLAY "Build direct display support for the Wayland platform module" OFF)
option(BUILD_DOCS "Build the documentation" OFF)
option(USE_SOUP2 "Build with libsoup2 instead of libsoup3" ON)
set(COG_APPID "" CACHE STRING "Default GApplication unique identifier")
set(COG_HOME_URI "" CACHE STRING "Default home URI")
set(COG_MODULEDIR "${CMAKE_INSTALL_PREFIX}/lib/cog/modules"
CACHE STRING "Default search path for loadable modules")
if (NOT COG_APPID OR COG_APPID STREQUAL "")
set(COG_DEFAULT_APPID com.igalia.Cog)
else ()
set(COG_DEFAULT_APPID ${COG_APPID})
endif ()
if (COG_HOME_URI AND NOT COG_HOME_URI STREQUAL "")
set(COG_DEFAULT_HOME_URI ${COG_HOME_URI})
endif ()
if (BUILD_SHARED_LIBS)
set(COGCORE_COMPONENT "runtime")
else()
set(COGCORE_COMPONENT "development")
endif()
add_definitions(-DCOG_INSIDE_COG__=1)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
find_package(PkgConfig)
# libcogcore
set(COGCORE_API_HEADERS
core/cog.h
core/cog-launcher.h
core/cog-request-handler.h
core/cog-directory-files-handler.h
core/cog-host-routes-handler.h
core/cog-prefix-routes-handler.h
core/cog-shell.h
core/cog-utils.h
core/cog-webkit-utils.h
core/cog-platform.h
core/cog-modules.h
core/cog-modules.c
${CMAKE_CURRENT_BINARY_DIR}/cog-config.h
)
set(COGCORE_SOURCES
core/cog-launcher.c
core/cog-request-handler.c
core/cog-directory-files-handler.c
core/cog-host-routes-handler.c
core/cog-prefix-routes-handler.c
core/cog-utils.c
core/cog-shell.c
core/cog-webkit-utils.c
core/cog-platform.c
)
if (USE_SOUP2)
set(REQUIRED_GIO_VERSION "gio-2.0>=2.44")
set(REQUIRED_SOUP_VERSION "libsoup-2.4")
set(REQUIRED_WEBKIT_VERSION "wpe-webkit-1.0>=2.28.0")
add_definitions("-DCOG_USE_SOUP2=1")
else()
set(REQUIRED_GIO_VERSION "gio-2.0>=2.67.4")
set(REQUIRED_SOUP_VERSION "libsoup-3.0>=2.99.7")
set(REQUIRED_WEBKIT_VERSION "wpe-webkit-1.1>=2.33.1")
add_definitions("-DCOG_USE_SOUP2=0")
endif()
pkg_check_modules(GIO IMPORTED_TARGET REQUIRED ${REQUIRED_GIO_VERSION})
pkg_check_modules(SOUP IMPORTED_TARGET REQUIRED ${REQUIRED_SOUP_VERSION})
pkg_check_modules(WebKit IMPORTED_TARGET REQUIRED ${REQUIRED_WEBKIT_VERSION})
include(CheckCCompilerFlag)
check_c_compiler_flag(-Wall HAS_WALL)
if (COG_DBUS_SYSTEM_BUS)
# Generate and install D-Bus policy configuration file.
configure_file(dbus/policy.conf.in ${COG_DEFAULT_APPID}.conf @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COG_DEFAULT_APPID}.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/system.d
COMPONENT "runtime"
)
# Let the source code know that the option is enabled.
add_definitions(-DCOG_DBUS_SYSTEM_BUS=1)
add_definitions(-DCOG_DBUS_OWN_USER=\"${COG_DBUS_OWN_USER}\")
endif ()
add_library(cogcore SHARED ${COGCORE_SOURCES} ${COGCORE_API_HEADERS})
set_target_properties(cogcore PROPERTIES
C_STANDARD 99
VERSION ${COGCORE_VERSION}
SOVERSION ${COGCORE_VERSION_MAJOR}
)
target_link_libraries(cogcore PkgConfig::GIO PkgConfig::WebKit PkgConfig::SOUP)
target_compile_definitions(cogcore PRIVATE G_LOG_DOMAIN=\"Cog-Core\")
if (HAS_WALL)
target_compile_options(cogcore PUBLIC -Wall)
endif ()
if (COG_BUILD_PROGRAMS)
add_executable(cog cog.c)
set_property(TARGET cog PROPERTY C_STANDARD 99)
if (HAS_WALL)
target_compile_options(cog PUBLIC "-Wall")
endif ()
target_compile_definitions(cog PRIVATE G_LOG_DOMAIN=\"Cog\")
target_link_libraries(cog cogcore -ldl)
add_executable(cogctl cogctl.c core/cog-utils.c)
set_property(TARGET cogctl PROPERTY C_STANDARD 99)
target_compile_definitions(cogctl PRIVATE G_LOG_DOMAIN=\"Cog-Control\")
if (HAS_WALL)
target_compile_options(cogctl PUBLIC "-Wall")
endif ()
target_link_libraries(cogctl PkgConfig::GIO PkgConfig::SOUP)
install(TARGETS cog cogctl
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT "runtime"
)
if (INSTALL_MAN_PAGES)
install(FILES data/cog.1 data/cogctl.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
COMPONENT "runtime"
)
endif ()
endif ()
install(TARGETS cogcore
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${COGCORE_COMPONENT}
)
install(FILES ${COGCORE_API_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cog
COMPONENT "development"
)
configure_file(core/cog-config.h.in cog-config.h @ONLY)
configure_file(core/cogcore.pc.in cogcore.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cogcore.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT "development"
)
if (BUILD_DOCS)
add_subdirectory(docs)
endif ()
if (COG_PLATFORM_HEADLESS)
add_subdirectory(platform/headless)
endif ()
if (COG_PLATFORM_WL)
add_subdirectory(platform/wayland)
endif ()
if (COG_PLATFORM_DRM)
add_subdirectory(platform/drm)
endif ()
if (COG_PLATFORM_X11)
add_subdirectory(platform/x11)
endif ()
if (COG_PLATFORM_GTK4)
add_subdirectory(platform/gtk4)
endif ()