Cycles: svn merge -r41225:41232 ^/trunk/blender
[blender.git] / intern / cycles / kernel / CMakeLists.txt
1
2 set(sources
3         kernel.cpp
4         kernel.cl
5         kernel.cu)
6
7 set(headers
8         kernel.h
9         kernel_bvh.h
10         kernel_camera.h
11         kernel_compat_cpu.h
12         kernel_compat_cuda.h
13         kernel_compat_opencl.h
14         kernel_differential.h
15         kernel_displace.h
16         kernel_emission.h
17         kernel_film.h
18         kernel_globals.h
19         kernel_light.h
20         kernel_math.h
21         kernel_mbvh.h
22         kernel_montecarlo.h
23         kernel_object.h
24         kernel_path.h
25         kernel_qbvh.h
26         kernel_random.h
27         kernel_shader.h
28         kernel_textures.h
29         kernel_triangle.h
30         kernel_types.h)
31
32 set(svm_headers
33         svm/bsdf.h
34         svm/bsdf_ashikhmin_velvet.h
35         svm/bsdf_diffuse.h
36         svm/bsdf_microfacet.h
37         svm/bsdf_reflection.h
38         svm/bsdf_refraction.h
39         svm/bsdf_transparent.h
40         svm/bsdf_ward.h
41         svm/bsdf_westin.h
42         svm/emissive.h
43         svm/svm.h
44         svm/svm_attribute.h
45         svm/svm_blend.h
46         svm/svm_bsdf.h
47         svm/svm_closure.h
48         svm/svm_clouds.h
49         svm/svm_convert.h
50         svm/svm_displace.h
51         svm/svm_distorted_noise.h
52         svm/svm_fresnel.h
53         svm/svm_geometry.h
54         svm/svm_image.h
55         svm/svm_light_path.h
56         svm/svm_magic.h
57         svm/svm_mapping.h
58         svm/svm_marble.h
59         svm/svm_math.h
60         svm/svm_mix.h
61         svm/svm_musgrave.h
62         svm/svm_noise.h
63         svm/svm_noisetex.h
64         svm/svm_sky.h
65         svm/svm_stucci.h
66         svm/svm_tex_coord.h
67         svm/svm_texture.h
68         svm/svm_types.h
69         svm/svm_value.h
70         svm/svm_voronoi.h
71         svm/svm_wood.h
72         svm/volume.h
73         )
74
75 set(util_headers
76         ../util/util_color.h
77         ../util/util_math.h
78         ../util/util_transform.h
79         ../util/util_types.h)
80
81 # CUDA module
82
83 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
84         set(CUDA_BITS 64)
85 else()
86         set(CUDA_BITS 32)
87 endif()
88
89 if(WITH_CYCLES_CUDA)
90         set(cuda_sources kernel.cu ${headers} ${svm_headers})
91         set(cuda_cubins)
92
93         foreach(arch ${CYCLES_CUDA_ARCH})
94                 set(cuda_cubin kernel_${arch}.cubin)
95
96                 add_custom_command(
97                         OUTPUT ${cuda_cubin}
98                         COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu --use_fast_math -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" --maxrregcount=${CYCLES_CUDA_MAXREG} --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
99                         DEPENDS ${cuda_sources})
100
101                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
102                 list(APPEND cuda_cubins ${cuda_cubin})
103         endforeach()
104
105         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
106 endif()
107
108 # OSL module
109
110 if(WITH_CYCLES_OSL)
111         add_subdirectory(osl)
112 endif()
113
114 # CPU module
115
116 include_directories(. ../util osl svm)
117
118 add_library(cycles_kernel ${sources} ${headers} ${svm_headers})
119
120 if(WITH_CYCLES_CUDA)
121         add_dependencies(cycles_kernel cycles_kernel_cuda)
122 endif()
123
124 # OPENCL kernel
125
126 #set(kernel_preprocessed ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
127 #add_custom_command(
128 #       OUTPUT ${kernel_preprocessed}
129 #       COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DWITH_OPENCL -o ${kernel_preprocessed}
130 #       DEPENDS ${kernel_sources} ${util_headers})
131 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${kernel_preprocessed})
132 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${kernel_preprocessed}" ${CYCLES_INSTALL_PATH}/kernel)
133
134 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
135 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
136 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${headers}" ${CYCLES_INSTALL_PATH}/kernel)
137 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${svm_headers}" ${CYCLES_INSTALL_PATH}/kernel/svm)
138 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${util_headers}" ${CYCLES_INSTALL_PATH}/kernel)
139