forked from NVIDIA/MDL-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
237 lines (206 loc) · 10.7 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
234
235
236
#*****************************************************************************
# Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#*****************************************************************************
cmake_minimum_required(VERSION 3.9.6 FATAL_ERROR)
# policies
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif()
project(MDL LANGUAGES C CXX)
# MDL SDK build directories
set(MDL_BASE_FOLDER ${CMAKE_SOURCE_DIR} CACHE PATH "The folder that contains the targets to build and the cmake utility scripts.")
set(MDL_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/include CACHE PATH "The folder that interface headers, i.e., mi/base, mi/neuray, ... directories.")
set(MDL_SRC_FOLDER ${CMAKE_SOURCE_DIR}/src CACHE PATH "The folder that contains the sources, i.e., the base, io, mdl, ... directories.")
set(MDL_EXAMPLES_FOLDER ${CMAKE_SOURCE_DIR}/examples CACHE PATH "The folder that contains the mdl examples")
#--------------------------------------------------------------------------------------------------
# configuration options
option(MDL_BUILD_SDK_EXAMPLES "Adds MDL SDK examples to the build." ON)
option(MDL_BUILD_CORE_EXAMPLES "Adds MDL Core examples to the build." ON)
option(MDL_BUILD_ARNOLD_PLUGIN "Enable the build of the MDL Arnold plugin." OFF)
option(MDL_LOG_PLATFORM_INFOS "Prints some infos about the current build system (relevant for error reports)." ON)
option(MDL_LOG_DEPENDENCIES "Prints the list of dependencies during the generation step." OFF)
option(MDL_LOG_FILE_DEPENDENCIES "Prints the list of files that is copied after a successful build." OFF)
set(MDL_ADDITIONAL_COMPILER_DEFINES "MDL_SOURCE_RELEASE" CACHE STRING "Additional compile defines that are passed to each of the projects")
set(MDL_ADDITIONAL_COMPILER_OPTIONS "" CACHE STRING "Additional compile options that are passed to each of the projects")
# set the default installation path
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "..." FORCE)
endif()
# -------------------------------------------------------------------------------------------------
# general setup
include(${MDL_BASE_FOLDER}/cmake/setup.cmake)
if(MDL_LOG_PLATFORM_INFOS)
MESSAGE(STATUS "[INFO] MDL_BUILD_SDK_EXAMPLES: " ${MDL_BUILD_SDK_EXAMPLES})
MESSAGE(STATUS "[INFO] MDL_BUILD_CORE_EXAMPLES: " ${MDL_BUILD_CORE_EXAMPLES})
MESSAGE(STATUS "[INFO] MDL_BUILD_ARNOLD_PLUGIN: " ${MDL_BUILD_ARNOLD_PLUGIN})
endif()
# enable tests if available
if(MDL_ENABLE_TESTS)
enable_testing()
endif()
# -------------------------------------------------------------------------------------------------
# presets and utility functions used in all CMakeLists
include(${MDL_BASE_FOLDER}/cmake/utilities.cmake)
#--------------------------------------------------------------------------------------------------
# list of modules in defined order
# PUBLIC HEADERS (for convenience in IDEs)
#--------------------------------------------------------------------------------------------------
add_subdirectory(${MDL_INCLUDE_FOLDER})
# MDL SDK and MDL CORE
#--------------------------------------------------------------------------------------------------
# first thing to build
add_subdirectory(${MDL_SRC_FOLDER}/base/system/main)
add_subdirectory(${MDL_SRC_FOLDER}/base/system/stlext)
add_subdirectory(${MDL_SRC_FOLDER}/base/system/version)
# third party
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/libzip)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/zlib)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/tinyxml2)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/compiler/coco)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/jit/llvm)
# libs
add_subdirectory(${MDL_SRC_FOLDER}/base/util/string_utils)
add_subdirectory(${MDL_SRC_FOLDER}/base/util/registry)
add_subdirectory(${MDL_SRC_FOLDER}/base/hal/disk)
add_subdirectory(${MDL_SRC_FOLDER}/base/hal/hal)
add_subdirectory(${MDL_SRC_FOLDER}/base/hal/link)
add_subdirectory(${MDL_SRC_FOLDER}/base/hal/time)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/config)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/cont)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/log)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/mem)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/path)
add_subdirectory(${MDL_SRC_FOLDER}/base/lib/plug)
add_subdirectory(${MDL_SRC_FOLDER}/base/data/attr)
add_subdirectory(${MDL_SRC_FOLDER}/base/data/db)
add_subdirectory(${MDL_SRC_FOLDER}/base/data/dblight)
add_subdirectory(${MDL_SRC_FOLDER}/base/data/serial)
add_subdirectory(${MDL_SRC_FOLDER}/io/image)
add_subdirectory(${MDL_SRC_FOLDER}/io/scene)
add_subdirectory(${MDL_SRC_FOLDER}/api/api/mdl)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/codegenerators/generator_code)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/codegenerators/generator_dag)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/compiler/compilercore)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/compiler/compiler_hlsl)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/jit/libbsdf)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/jit/libmdlrt)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/jit/devlib)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/jit/generator_jit)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/no_glsl/generator_stub)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/no_jit/generator_stub)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/runtime)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/integration/i18n)
add_subdirectory(${MDL_SRC_FOLDER}/mdl/integration/mdlnr)
add_subdirectory(${MDL_SRC_FOLDER}/render/mdl/backends)
add_subdirectory(${MDL_SRC_FOLDER}/render/mdl/runtime)
# libs/products
add_subdirectory(${MDL_SRC_FOLDER}/prod/lib/mdl_core)
add_subdirectory(${MDL_SRC_FOLDER}/prod/lib/mdl_sdk)
add_subdirectory(${MDL_SRC_FOLDER}/prod/bin/i18n)
add_subdirectory(${MDL_SRC_FOLDER}/prod/bin/mdlc)
add_subdirectory(${MDL_SRC_FOLDER}/prod/bin/mdlm)
# PLUGINS
#--------------------------------------------------------------------------------------------------
add_subdirectory(${MDL_SRC_FOLDER}/shaders/plugin/dds)
add_subdirectory(${MDL_SRC_FOLDER}/shaders/plugin/freeimage)
# EXAMPLES
#--------------------------------------------------------------------------------------------------
# third party
add_subdirectory(${MDL_EXAMPLES_FOLDER}/thirdparty/imgui)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/thirdparty/tinyxml2)
# MDL SDK
if(MDL_BUILD_SDK_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/shared)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/archives)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/calls)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/code_gen)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/compilation)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/create_module)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/discovery)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/execution_native)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/generate_mdl_identifier)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/instantiation)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/mdle)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/modules)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/start_shutdown)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/traversal)
if(MDL_ENABLE_OPENGL_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/df_native)
endif()
if(MDL_ENABLE_CUDA_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/execution_cuda)
if(MDL_ENABLE_OPENGL_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/df_cuda)
if(MDL_ENABLE_OPTIX7_EXAMPLES)
if(WINDOWS)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/optix7)
else()
message(WARNING "The OptiX 7 example is currently only available for Windows.")
endif()
endif()
endif()
endif()
if(MDL_ENABLE_QT_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/mdl_browser)
endif()
if(WINDOWS AND MDL_ENABLE_D3D12_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_sdk/dxr)
endif()
endif()
# MDL CORE
if(MDL_BUILD_CORE_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_core/shared)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_core/calls)
if(MDL_ENABLE_CUDA_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_core/execution_cuda)
if(MDL_ENABLE_OPENGL_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_core/df_cuda)
endif()
endif()
endif()
# Example Content
if(MDL_BUILD_SDK_EXAMPLES OR MDL_BUILD_CORE_EXAMPLES)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl)
endif()
# MDL SDK libs/products and
# PLUGINS FOR EXTERNAL APPLICATIONS that use the MDL SDK and mdl_sdk::shared
#--------------------------------------------------------------------------------------------------
# MDL Arnold
if(MDL_BUILD_ARNOLD_PLUGIN)
add_subdirectory(${MDL_SRC_FOLDER}/prod/lib/mdl_arnold)
endif()
# Language Bindings
if(MDL_ENABLE_PYTHON_BINDINGS)
add_subdirectory(${MDL_SRC_FOLDER}/prod/bindings/mdl_python)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_python)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_python/modules)
add_subdirectory(${MDL_EXAMPLES_FOLDER}/mdl_python/start_shutdown)
endif()
# add tests with the POST option; there require all regular targets to be defined already
foreach(_TEST_POST ${MDL_TEST_LIST_POST})
add_subdirectory(${_TEST_POST})
endforeach()