-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
233 lines (186 loc) · 6.13 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
#
# Copyright 2022 Toyota Connected North America
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.10.2)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE)
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.")
endif ()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
if (NOT BUILD_NUMBER)
set(BUILD_NUMBER 0)
endif ()
project(comp_surf_filament
VERSION "1.0.${BUILD_NUMBER}"
DESCRIPTION "Compositor Surface Filament Test"
LANGUAGES CXX C
)
message(STATUS "Project ................ ${PROJECT_NAME}")
message(STATUS "Version ................ ${PROJECT_VERSION}")
message(STATUS "Generator .............. ${CMAKE_GENERATOR}")
message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(options)
include(flags)
include(target_arch)
add_subdirectory(third_party)
add_subdirectory(libs/filamentappwayland)
#
# System packages
#
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
#
# Library
#
set(API_PUBLIC_HEADERS include/${PROJECT_NAME}/${PROJECT_NAME}.h)
add_library(${PROJECT_NAME} SHARED
src/main.cpp
src/context.h
src/context.cpp
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
EGL_NO_X11
MESA_EGL_NO_X11_HEADERS
)
target_include_directories(${PROJECT_NAME}
PUBLIC
include
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/libs/filamentappwayland/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/filament/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/camutils/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/utils/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/math/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/filament/backend/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/filabridge/include
${CMAKE_BINARY_DIR}/third_party/filament/samples
${CMAKE_BINARY_DIR}/libs/filamentappwayland
${GST_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
filament
backend
bluevk
filabridge
filaflat
smol-v
vkshaders
ibl
camutils
civetweb
filament-iblprefilter
filameshio
gltfio
filamat
gltfio_core
utils
dracodec
geometry
image
matdbg
meshoptimizer
shaders
viewer
stb
filament
filamentappwl
filamentappwl-resources
sample-resources
suzanne-resources
Threads::Threads
${CMAKE_DL_LIBS}
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MINOR}
)
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}
)
add_dependencies(${PROJECT_NAME} sample-resources)
add_library(${PROJECT_NAME}_test SHARED
test/main.cpp
test/context.h
test/context.cpp
)
target_compile_definitions(${PROJECT_NAME}_test PRIVATE FILAMENT_SUPPORTS_WAYLAND)
target_include_directories(${PROJECT_NAME}_test
PUBLIC
include
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/libs/filamentappwayland/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/filament/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/camutils/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/utils/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/math/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/filament/backend/include
${CMAKE_CURRENT_LIST_DIR}/third_party/filament/libs/filabridge/include
${GST_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}_test PRIVATE
bluevk
sdl2
${CMAKE_DL_LIBS}
)
set_target_properties(${PROJECT_NAME}_test
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MINOR}
)
#
# Optimizations
#
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_support_result OUTPUT ipo_support_output)
if (ipo_support_result)
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else ()
message(WARNING "IPO is not supported: ${ipo_support_output}")
endif ()
#
# Install
#
include(GNUInstallDirs)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
ASSET_DIRECTORY="${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/assets"
)
message(STATUS "install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "staging prefix: ${CMAKE_STAGING_PREFIX}")
install(TARGETS ${PROJECT_NAME})
install(FILES ${API_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(DIRECTORY assets DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/)
#
# Packaging
#
if (NOT CMAKE_CROSSCOMPILING)
include(packaging)
endif ()