-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
240 lines (207 loc) · 6.61 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
237
238
239
240
# SPDX-FileCopyrightText: 2024 Howetuft
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.30.0)
project(luxcore_wrapper)
enable_language(C)
enable_language(CXX)
include(CMakePrintHelpers)
cmake_print_variables(CMAKE_BUILD_TYPE)
cmake_print_variables(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
cmake_print_variables(CMAKE_CXX_FLAGS)
set(CMAKE_CXX_STANDARD $ENV{CXX_VERSION})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
set(CMAKE_INSTALL_NAME_DIR "$ENV{CMAKE_INSTALL_NAME_DIR}")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(BUILD_LUXCORE_DLL 1)
set(LUXRAYS_ENABLE_OPENCL TRUE)
set(LUXRAYS_ENABLE_CUDA TRUE)
set(LUXRAYS_ENABLE_OPTIX TRUE)
unset(LUXRAYS_DISABLE_OPENCL)
unset(LUXRAYS_DISABLE_CUDA)
unset(LUXRAYS_DISABLE_OPTIX)
cmake_policy(SET CMP0074 NEW) # *_ROOT variable
message(STATUS "LuxCoreWheel - Add conan targets")
find_package(TBB REQUIRED)
find_package(minizip REQUIRED)
find_package(spdlog REQUIRED)
find_package(OpenImageIO REQUIRED)
find_package(PNG REQUIRED)
find_package(OpenColorIO REQUIRED)
find_package(OpenEXR REQUIRED)
find_package(embree REQUIRED)
find_package(Blosc REQUIRED)
find_package(oidn REQUIRED)
find_package(Boost_python REQUIRED)
find_package(Boost REQUIRED)
find_package(OpenVDB REQUIRED)
find_package(Imath REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(blender-types REQUIRED)
# Bison/Flex
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
# Python
MESSAGE(STATUS "LuxCoreWheel - Python_ROOT_DIR: ${Python_ROOT_DIR}")
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
# If we are here, it means we have found all dependencies
# So let's tell LuxCore all is ok
set(OPENIMAGEIO_FOUND TRUE)
set(EMBREE_FOUND TRUE)
set(OIDN_FOUND TRUE)
set(BLOSC_FOUND TRUE)
if(APPLE)
# OpenMP
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp -Wno-register")
endif(APPLE)
if(LINUX)
set(OpenGL_GL_PREFERENCE "LEGACY")
endif(LINUX)
if(MSVC)
# Minimizes Windows header files
#ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
# Do not define MIN and MAX macros
ADD_DEFINITIONS(-DNOMINMAX)
# Do not warn about standard but insecure functions
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
# Enable Unicode
ADD_DEFINITIONS(-D_UNICODE)
# Enable SSE2/SSE/MMX
ADD_DEFINITIONS(-D__SSE2__ -D__SSE__ -D__MMX__)
add_link_options("/INCREMENTAL:NO" "/PDBALTPATH:%_PDB%")
endif(MSVC)
# Add LuxCore
add_subdirectory(LuxCore)
# sanitize
# Add deps targets to LuxCore libs
target_link_libraries(luxrays embree openimageio::openimageio boost::boost)
target_link_libraries(opensubdiv PRIVATE boost::boost)
target_link_libraries(bcd PRIVATE boost::boost Eigen3::Eigen)
target_link_libraries(slg-core PRIVATE
boost::boost
OpenColorIO::OpenColorIO
OpenVDB::openvdb
openexr::openexr
Imath::Imath
embree
openimageio::openimageio
)
target_link_libraries(slg-kernels PRIVATE boost::boost)
target_link_libraries(slg-film PRIVATE
boost::boost
OpenColorIO::OpenColorIO
embree
oidn::oidn
openimageio::openimageio
)
if ((DEFINED ENV{SANITIZE}) AND LINUX)
message(STATUS "Linking with asan")
add_library(asan SHARED IMPORTED)
set_property(TARGET asan PROPERTY
IMPORTED_LOCATION
$ENV{ASAN_PATH}
)
set(HAVE_SANITIZER TRUE)
endif()
target_link_libraries(pyluxcore PRIVATE
$<$<BOOL:${HAVE_SANITIZER}>:asan>
slg-core
slg-film
slg-kernels
luxrays
bcd
opensubdiv
OpenVDB::openvdb
spdlog::spdlog_header_only
Boost::python
boost::boost
Python::Module
onetbb::onetbb
blender-types
)
set_property(TARGET pyluxcore PROPERTY CXX_STANDARD 17)
target_link_options(pyluxcore PRIVATE $<$<BOOL:${HAVE_SANITIZER}>:-fsanitize=address>)
if(APPLE)
target_link_libraries(opensubdiv PRIVATE llvm-openmp::llvm-openmp)
target_link_libraries(bcd PRIVATE llvm-openmp::llvm-openmp)
target_link_libraries(slg-core PRIVATE llvm-openmp::llvm-openmp)
target_link_libraries(pyluxcore PRIVATE llvm-openmp::llvm-openmp)
endif(APPLE)
# oidnDenoise
add_executable(oidn-denoise IMPORTED)
set_property(TARGET oidn-denoise PROPERTY IMPORTED_LOCATION "${LUX_OIDN_DENOISE_PATH}")
# Installation
# Pyluxcore
INSTALL(TARGETS pyluxcore DESTINATION pyluxcore)
# oidnDenoise (much more work...)
if(WIN32)
# Windows lacks rpath system, so we have to put oidnDenoise in the same
# folder as the dlls...
set(OIDN_DESTINATION "pyluxcore.libs")
else()
# For Macos, reminder: don't put it in pyluxcore/.dylibs, it would prevent
# other deps' relocation
set(OIDN_DESTINATION "pyluxcore.oidn")
endif(WIN32)
if(LINUX)
set_property(
TARGET oidn-denoise
PROPERTY INSTALL_RPATH "\\\${ORIGIN}/../pyluxcore.libs"
)
install(
PROGRAMS "${LUX_OIDN_DENOISE_CPU}"
DESTINATION "pyluxcore.libs"
)
endif(LINUX)
if(APPLE)
set_target_properties(
oidn-denoise PROPERTIES
INSTALL_RPATH "\\\${ORIGIN}/../pyluxcore/.pylibs"
BUILD_RPATH ""
)
endif(APPLE)
INSTALL(
IMPORTED_RUNTIME_ARTIFACTS oidn-denoise
DESTINATION ${OIDN_DESTINATION}
PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
if(WIN32)
# For Win32, we need to add device_cpu
# device_cpu should first have a pyd extension to be repaired.
# This will be reverted after repairing
install(
PROGRAMS "${LUX_OIDN_DENOISE_BINS}/OpenImageDenoise_device_cpu.dll"
DESTINATION "pyluxcore.libs"
RENAME "OpenImageDenoise_device_cpu.pyd"
)
# TODO
#add_library(oidn-device-cpu SHARED IMPORTED)
#set_target_properties(
#oidn-device-cpu PROPERTIES
#IMPORTED_LOCATION "${LUX_OIDN_DENOISE_BINS}/OpenImageDenoise_device_cpu.dll"
#OUTPUT_NAME "OpenImageDenoise_device_cpu.pyd"
#)
#INSTALL(
#IMPORTED_RUNTIME_ARTIFACTS oidn-device-cpu
#DESTINATION "pyluxcore.libs"
#PERMISSIONS
#OWNER_WRITE OWNER_READ OWNER_EXECUTE
#GROUP_READ GROUP_EXECUTE
#WORLD_READ WORLD_EXECUTE
#)
# Delvewheel doesn't handle executables, however we need to delocate oidnDenoise.
# Therefore we had to let Delvewheel believe oidnDenoise is a lib, and now
# we have to make it an executable again...
message(STATUS "oidnDenoise suffix back to pyd")
INSTALL(CODE "file(RENAME \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/oidnDenoise.exe\" \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/oidnDenoise.pyd\")")
# TODO
# device_cpu should have a pyd extension
#INSTALL(CODE "file(RENAME \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.dll\" \"${CMAKE_INSTALL_PREFIX}/pyluxcore.libs/OpenImageDenoise_device_cpu.pyd\")")
# This will be reverted after repairing
endif(WIN32)