forked from KhronosGroup/ANARI-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
180 lines (144 loc) · 4.59 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
## Copyright 2021-2024 The Khronos Group
## SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.11)
message(STATUS "CMake version: ${CMAKE_VERSION}")
## Language setup
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_BUILD_TYPE_INIT Release)
set(CMAKE_INSTALL_MESSAGE LAZY)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
## Establish project
set(ANARI_SDK_VERSION_MAJOR 0)
set(ANARI_SDK_VERSION_MINOR 11)
set(ANARI_SDK_VERSION_PATCH 1)
set(ANARI_SDK_VERSION
${ANARI_SDK_VERSION_MAJOR}.${ANARI_SDK_VERSION_MINOR}.${ANARI_SDK_VERSION_PATCH}
)
project(anari VERSION ${ANARI_SDK_VERSION} LANGUAGES C CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
include(GNUInstallDirs)
include(CMakeDependentOption)
enable_testing()
if (APPLE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
elseif(UNIX)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
# Built-in CMake options
option(BUILD_SHARED_LIBS "Build shared libraries instead of static" ON)
option(BUILD_TESTING "Build tests for CTest" ON)
# ANARI specific options
option(BUILD_CTS "Build cts toolkit" OFF)
cmake_dependent_option(CTS_ENABLE_GLTF "Enable glTF support for cts" ON "BUILD_CTS" OFF)
option(USE_DRACO "Use draco when loading glTF files" OFF)
option(USE_WEBP "Use webp when loading glTF files" OFF)
option(USE_KTX "Use ktx when loading glTF files" OFF)
if (CTS_ENABLE_GLTF)
# To enforce WEBP, KTX and DRACO support (CI does not have these dependecies)
# set(USE_KTX ON)
# set(USE_WEBP ON)
# set(USE_DRACO ON)
endif()
option(BUILD_EXAMPLES "Build example applications and example device" ON)
cmake_dependent_option(BUILD_VIEWER
"Build interactive viewer app (requires GLFW)"
OFF
"BUILD_EXAMPLES"
OFF
)
cmake_dependent_option(BUILD_SCENES_LIB
"Enable anari_test_scenes library"
ON
"NOT BUILD_TESTING;NOT BUILD_EXAMPLES;NOT BUILD_CTS"
ON
)
option(INSTALL_VIEWER_LIBRARY "Install anari::anari_viewer library target" ON)
option(INSTALL_VIEWER "Install anariViewer app" OFF)
mark_as_advanced(INSTALL_VIEWER)
cmake_dependent_option(VIEWER_ENABLE_GLTF
"Enable glTF support in viewer"
OFF
"BUILD_VIEWER"
OFF
)
if (VIEWER_ENABLE_GLTF)
# To enforce WEBP and DRACO support (CI does not have these dependecies)
# set(USE_WEBP ON)
# set(USE_DRACO ON)
endif()
cmake_dependent_option(VIEWER_ENABLE_KTX
"Enable KTX support in viewer"
OFF
"BUILD_VIEWER"
OFF
)
if (VIEWER_ENABLE_KTX)
set(USE_KTX ON)
endif()
## The generate_all targets collects all offline code generation targets
set(ANARI_CODE_GEN_ROOT ${CMAKE_SOURCE_DIR}/code_gen)
add_custom_target(generate_all)
include(cmake/anari_generate_frontend.cmake)
include(cmake/anari_generate_codegen.cmake)
include(cmake/cmake_project_commands.cmake)
include(cmake/anari_sdk_fetch_project.cmake)
## Add library and executable targets
add_subdirectory(src)
add_subdirectory(external)
add_subdirectory(code_gen)
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
if (BUILD_CTS)
add_subdirectory(cts)
endif()
include(cmake/mark_cache_variables_as_advanced.cmake)
## Configure CMake find_package() config files ##
set(ANARI_CMAKE_INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
)
install(EXPORT anari_Exports
DESTINATION ${ANARI_CMAKE_INSTALL_DESTINATION}
NAMESPACE anari::
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${ANARI_CMAKE_INSTALL_DESTINATION}
)
write_basic_package_version_file(
"${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION
${ANARI_CMAKE_INSTALL_DESTINATION}
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/cmake
DESTINATION
${ANARI_CMAKE_INSTALL_DESTINATION}
FILES_MATCHING
PATTERN *.cmake
PATTERN Findanari.cmake EXCLUDE
)