-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
186 lines (150 loc) · 4.77 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
#
# 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_pbr
VERSION "1.0.${BUILD_NUMBER}"
DESCRIPTION "Compositor Surface C++ Template"
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}")
include(options)
include(flags)
include(target_arch)
add_subdirectory(third_party)
#
# System packages
#
#find_package(PkgConfig REQUIRED)
#pkg_check_modules(GLES glesv2 egl REQUIRED)
#pkg_check_modules(WAYLAND REQUIRED wayland-egl)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(Vulkan REQUIRED)
#
# Library
#
add_subdirectory(base)
set(API_PUBLIC_HEADERS include/${PROJECT_NAME}/${PROJECT_NAME}.h)
add_library(${PROJECT_NAME} SHARED
src/main.cpp
src/context.h
src/context.cpp
src/vulkan_pbr.cpp
third_party/imgui/imgui.cpp
third_party/imgui/imgui_draw.cpp
third_party/imgui/imgui_tables.cpp
third_party/imgui/imgui_widgets.cpp
${WAYLAND_PROTOCOL_SOURCES}
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
NOMINMAX
_USE_MATH_DEFINES
_CRT_SECURE_NO_WARNINGS
RUNTIME_ASSET_PATH="${RUNTIME_ASSET_PATH}"
)
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-switch-enum)
target_include_directories(${PROJECT_NAME}
PUBLIC
include
PRIVATE
base
third_party/imgui
Vulkan::Vulkan
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
base
ktx
Threads::Threads
Vulkan::Vulkan
draco_attributes
draco_compression_attributes_dec
draco_compression_attributes_pred_schemes_dec
draco_compression_bit_coders
draco_compression_decode
draco_compression_entropy
draco_compression_mesh_dec
draco_compression_options
draco_compression_point_cloud_dec
draco_core
draco_dec_config
draco_enc_config
draco_io
draco_mesh
draco_metadata
draco_metadata_dec
draco_animation
draco_animation_dec
draco_point_cloud
draco_points_dec
${WAYLAND_LINK_LIBRARIES}
${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}
)
#
# 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 ()