-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
179 lines (158 loc) · 5.2 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
cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(VersioningUtils)
read_version_header("" "WPE_[A-Z]+_VERSION" "${CMAKE_CURRENT_SOURCE_DIR}/include/wpe/libwpe-version.h")
set_project_version(${WPE_MAJOR_VERSION} ${WPE_MINOR_VERSION} ${WPE_MICRO_VERSION})
set(WPE_API_VERSION "1.0")
# 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(LIBWPE 11 0 10)
project(libwpe VERSION "${PROJECT_VERSION}")
set(BUILD_SHARED_LIBS
ON
CACHE BOOL "Build libwpe as a shared library"
)
set(WPE_BACKEND
""
CACHE STRING "Name of the backend library to load, instead of libWPEBackend-default.so"
)
set(WPE_ENABLE_XKB
ON
CACHE STRING "Enable use of libxkbcommon for keyboard input"
)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
foreach (cxxflag -fno-exceptions -fno-rtti -Wall)
check_cxx_compiler_flag("${cxxflag}" CXX_HAS_FLAG_${cxxflag})
if (CXX_HAS_FLAG_${cxxflag})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxxflag}")
endif ()
endforeach ()
foreach (cflag -Wall)
check_c_compiler_flag("${cflag}" CC_HAS_FLAG_${cflag})
if (CC_HAS_FLAG_${cflag})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflag}")
endif ()
endforeach ()
include(DistTargets)
include(GNUInstallDirs)
find_package(EGL REQUIRED)
set(WPE_PUBLIC_HEADERS
include/wpe/libwpe-version.h
include/wpe/version.h
include/wpe/version-deprecated.h
include/wpe/export.h
include/wpe/gamepad.h
include/wpe/input.h
include/wpe/input-xkb.h
include/wpe/keysyms.h
include/wpe/loader.h
include/wpe/pasteboard.h
include/wpe/process.h
include/wpe/renderer-backend-egl.h
include/wpe/renderer-host.h
include/wpe/view-backend.h
include/wpe/wpe-egl.h
include/wpe/wpe.h
)
add_library(
wpe
src/alloc.c
src/input-xkb.c
src/key-unicode.c
src/pasteboard.c
src/pasteboard-generic.cpp
src/pasteboard-noop.cpp
src/process.c
src/renderer-backend-egl.c
src/renderer-host.c
src/version.c
src/view-backend.c
src/gamepad.c
)
if (BUILD_SHARED_LIBS)
target_sources(wpe PRIVATE src/loader.c)
set_target_properties(
wpe
PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
OUTPUT_NAME wpe-${WPE_API_VERSION}
VERSION ${LIBWPE_VERSION}
SOVERSION ${LIBWPE_VERSION_MAJOR}
)
else ()
target_sources(wpe PRIVATE src/loader-static.c)
endif ()
target_include_directories(
wpe PRIVATE "include" "src" $<TARGET_PROPERTY:GL::egl,INTERFACE_INCLUDE_DIRECTORIES>
)
target_compile_definitions(
wpe PRIVATE WPE_COMPILATION $<TARGET_PROPERTY:GL::egl,INTERFACE_COMPILE_DEFINITIONS>
)
if (WPE_BACKEND)
target_compile_definitions(wpe PRIVATE WPE_BACKEND=\"${WPE_BACKEND}\")
endif ()
if (WPE_ENABLE_XKB)
target_compile_definitions(wpe PUBLIC WPE_ENABLE_XKB=1)
set(WPE_PC_CFLAGS -DWPE_ENABLE_XKB=1)
endif ()
target_compile_options(wpe PRIVATE $<TARGET_PROPERTY:GL::egl,INTERFACE_COMPILE_OPTIONS>)
target_link_libraries(wpe PRIVATE ${CMAKE_DL_LIBS})
if (WPE_ENABLE_XKB)
find_package(Libxkbcommon REQUIRED)
target_link_libraries(wpe PRIVATE XkbCommon::libxkbcommon)
set(WPE_PC_REQUIRES xkbcommon)
endif ()
install(
TARGETS wpe
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${WPE_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wpe-${WPE_API_VERSION}/wpe)
configure_file(wpe.pc.in wpe-${WPE_API_VERSION}.pc @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/wpe-${WPE_API_VERSION}.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
option(BUILD_DOCS "Build the documentation" OFF)
if (BUILD_DOCS)
find_program(HOTDOC hotdoc)
if (NOT HOTDOC)
message(FATAL_ERROR "hotdoc not found!")
endif ()
execute_process(
COMMAND ${HOTDOC} --has-extension c-extension
RESULT_VARIABLE HAS_HOTDOC_C_EXTENSION
ERROR_QUIET
)
if ("${HAS_HOTDOC_C_EXTENSION}" EQUAL 0)
add_custom_target(
Documentation ALL
${HOTDOC}
run
--project-name=libwpe
--project-version=1.0
--include-paths="${CMAKE_CURRENT_SOURCE_DIR}/docs"
--sitemap=${CMAKE_CURRENT_SOURCE_DIR}/docs/sitemap.txt
--output=${CMAKE_CURRENT_BINARY_DIR}/Documentation/
--c-sources
"${CMAKE_CURRENT_SOURCE_DIR}/include/wpe/*.h"
--extra-c-flags=-DWPE_COMPILATION=1
--c-include-directories
${CMAKE_CURRENT_SOURCE_DIR}/include
--c-smart-index
)
else ()
message(FATAL_ERROR "Hotdoc C extension not found... can't build the documentation.")
endif ()
endif ()