forked from GPUOpen-LibrariesAndSDKs/RadeonProRender-Baikal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
144 lines (116 loc) · 5.11 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
cmake_minimum_required(VERSION 3.8)
project(Baikal CXX)
option(BAIKAL_ENABLE_RAYMASK "Enable visibility flags for shapes (slows down an intersector)" OFF)
option(BAIKAL_ENABLE_DENOISER "Use denoising on output" OFF)
option(BAIKAL_ENABLE_RPR "Enable RadeonProRender API lib" OFF)
option(BAIKAL_ENABLE_TESTS "Enable tests" ON)
option(BAIKAL_ENABLE_STANDALONE "Enable standalone application build" ON)
option(BAIKAL_ENABLE_IO "Enable IO library build" ON)
option(BAIKAL_ENABLE_FBX "Enable FBX import in BaikalIO. Requires BaikalIO to be turned ON" OFF)
#Disabled for now.
#option(BAIKAL_EMBED_KERNELS "Embed CL kernels into binary module" OFF)
#Sanity checks
if (BAIKAL_ENABLE_GLTF AND NOT BAIKAL_ENABLE_RPR)
message(FATAL_ERROR "glTF support requires RPR but it's disabled")
endif (BAIKAL_ENABLE_GLTF AND NOT BAIKAL_ENABLE_RPR)
#global settings
if (WIN32)
add_definitions(/MP -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
elseif (UNIX)
add_definitions(-fvisibility=hidden -Wno-ignored-attributes)
endif (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#Find required packages
find_package(Threads REQUIRED)
find_package(OIIO REQUIRED)
if (BAIKAL_ENABLE_STANDALONE OR BAIKAL_ENABLE_RPR)
find_package(OpenGL REQUIRED)
endif (BAIKAL_ENABLE_STANDALONE OR BAIKAL_ENABLE_RPR)
#Configure RadeonRays build
set(RR_EMBED_KERNELS ON CACHE BOOL "Embed CL kernels into binary module")
set(RR_ALLOW_CPU_DEVICES OFF CACHE BOOL "Allows CPU Devices")
set(RR_USE_OPENCL ON CACHE BOOL "Use OpenCL for GPU hit testing")
set(RR_USE_EMBREE OFF CACHE BOOL "Use Intel(R) Embree for CPU hit testing")
set(RR_USE_VULKAN OFF CACHE BOOL "Use vulkan for GPU hit testing")
set(RR_NO_TESTS ON CACHE BOOL "Don't add any unit tests and remove any test functionality from the library")
set(RR_ENABLE_STATIC OFF CACHE BOOL "Create static libraries rather than dynamic")
set(RR_SHARED_CALC OFF CACHE BOOL "Link Calc(compute abstraction layer) dynamically")
set(RR_ENABLE_RAYMASK $BAIKAL_ENABLE_RAYMASK CACHE BOOL "Enable ray masking in intersection kernels")
set(RR_TUTORIALS OFF CACHE BOOL "Add tutorials projects")
set(RR_SAFE_MATH OFF CACHE BOOL "use safe math")
# Sanity checks
if (BAIKAL_ENABLE_STANDALONE AND NOT BAIKAL_ENABLE_IO)
message(FATAL_ERROR "BAIKAL_ENABLE_STANDALONE option requires BAIKAL_ENABLE_IO to be turned ON but it is OFF")
endif (BAIKAL_ENABLE_STANDALONE AND NOT BAIKAL_ENABLE_IO)
if (BAIKAL_ENABLE_STANDALONE OR BAIKAL_ENABLE_RPR)
find_package(GLEW REQUIRED)
endif (BAIKAL_ENABLE_STANDALONE OR BAIKAL_ENABLE_RPR)
add_subdirectory(RadeonRays)
add_subdirectory(Baikal)
if (BAIKAL_ENABLE_IO)
if (BAIKAL_ENABLE_FBX)
find_package(FBX_SDK REQUIRED)
endif (BAIKAL_ENABLE_FBX)
add_subdirectory(BaikalIO)
endif (BAIKAL_ENABLE_IO)
if (BAIKAL_GENERATE_DATASET)
if (MSVC)
add_compile_options(/DGENERATE_DATASET)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MGENERATE_DATASET")
endif()
endif(BAIKAL_GENERATE_DATASET)
if (BAIKAL_ENABLE_RPR)
set(RprSupport_HEADER "${Baikal_SOURCE_DIR}/3rdparty/RprSupport/include/")
add_subdirectory(Rpr)
add_subdirectory(RprSupport)
endif (BAIKAL_ENABLE_RPR)
set (BAIKAL_DLLS
"${Baikal_SOURCE_DIR}/3rdparty/glew/bin/x64/glew32.dll"
"${Baikal_SOURCE_DIR}/3rdparty/glfw/bin/x64/glfw3.dll"
)
if (CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND BAIKAL_DLLS
"${Baikal_SOURCE_DIR}/3rdparty/oiio/bin/x64/OpenImageIOD.dll"
)
else ()
list(APPEND BAIKAL_DLLS
"${Baikal_SOURCE_DIR}/3rdparty/oiio/bin/x64/OpenImageIO.dll"
)
endif ()
add_custom_target(ResourcesDir)
add_custom_target(BaikalKernelsDir)
set(RESOURCES_DIR Resources)
FILE(TO_NATIVE_PATH ${Baikal_SOURCE_DIR}/${RESOURCES_DIR} RESOURCES_SRC)
FILE(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/${RESOURCES_DIR} RESOURCES_DST)
set(BAIKAL_KERNELS_DIR Baikal/Kernels)
FILE(TO_NATIVE_PATH ${Baikal_SOURCE_DIR}/${BAIKAL_KERNELS_DIR} BAIKAL_KERNELS_SRC)
FILE(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/${BAIKAL_KERNELS_DIR} BAIKAL_KERNELS_DST)
if (WIN32)
add_custom_command(TARGET ResourcesDir POST_BUILD
COMMAND IF NOT EXIST ${RESOURCES_DST} mklink /D ${RESOURCES_DST} ${RESOURCES_SRC}
COMMAND IF NOT EXIST ${BAIKAL_KERNELS_DST} mklink /D ${BAIKAL_KERNELS_DST} ${BAIKAL_KERNELS_SRC}
DEPENDS ${RESOURCES_DST} ${BAIKAL_KERNELS_DST}
)
else ()
add_custom_command(TARGET ResourcesDir POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${RESOURCES_SRC} ${RESOURCES_DST}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BAIKAL_KERNELS_SRC} ${BAIKAL_KERNELS_DST}
DEPENDS ${RESOURCES_DST} ${BAIKAL_KERNELS_DST}
)
endif ()
if (BAIKAL_ENABLE_STANDALONE)
set(BAIKALSTANDALONE_DLLS ${BAIKAL_DLLS})
find_package(GLFW3 REQUIRED)
add_subdirectory(BaikalStandalone)
endif (BAIKAL_ENABLE_STANDALONE)
if (BAIKAL_ENABLE_TESTS)
set(BAIKAL_TESTS_DLLS ${BAIKAL_DLLS})
add_subdirectory(Gtest)
add_subdirectory(BaikalTest)
if (BAIKAL_ENABLE_RPR)
add_subdirectory(RprTest)
endif (BAIKAL_ENABLE_RPR)
endif (BAIKAL_ENABLE_TESTS)