cfca45600a5e3526758c9849b35b7f65b78a65fe
[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         if(WITH_OPENCOLORIO)
84                 link_directories(${OPENCOLORIO_LIBPATH})
85                 target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
86         endif()
87         target_link_libraries(
88                 ${target}
89                 ${OPENIMAGEIO_LIBRARIES}
90                 ${OPENEXR_LIBRARIES}
91                 ${PUGIXML_LIBRARIES}
92                 ${BOOST_LIBRARIES}
93                 ${CMAKE_DL_LIBS}
94                 ${PLATFORM_LINKLIBS}
95         )
96 endmacro()
97
98 # Application build targets
99
100 if(WITH_CYCLES_STANDALONE)
101         set(SRC
102                 cycles_standalone.cpp
103                 cycles_xml.cpp
104                 cycles_xml.h
105         )
106         add_executable(cycles ${SRC})
107         cycles_target_link_libraries(cycles)
108
109         if(UNIX AND NOT APPLE)
110                 set_target_properties(cycles PROPERTIES INSTALL_RPATH $ORIGIN/lib)
111         endif()
112         unset(SRC)
113 endif()
114
115 if(WITH_CYCLES_NETWORK)
116         set(SRC
117                 cycles_server.cpp
118         )
119         add_executable(cycles_server ${SRC})
120         cycles_target_link_libraries(cycles_server)
121
122         if(UNIX AND NOT APPLE)
123                 set_target_properties(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib)
124         endif()
125         unset(SRC)
126 endif()
127
128 if(WITH_CYCLES_CUBIN_COMPILER)
129         # 32 bit windows is special, nvrtc is not supported on x86, so even
130         # though we are building 32 bit blender a 64 bit cubin_cc will have
131         # to be build to compile the cubins.
132         if(MSVC AND NOT CMAKE_CL_64)
133                 message("Building with CUDA not supported on 32 bit, skipped")
134                 set(WITH_CYCLES_CUDA_BINARIES OFF)
135         else()
136                 set(SRC
137                         cycles_cubin_cc.cpp
138                 )
139                 set(INC
140                         ../../../extern/cuew/include
141                 )
142                 add_executable(cycles_cubin_cc ${SRC})
143                 include_directories(${INC})
144                 target_link_libraries(cycles_cubin_cc
145                         extern_cuew
146                         ${OPENIMAGEIO_LIBRARIES}
147                         ${PLATFORM_LINKLIBS}
148                 )
149                 if(NOT CYCLES_STANDALONE_REPOSITORY)
150                         target_link_libraries(cycles_cubin_cc bf_intern_guardedalloc)
151                 endif()
152                 unset(SRC)
153                 unset(INC)
154         endif()
155 endif()