forked from KDAB/KDGpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (102 loc) · 4.21 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
# This file is part of KDGpu.
#
# SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: MIT
#
# Contact KDAB at <[email protected]> for commercial licensing options.
#
cmake_minimum_required(VERSION 3.16)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
cmake_policy(SET CMP0090 NEW) # Stop export(PACKAGE) from modifying the system-wide cmake package system
cmake_policy(SET CMP0117 NEW) # Do not add /GR to CMAKE_CXX_FLAGS
project(KDGpu VERSION 0.5.1)
add_definitions(-DKDGPU_ASSET_PATH="${CMAKE_CURRENT_BINARY_DIR}/assets")
if(KDGPU_LARGE_ASSETS)
add_definitions(-DKDGPU_LARGE_ASSET_PATH="${CMAKE_CURRENT_BINARY_DIR}/assets/large-assets")
endif()
# Add a DEBUG define on DEBUG builds
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE)
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT WIN32)
)
# Linker warnings should be treated as errors
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_MODULE_LINKER_FLAGS}")
# Do not allow undefined symbols, even in non-symbolic shared libraries
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU")
add_compile_options(-Wimplicit-fallthrough)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# cmake-lint: disable=C0301
# Silences a warning on raspberry pi gcc. See:
# https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
add_compile_options(-Wno-psabi)
endif()
include(CompileShader)
include(CheckAtomic)
include(ECMEnableSanitizers)
include(FeatureSummary)
include(CMakeDependentOption)
include(GNUInstallDirs)
# Note: Set before including dependencies.cmake, so 3rd party libs end up in the correct dir
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
option(KDGPU_BUILD_SHARED_LIBS "Build shared libraries" ON)
set(BUILD_SHARED_LIBS ${KDGPU_BUILD_SHARED_LIBS})
option(KDGPU_CODE_COVERAGE "Code Coverage" OFF)
option(KDGPU_BUILD_TESTS "Build tests" ON)
option(KDGPU_BUILD_KDGPUKDGUI "Build KDGpuKDGui" ON)
cmake_dependent_option(
KDGPU_BUILD_KDGPUEXAMPLE
"Build KDGpuExample"
ON
KDGPU_BUILD_KDGPUKDGUI
OFF
)
option(KDGPU_BUILD_EXAMPLES "Build examples" ON)
cmake_dependent_option(
KDGPU_BUILD_ASSETS
"Build Assets"
ON
KDGPU_BUILD_EXAMPLES
OFF
)
option(KDGPU_HLSL_SUPPORT "Try to find and use the dxc HLSL to SPIR-V compiler" OFF)
add_feature_info(KDGpuKDGui ${KDGPU_BUILD_KDGPUKDGUI} "Build KDGpuKDGui")
add_feature_info(KDGpuExample ${KDGPU_BUILD_KDGPUEXAMPLE} "Build KDGpuExample")
option(KDGPU_BUILD_KDXR "Build KDXr" ON)
option(KDGPU_OPENXR_SUPPORT "Enable support for OpenXR" ON)
add_feature_info(OpenXR ${KDGPU_OPENXR_SUPPORT} "Enable support for OpenXR")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(KDGPU_CODE_COVERAGE)
include(cmake/CodeCoverage.cmake)
endif()
endif()
add_subdirectory(src)
add_feature_info(KDGpu-Assets ${KDGPU_BUILD_ASSETS} "Build Assets")
if(KDGPU_BUILD_ASSETS)
add_subdirectory(assets)
endif()
add_feature_info(KDGpu-Tests ${KDGPU_BUILD_TESTS} "Build Tests")
if(KDGPU_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
add_feature_info(KDGpu-Examples ${KDGPU_BUILD_EXAMPLES} "Build Examples")
if(KDGPU_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
option(KDGPU_DOCS "Build the API documentation" OFF)
add_feature_info(KDGpu-Documentation ${KDGPU_DOCS} "Build Documentation")
if(KDGPU_DOCS)
add_subdirectory(docs)
endif()
feature_summary(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND ENABLED_FEATURES DISABLED_FEATURES INCLUDE_QUIET_PACKAGES)