external_libs.cmake 4.2 KB

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