-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
176 lines (138 loc) · 4.86 KB
/
Copy pathCMakeLists.txt
File metadata and controls
176 lines (138 loc) · 4.86 KB
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
## Copyright 2021-2026 The Khronos Group
## SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.11)
# Honor normal/cache variables (e.g. -DCTS_ENABLE_GLTF=ON) set before option().
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif ()
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 17)
set(ANARI_SDK_VERSION_PATCH 0)
set(ANARI_SDK_VERSION
${ANARI_SDK_VERSION_MAJOR}.${ANARI_SDK_VERSION_MINOR}.${ANARI_SDK_VERSION_PATCH}
)
project(anari-sdk 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_TESTING "Build tests for CTest" ON)
option(BUILD_SHARED_LIBS "Build shared libraries instead of static" ON)
## ANARI specific options ##
option(BUILD_CTS "Build the cts conformance tool" OFF)
# Decoupled from BUILD_CTS: the glTF asset tests need only the glTF loader, not
# the (removed) Python/pybind toolkit. CMP0077 (NEW, set above) lets -D override.
option(CTS_ENABLE_GLTF "Enable the CTS glTF asset-scanning tests" OFF)
option(BUILD_CAT "Build capability analysis tool" 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)
option(USE_KOKKOS "Use Kokkos to accelerate scene build and updates" OFF)
option(BUILD_EXAMPLES "Build example applications and example device" ON)
cmake_dependent_option(BUILD_VIEWER
"Build interactive viewer app (requires SDL3)"
OFF
"BUILD_EXAMPLES"
OFF
)
if (BUILD_CAT)
# CAT requires anari::anari_viewer library
set(BUILD_VIEWER ON CACHE BOOL "Build interactive viewer app (requires SDL3)" FORCE)
endif ()
option(INSTALL_CTS "Install CTS scripts and data" OFF)
option(INSTALL_VIEWER_LIBRARY "Install anari::anari_viewer library target" ON)
option(INSTALL_VIEWER "Install anariViewer app" OFF)
option(INSTALL_CAT "Install anariCat app" OFF)
mark_as_advanced(INSTALL_CAT)
mark_as_advanced(INSTALL_VIEWER)
cmake_dependent_option(VIEWER_ENABLE_GLTF
"Enable glTF support in viewer"
OFF
"BUILD_VIEWER"
OFF
)
## 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()
# Added after tests/ so include(CTest) above enables the anariCts smoke tests.
# CTS_ENABLE_GLTF only affects a CTS consumer; it does not create one itself.
if (BUILD_CTS OR BUILD_TESTING OR INSTALL_CTS)
add_subdirectory(cts)
endif()
if (BUILD_CAT)
add_subdirectory(cat)
endif ()
include(cmake/mark_cache_variables_as_advanced.cmake)
## Configure CMake find_package() config files ##
set(ANARI_CMAKE_INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/anari-${PROJECT_VERSION}
)
install(EXPORT anari_Exports
DESTINATION ${ANARI_CMAKE_INSTALL_DESTINATION}
NAMESPACE anari::
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/anariConfig.cmake.in"
"${PROJECT_BINARY_DIR}/anariConfig.cmake"
INSTALL_DESTINATION
${ANARI_CMAKE_INSTALL_DESTINATION}
)
write_basic_package_version_file(
"anariConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/anariConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/anariConfigVersion.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
)