Merge branch 'master' into blender2.8
[blender.git] / intern / cycles / cmake / external_libs.cmake
1 ###########################################################################
2 # Precompiled libraries tips and hints, for find_package().
3
4 if(CYCLES_STANDALONE_REPOSITORY)
5         if(APPLE OR WIN32)
6                 include(precompiled_libs)
7         endif()
8 endif()
9
10 ###########################################################################
11 # GLUT
12
13 if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
14         set(GLUT_ROOT_PATH ${CYCLES_GLUT})
15
16         find_package(GLUT)
17         message(STATUS "GLUT_FOUND=${GLUT_FOUND}")
18
19         include_directories(
20                 SYSTEM
21                 ${GLUT_INCLUDE_DIR}
22         )
23 endif()
24
25 ###########################################################################
26 # GLEW
27
28 # Workaround for unconventional variable name use in Blender.
29 if(NOT CYCLES_STANDALONE_REPOSITORY)
30         set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}")
31 endif()
32
33 if(WITH_CYCLES_STANDALONE)
34         set(CYCLES_APP_GLEW_LIBRARY ${BLENDER_GLEW_LIBRARIES})
35 endif()
36
37 ###########################################################################
38 # CUDA
39
40 if(WITH_CYCLES_CUDA_BINARIES OR NOT WITH_CUDA_DYNLOAD)
41         find_package(CUDA) # Try to auto locate CUDA toolkit
42         if(CUDA_FOUND)
43                 message(STATUS "CUDA nvcc = ${CUDA_NVCC_EXECUTABLE}")
44         else()
45                 message(STATUS "CUDA compiler not found, disabling WITH_CYCLES_CUDA_BINARIES")
46                 set(WITH_CYCLES_CUDA_BINARIES OFF)
47                 if(NOT WITH_CUDA_DYNLOAD)
48                         message(STATUS "Additionally falling back to dynamic CUDA load")
49                         set(WITH_CUDA_DYNLOAD ON)
50                 endif()
51         endif()
52 endif()
53
54 # Packages which are being found by Blender when building from inside Blender
55 # source code. but which we need to take care of when building Cycles from a
56 # standalone repository
57 if(CYCLES_STANDALONE_REPOSITORY)
58         # PThreads
59         # TODO(sergey): Bloody exception, handled in precompiled_libs.cmake.
60         if(NOT WIN32)
61                 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
62                 find_package(Threads REQUIRED)
63                 set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
64         endif()
65
66         ####
67         # OpenGL
68
69         # TODO(sergey): We currently re-use the same variable name as we use
70         # in Blender. Ideally we need to make it CYCLES_GL_LIBRARIES.
71         find_package(OpenGL REQUIRED)
72         find_package(GLEW REQUIRED)
73         list(APPEND BLENDER_GL_LIBRARIES
74                 "${OPENGL_gl_LIBRARY}"
75                 "${OPENGL_glu_LIBRARY}"
76                 "${GLEW_LIBRARY}"
77         )
78
79         ####
80         # OpenImageIO
81         find_package(OpenImageIO REQUIRED)
82         if(OPENIMAGEIO_PUGIXML_FOUND)
83                 set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
84                 set(PUGIXML_LIBRARIES "")
85         else()
86                 find_package(PugiXML REQUIRED)
87         endif()
88
89         # OIIO usually depends on OpenEXR, so find this library
90         # but don't make it required.
91         find_package(OpenEXR)
92
93         ####
94         # OpenShadingLanguage
95         if(WITH_CYCLES_OSL)
96                 find_package(OpenShadingLanguage REQUIRED)
97                 find_package(LLVM REQUIRED)
98         endif()
99
100         ####
101         # OpenColorIO
102         if(WITH_OPENCOLORIO)
103                 find_package(OpenColorIO REQUIRED)
104         endif()
105
106         ####
107         # Boost
108         set(__boost_packages filesystem regex system thread date_time)
109         if(WITH_CYCLES_NETWORK)
110                 list(APPEND __boost_packages serialization)
111         endif()
112         if(WITH_CYCLES_OSL)
113                 # TODO(sergey): This is because of the way how our precompiled
114                 # libraries works, could be different for someone's else libs..
115                 if(APPLE OR MSVC)
116                         list(APPEND __boost_packages wave)
117                 elseif(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6"))
118                         list(APPEND __boost_packages wave)
119                 endif()
120         endif()
121         find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED)
122         if(NOT Boost_FOUND)
123                 # Try to find non-multithreaded if -mt not found, this flag
124                 # doesn't matter for us, it has nothing to do with thread
125                 # safety, but keep it to not disturb build setups.
126                 set(Boost_USE_MULTITHREADED OFF)
127                 find_package(Boost 1.48 COMPONENTS ${__boost_packages})
128         endif()
129         unset(__boost_packages)
130         set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
131         set(BOOST_LIBRARIES ${Boost_LIBRARIES})
132         set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
133         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
134
135         ####
136         # embree
137         if(WITH_CYCLES_EMBREE)
138                 find_package(embree 3.2.4 REQUIRED)
139         endif()
140
141         ####
142         # Logging
143         if(WITH_CYCLES_LOGGING)
144                 find_package(Glog REQUIRED)
145                 find_package(Gflags REQUIRED)
146         endif()
147
148         unset(_lib_DIR)
149 else()
150         set(LLVM_LIBRARIES ${LLVM_LIBRARY})
151 endif()