code cleanup:
[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_optimized.cpp
16         kernel.cl
17         kernel.cu
18 )
19
20 set(SRC_HEADERS
21         kernel.h
22         kernel_accumulate.h
23         kernel_attribute.h
24         kernel_bvh.h
25         kernel_camera.h
26         kernel_compat_cpu.h
27         kernel_compat_cuda.h
28         kernel_compat_opencl.h
29         kernel_differential.h
30         kernel_displace.h
31         kernel_emission.h
32         kernel_film.h
33         kernel_globals.h
34         kernel_light.h
35         kernel_math.h
36         kernel_montecarlo.h
37         kernel_object.h
38         kernel_passes.h
39         kernel_path.h
40         kernel_projection.h
41         kernel_random.h
42         kernel_shader.h
43         kernel_textures.h
44         kernel_triangle.h
45         kernel_types.h
46 )
47
48 set(SRC_SVM_HEADERS
49         svm/bsdf.h
50         svm/bsdf_ashikhmin_velvet.h
51         svm/bsdf_diffuse.h
52         svm/bsdf_oren_nayar.h
53         svm/bsdf_microfacet.h
54         svm/bsdf_reflection.h
55         svm/bsdf_refraction.h
56         svm/bsdf_transparent.h
57         svm/bsdf_ward.h
58         svm/bsdf_westin.h
59         svm/emissive.h
60         svm/svm.h
61         svm/svm_attribute.h
62         svm/svm_bsdf.h
63         svm/svm_camera.h
64         svm/svm_closure.h
65         svm/svm_convert.h
66         svm/svm_checker.h
67         svm/svm_brick.h
68         svm/svm_displace.h
69         svm/svm_fresnel.h
70         svm/svm_gamma.h
71         svm/svm_brightness.h
72         svm/svm_geometry.h
73         svm/svm_gradient.h
74         svm/svm_hsv.h
75         svm/svm_image.h
76         svm/svm_invert.h
77         svm/svm_light_path.h
78         svm/svm_magic.h
79         svm/svm_mapping.h
80         svm/svm_math.h
81         svm/svm_mix.h
82         svm/svm_musgrave.h
83         svm/svm_noise.h
84         svm/svm_noisetex.h
85         svm/svm_normal.h
86         svm/svm_ramp.h
87         svm/svm_sepcomb_rgb.h
88         svm/svm_sky.h
89         svm/svm_tex_coord.h
90         svm/svm_texture.h
91         svm/svm_types.h
92         svm/svm_value.h
93         svm/svm_voronoi.h
94         svm/svm_wave.h
95         svm/volume.h
96 )
97
98 set(SRC_UTIL_HEADERS
99         ../util/util_color.h
100         ../util/util_math.h
101         ../util/util_transform.h
102         ../util/util_types.h
103 )
104 # CUDA module
105
106 if(WITH_CYCLES_CUDA_BINARIES)
107         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
108                 set(CUDA_BITS 64)
109         else()
110                 set(CUDA_BITS 32)
111         endif()
112
113         set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_UTIL_HEADERS})
114         set(cuda_cubins)
115
116         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
117                 set(cuda_cubin kernel_${arch}.cubin)
118
119                 add_custom_command(
120                         OUTPUT ${cuda_cubin}
121                         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" --maxrregcount=24 --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
122                         DEPENDS ${cuda_sources})
123
124                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
125                 list(APPEND cuda_cubins ${cuda_cubin})
126         endforeach()
127
128         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
129 endif()
130
131 # OSL module
132
133 if(WITH_CYCLES_OSL)
134         add_subdirectory(osl)
135 endif()
136
137 # CPU module
138
139 include_directories(${INC})
140 include_directories(SYSTEM ${INC_SYS})
141
142 add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_SVM_HEADERS})
143
144 if(WITH_CYCLES_OPTIMIZED_KERNEL)
145         set_source_files_properties(kernel_optimized.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_OPTIMIZED_KERNEL_FLAGS}")
146 endif()
147
148 if(WITH_CYCLES_CUDA)
149         add_dependencies(cycles_kernel cycles_kernel_cuda)
150 endif()
151
152 # OpenCL kernel
153
154 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
155 #add_custom_command(
156 #       OUTPUT ${KERNEL_PREPROCESSED}
157 #       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}
158 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
159 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
160 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
161
162 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
163 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
164 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
165 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
166 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
167