cycles: Add an nvrtc based cubin cli compiler.
[blender.git] / intern / cycles / app / CMakeLists.txt
1
2 set(INC
3         ..
4 )
5 set(INC_SYS
6 )
7
8 # NOTE: LIBRARIES contains all the libraries which are common
9 # across release and debug build types, stored in a linking order.
10 set(LIBRARIES
11         cycles_device
12         cycles_kernel
13         cycles_render
14         cycles_bvh
15         cycles_subd
16         cycles_graph
17         cycles_util
18         ${BLENDER_GL_LIBRARIES}
19         ${CYCLES_APP_GLEW_LIBRARY}
20         ${PNG_LIBRARIES}
21         ${JPEG_LIBRARIES}
22         ${ZLIB_LIBRARIES}
23         ${TIFF_LIBRARY}
24         ${PTHREADS_LIBRARIES}
25         extern_clew
26 )
27
28 if(WITH_CUDA_DYNLOAD)
29         list(APPEND LIBRARIES extern_cuew)
30 else()
31         list(APPEND LIBRARIES ${CUDA_CUDA_LIBRARY})
32 endif()
33
34 if(WITH_CYCLES_OSL)
35         list(APPEND LIBRARIES cycles_kernel_osl)
36 endif()
37
38 if(NOT CYCLES_STANDALONE_REPOSITORY)
39         list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc)
40 endif()
41
42 if(WITH_CYCLES_LOGGING)
43         list(APPEND LIBRARIES
44                 ${GLOG_LIBRARIES}
45                 ${GFLAGS_LIBRARIES}
46         )
47 endif()
48
49 if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
50         list(APPEND LIBRARIES ${GLUT_LIBRARIES})
51 endif()
52
53 # Common configuration.
54
55 link_directories(${OPENIMAGEIO_LIBPATH}
56                  ${BOOST_LIBPATH}
57                  ${PNG_LIBPATH}
58                  ${JPEG_LIBPATH}
59                  ${ZLIB_LIBPATH}
60                  ${TIFF_LIBPATH}
61                  ${OPENEXR_LIBPATH})
62
63 add_definitions(${GL_DEFINITIONS})
64
65 include_directories(${INC})
66 include_directories(SYSTEM ${INC_SYS})
67
68 # Make sure given target is linked against proper libraries
69 # which varies across debug and release build types.
70 #
71 # This will also make sure dependencies of that libraries
72 # are sent to the linker after them.
73 #
74 # TODO(sergey): Think of a better place for this?
75 macro(cycles_target_link_libraries target)
76         target_link_libraries(${target} ${LIBRARIES})
77         if(WITH_CYCLES_OSL)
78                 target_link_libraries(${target} ${OSL_LIBRARIES} ${LLVM_LIBRARIES})
79         endif()
80         if(WITH_CYCLES_OPENSUBDIV)
81                 target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
82         endif()
83         target_link_libraries(
84                 ${target}
85                 ${OPENIMAGEIO_LIBRARIES}
86                 ${OPENEXR_LIBRARIES}
87                 ${PUGIXML_LIBRARIES}
88                 ${BOOST_LIBRARIES}
89                 ${CMAKE_DL_LIBS}
90                 ${PLATFORM_LINKLIBS}
91         )
92 endmacro()
93
94 # Application build targets
95
96 if(WITH_CYCLES_STANDALONE)
97         set(SRC
98                 cycles_standalone.cpp
99                 cycles_xml.cpp
100                 cycles_xml.h
101         )
102         add_executable(cycles ${SRC})
103         cycles_target_link_libraries(cycles)
104
105         if(UNIX AND NOT APPLE)
106                 set_target_properties(cycles PROPERTIES INSTALL_RPATH $ORIGIN/lib)
107         endif()
108         unset(SRC)
109 endif()
110
111 if(WITH_CYCLES_NETWORK)
112         set(SRC
113                 cycles_server.cpp
114         )
115         add_executable(cycles_server ${SRC})
116         cycles_target_link_libraries(cycles_server)
117
118         if(UNIX AND NOT APPLE)
119                 set_target_properties(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib)
120         endif()
121         unset(SRC)
122 endif()
123
124 if(WITH_CYCLES_CUBIN_COMPILER)
125         # 32 bit windows is special, nvrtc is not supported on x86, so even
126         # though we are building 32 bit blender a 64 bit cubin_cc will have
127         # to be build to compile the cubins.
128         if(MSVC AND NOT CMAKE_CL_64)
129                 Message("cycles_cubin_cc not supported on x86")
130         else()
131                 set(SRC cycles_cubin_cc.cpp)
132                 set(INC ../../../extern/cuew/include)
133                 add_executable(cycles_cubin_cc ${SRC})
134                 include_directories(${INC})
135                 target_link_libraries(cycles_cubin_cc
136                         extern_cuew
137                         ${OPENIMAGEIO_LIBRARIES}
138                         ${PLATFORM_LINKLIBS}
139                 )
140                 if(NOT CYCLES_STANDALONE_REPOSITORY)
141                         target_link_libraries(cycles_cubin_cc bf_intern_guardedalloc)
142                 endif()
143                 unset(SRC)
144                 unset(INC)
145         endif()
146 endif()