add BLI_strcpy_rlen, replace strcat, which was used in misleading way.
[blender.git] / intern / cycles / kernel / CMakeLists.txt
1
2 set(INC
3         .
4         ../util
5         osl
6         svm
7 )
8
9 set(INC_SYS
10
11 )
12
13 set(SRC
14         kernel.cpp
15         kernel_sse2.cpp
16         kernel_sse3.cpp
17         kernel.cl
18         kernel.cu
19 )
20
21 set(SRC_HEADERS
22         kernel.h
23         kernel_accumulate.h
24         kernel_bvh.h
25         kernel_bvh_traversal.h
26         kernel_camera.h
27         kernel_compat_cpu.h
28         kernel_compat_cuda.h
29         kernel_compat_opencl.h
30         kernel_curve.h
31         kernel_differential.h
32         kernel_displace.h
33         kernel_emission.h
34         kernel_film.h
35         kernel_globals.h
36         kernel_jitter.h
37         kernel_light.h
38         kernel_math.h
39         kernel_montecarlo.h
40         kernel_object.h
41         kernel_passes.h
42         kernel_path.h
43         kernel_primitive.h
44         kernel_projection.h
45         kernel_random.h
46         kernel_shader.h
47         kernel_subsurface.h
48         kernel_textures.h
49         kernel_triangle.h
50         kernel_types.h
51 )
52
53 set(SRC_CLOSURE_HEADERS
54         closure/bsdf.h
55         closure/bsdf_ashikhmin_velvet.h
56         closure/bsdf_diffuse.h
57         closure/bsdf_diffuse_ramp.h
58         closure/bsdf_microfacet.h
59         closure/bsdf_oren_nayar.h
60         closure/bsdf_phong_ramp.h
61         closure/bsdf_reflection.h
62         closure/bsdf_refraction.h
63         closure/bsdf_toon.h
64         closure/bsdf_transparent.h
65         closure/bsdf_util.h
66         closure/bsdf_ward.h
67         closure/bsdf_westin.h
68         closure/bssrdf.h
69         closure/emissive.h
70         closure/volume.h
71 )
72 set(SRC_SVM_HEADERS
73         svm/svm.h
74         svm/svm_attribute.h
75         svm/svm_camera.h
76         svm/svm_closure.h
77         svm/svm_convert.h
78         svm/svm_checker.h
79         svm/svm_brick.h
80         svm/svm_displace.h
81         svm/svm_fresnel.h
82         svm/svm_wireframe.h
83         svm/svm_wavelength.h
84         svm/svm_gamma.h
85         svm/svm_brightness.h
86         svm/svm_geometry.h
87         svm/svm_gradient.h
88         svm/svm_hsv.h
89         svm/svm_image.h
90         svm/svm_invert.h
91         svm/svm_light_path.h
92         svm/svm_magic.h
93         svm/svm_mapping.h
94         svm/svm_math.h
95         svm/svm_mix.h
96         svm/svm_musgrave.h
97         svm/svm_noise.h
98         svm/svm_noisetex.h
99         svm/svm_normal.h
100         svm/svm_ramp.h
101         svm/svm_sepcomb_rgb.h
102         svm/svm_sky.h
103         svm/svm_tex_coord.h
104         svm/svm_texture.h
105         svm/svm_types.h
106         svm/svm_value.h
107         svm/svm_voronoi.h
108         svm/svm_wave.h
109 )
110
111 set(SRC_UTIL_HEADERS
112         ../util/util_color.h
113         ../util/util_math.h
114         ../util/util_transform.h
115         ../util/util_types.h
116 )
117 # CUDA module
118
119 if(WITH_CYCLES_CUDA_BINARIES)
120         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
121                 set(CUDA_BITS 64)
122         else()
123                 set(CUDA_BITS 32)
124         endif()
125
126         set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
127         set(cuda_cubins)
128
129         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
130                 set(cuda_cubin kernel_${arch}.cubin)
131
132                 if(${arch} MATCHES "sm_1[0-9]")
133                         # sm_1x
134                         set(cuda_arch_flags "--maxrregcount=24 --opencc-options -OPT:Olimit=0")
135                 elseif(${arch} MATCHES "sm_2[0-9]")
136                         # sm_2x
137                         set(cuda_arch_flags "--maxrregcount=24")
138                 else()
139                         # sm_3x
140                         set(cuda_arch_flags "--maxrregcount=32")
141                 endif()
142                 
143                 add_custom_command(
144                         OUTPUT ${cuda_cubin}
145                         COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
146                         DEPENDS ${cuda_sources})
147
148                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
149                 list(APPEND cuda_cubins ${cuda_cubin})
150         endforeach()
151
152         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
153 endif()
154
155 # OSL module
156
157 if(WITH_CYCLES_OSL)
158         add_subdirectory(osl)
159         add_subdirectory(shaders)
160 endif()
161
162 # CPU module
163
164 include_directories(${INC})
165 include_directories(SYSTEM ${INC_SYS})
166
167 add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS})
168
169 if(WITH_CYCLES_OPTIMIZED_KERNEL)
170         set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
171         set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
172 endif()
173
174 if(WITH_CYCLES_CUDA)
175         add_dependencies(cycles_kernel cycles_kernel_cuda)
176 endif()
177
178 # OpenCL kernel
179
180 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
181 #add_custom_command(
182 #       OUTPUT ${KERNEL_PREPROCESSED}
183 #       COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -o ${KERNEL_PREPROCESSED}
184 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
185 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
186 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
187
188 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
189 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
190 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
191 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
192 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
193 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
194