CMake: Add option to link against system-wide Gflags library
[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(CYCLES_STANDALONE_REPOSITORY)
39         if(WITH_CYCLES_LOGGING)
40                 list(APPEND LIBRARIES
41                         ${GLOG_LIBRARIES}
42                         ${GFLAGS_LIBRARIES}
43                 )
44         endif()
45 else()
46         list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc)
47         if(WITH_CYCLES_LOGGING)
48                 list(APPEND LIBRARIES extern_glog ${GFLAGS_LIBRARIES})
49         endif()
50 endif()
51
52 if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
53         list(APPEND LIBRARIES ${GLUT_LIBRARIES})
54 endif()
55
56 # Common configuration.
57
58 link_directories(${OPENIMAGEIO_LIBPATH}
59                  ${BOOST_LIBPATH}
60                  ${PNG_LIBPATH}
61                  ${JPEG_LIBPATH}
62                  ${ZLIB_LIBPATH}
63                  ${TIFF_LIBPATH}
64                  ${OPENEXR_LIBPATH})
65
66 add_definitions(${GL_DEFINITIONS})
67
68 include_directories(${INC})
69 include_directories(SYSTEM ${INC_SYS})
70
71 # Make sure given target is linked against proper libraries
72 # which varies across debug and release build types.
73 #
74 # This will also make sure dependencies of that libraries
75 # are sent to the linker after them.
76 #
77 # TODO(sergey): Think of a better place for this?
78 macro(cycles_target_link_libraries target)
79         target_link_libraries(${target} ${LIBRARIES})
80         if(WITH_CYCLES_OSL)
81                 target_link_libraries(${target} ${OSL_LIBRARIES} ${LLVM_LIBRARIES})
82         endif()
83         if(WITH_CYCLES_OPENSUBDIV)
84                 target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
85         endif()
86         target_link_libraries(
87                 ${target}
88                 ${OPENIMAGEIO_LIBRARIES}
89                 ${OPENEXR_LIBRARIES}
90                 ${PUGIXML_LIBRARIES}
91                 ${BOOST_LIBRARIES}
92                 ${CMAKE_DL_LIBS}
93                 ${PLATFORM_LINKLIBS}
94         )
95 endmacro()
96
97 # Application build targets
98
99 if(WITH_CYCLES_STANDALONE)
100         set(SRC
101                 cycles_standalone.cpp
102                 cycles_xml.cpp
103                 cycles_xml.h
104         )
105         add_executable(cycles ${SRC})
106         cycles_target_link_libraries(cycles)
107
108         if(UNIX AND NOT APPLE)
109                 set_target_properties(cycles PROPERTIES INSTALL_RPATH $ORIGIN/lib)
110         endif()
111         unset(SRC)
112 endif()
113
114 if(WITH_CYCLES_NETWORK)
115         set(SRC
116                 cycles_server.cpp
117         )
118         add_executable(cycles_server ${SRC})
119         cycles_target_link_libraries(cycles_server)
120
121         if(UNIX AND NOT APPLE)
122                 set_target_properties(cycles_server PROPERTIES INSTALL_RPATH $ORIGIN/lib)
123         endif()
124         unset(SRC)
125 endif()