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