Package.cmake 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. set(_thirdparty_dir_default "${PROJECT_SOURCE_DIR}/thirdparty")
  2. if(NOT (APPLE OR WIN32) OR NOT IS_DIRECTORY "${_thirdparty_dir_default}")
  3. set(_thirdparty_dir_default "")
  4. endif()
  5. set(THIRDPARTY_DIRECTORY "${_thirdparty_dir_default}" CACHE PATH
  6. "Optional location of a makepanda-style thirdparty directory. All libraries
  7. located here will be prioritized over system libraries. Useful for
  8. cross-compiling.")
  9. set(THIRDPARTY_DLLS)
  10. if(THIRDPARTY_DIRECTORY)
  11. # This policy is necessary for PackageName_ROOT variables to be respected
  12. if(POLICY CMP0074)
  13. cmake_policy(GET CMP0074 _policy_cmp0074)
  14. endif()
  15. if(NOT _policy_cmp0074 STREQUAL "NEW")
  16. message(FATAL_ERROR
  17. "Your version of CMake is too old; please upgrade or unset THIRDPARTY_DIRECTORY to continue.")
  18. endif()
  19. # Dig up the actual "libs" directory
  20. if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
  21. set(_package_dir "${THIRDPARTY_DIRECTORY}/darwin-libs-a")
  22. # Make sure thirdparty has the first shot, not system frameworks
  23. set(CMAKE_FIND_FRAMEWORK LAST)
  24. elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
  25. set(_package_dir "${THIRDPARTY_DIRECTORY}/ios-libs-arm64")
  26. file(GLOB _python_dirs "${THIRDPARTY_DIRECTORY}/ios-python*-arm64")
  27. # Make sure thirdparty has the first shot, not system frameworks
  28. set(CMAKE_FIND_FRAMEWORK LAST)
  29. list(REVERSE _python_dirs) # Descending order of version
  30. if(NOT DEFINED Python_ROOT)
  31. set(Python_ROOT "${_python_dirs}")
  32. endif()
  33. elseif(WIN32)
  34. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  35. set(_package_dir "${THIRDPARTY_DIRECTORY}/win-libs-vc14-x64")
  36. file(GLOB _python_dirs "${THIRDPARTY_DIRECTORY}/win-python*-x64")
  37. else()
  38. set(_package_dir "${THIRDPARTY_DIRECTORY}/win-libs-vc14")
  39. file(GLOB _python_dirs "${THIRDPARTY_DIRECTORY}/win-python*")
  40. endif()
  41. list(REVERSE _python_dirs) # Descending order of version
  42. if(NOT DEFINED Python_ROOT)
  43. set(Python_ROOT "${_python_dirs}")
  44. endif()
  45. set(BISON_ROOT "${THIRDPARTY_DIRECTORY}/win-util")
  46. set(FLEX_ROOT "${THIRDPARTY_DIRECTORY}/win-util")
  47. else()
  48. message(FATAL_ERROR
  49. "You can't use THIRDPARTY_DIRECTORY on this platform. Unset it to continue.")
  50. endif()
  51. if(NOT EXISTS "${_package_dir}")
  52. message(FATAL_ERROR
  53. "Either your THIRDPARTY_DIRECTORY path does not exist, or it is for the wrong platform.")
  54. endif()
  55. foreach(_Package
  56. ARToolKit
  57. Assimp
  58. Bullet
  59. Cg
  60. Eigen3
  61. FCollada
  62. FFMPEG
  63. FMODEx
  64. Freetype
  65. HarfBuzz
  66. JPEG
  67. LibSquish
  68. ODE
  69. Ogg
  70. OpenAL
  71. OpenEXR
  72. OpenSSL
  73. OpusFile
  74. PNG
  75. SWResample
  76. SWScale
  77. TIFF
  78. VorbisFile
  79. VRPN
  80. ZLIB
  81. )
  82. string(TOLOWER "${_Package}" _package)
  83. string(TOUPPER "${_Package}" _PACKAGE)
  84. # Some packages in the thirdparty dir have different subdirectory names from
  85. # the name of the CMake package
  86. if(_package STREQUAL "cg")
  87. set(_package "nvidiacg")
  88. elseif(_package STREQUAL "eigen3")
  89. set(_package "eigen")
  90. elseif(_package STREQUAL "ogg")
  91. set(_package "vorbis") # It's in the same install dir here
  92. elseif(_package STREQUAL "opusfile")
  93. set(_package "opus")
  94. elseif(_package STREQUAL "libsquish")
  95. set(_package "squish")
  96. elseif(_package STREQUAL "swresample" OR _package STREQUAL "swscale")
  97. set(_package "ffmpeg") # These are also part of FFmpeg
  98. elseif(_package STREQUAL "vorbisfile")
  99. set(_package "vorbis")
  100. endif()
  101. # Set search path
  102. set(${_Package}_ROOT "${_package_dir}/${_package}")
  103. # Set up copying DLLs, if necessary
  104. file(GLOB _dlls "${${_Package}_ROOT}/bin/*.dll")
  105. if(_dlls)
  106. set(_havevar "HAVE_${_PACKAGE}")
  107. set(THIRDPARTY_DLLS_${_havevar} "${_dlls}")
  108. list(APPEND THIRDPARTY_DLLS "${_havevar}")
  109. endif()
  110. endforeach(_Package)
  111. endif()
  112. # This is used to copy the DLLs alongside the output of `package`
  113. function(thirdparty_copy_alongside package)
  114. set(_dlls)
  115. foreach(_havevar ${THIRDPARTY_DLLS})
  116. if(${_havevar})
  117. list(APPEND _dlls ${THIRDPARTY_DLLS_${_havevar}})
  118. endif()
  119. endforeach(_havevar)
  120. if(NOT _dlls)
  121. # Don't try to copy/install nothingness
  122. return()
  123. endif()
  124. add_custom_command(TARGET ${package} POST_BUILD
  125. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  126. ${_dlls} $<TARGET_FILE_DIR:${package}>
  127. )
  128. # Also install the DLLs
  129. install(FILES ${_dlls} DESTINATION ${CMAKE_INSTALL_BINDIR})
  130. endfunction(thirdparty_copy_alongside)
  131. #
  132. # ------------ Python ------------
  133. #
  134. list(APPEND CMAKE_FIND_ROOT_PATH "${_package_dir}" "${_python_dirs}")
  135. set(WANT_PYTHON_VERSION ""
  136. CACHE STRING "Which Python version to seek out for building Panda3D against.")
  137. if(DEFINED _PREV_WANT_PYTHON_VERSION
  138. AND NOT _PREV_WANT_PYTHON_VERSION STREQUAL WANT_PYTHON_VERSION)
  139. # The user changed WANT_PYTHON_VERSION. We need to force FindPython to start
  140. # anew, deleting any variable that was autodetected last time
  141. foreach(_prev_var ${_PREV_PYTHON_VALUES})
  142. string(REPLACE "=" ";" _prev_var "${_prev_var}")
  143. list(GET _prev_var 0 _prev_var_name)
  144. list(GET _prev_var 1 _prev_var_sha1)
  145. string(SHA1 _current_var_sha1 "${${_prev_var_name}}")
  146. if(_prev_var_sha1 STREQUAL _current_var_sha1)
  147. unset(${_prev_var_name} CACHE)
  148. endif()
  149. endforeach(_prev_var)
  150. unset(_PREV_PYTHON_VALUES CACHE)
  151. endif()
  152. if(WANT_PYTHON_VERSION)
  153. # A specific version is requested; ensure we get that specific version
  154. list(APPEND WANT_PYTHON_VERSION "EXACT")
  155. endif()
  156. get_directory_property(_old_cache_vars CACHE_VARIABLES)
  157. if(CMAKE_SYSTEM_NAME MATCHES "iOS")
  158. set(Python_LIBRARY ${Python_ROOT}/lib/libpython3.8.a)
  159. set(Python_INCLUDE_DIR ${Python_ROOT}/include/python3.8)
  160. find_package(Python ${WANT_PYTHON_VERSION} QUIET COMPONENTS Development)
  161. else()
  162. find_package(Python ${WANT_PYTHON_VERSION} QUIET COMPONENTS Interpreter Development)
  163. endif()
  164. if(Python_FOUND)
  165. set(PYTHON_FOUND ON)
  166. set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
  167. set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
  168. set(PYTHON_LIBRARY_DIRS ${Python_LIBRARY_DIRS})
  169. set(PYTHON_VERSION_STRING ${Python_VERSION})
  170. elseif(CMAKE_VERSION VERSION_LESS "3.12")
  171. find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
  172. find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)
  173. if(PYTHONLIBS_FOUND)
  174. set(PYTHON_FOUND ON)
  175. if(NOT PYTHON_VERSION_STRING)
  176. set(PYTHON_VERSION_STRING ${PYTHONLIBS_VERSION_STRING})
  177. endif()
  178. endif()
  179. endif()
  180. if(CMAKE_VERSION VERSION_LESS "3.15")
  181. # CMake versions this old don't provide Python::Module, so we need to hack up
  182. # the variables to ensure no explicit linkage against libpython occurs
  183. if(WIN32)
  184. # Nothing needed here; explicit linkage is appropriate
  185. set(PYTHON_LIBRARY "${Python_LIBRARY}")
  186. set(PYTHON_LIBRARIES ${Python_LIBRARIES})
  187. elseif(APPLE OR UNIX)
  188. # Just unset and let the implicit linkage take over
  189. set(PYTHON_LIBRARY "")
  190. set(PYTHON_LIBRARIES "")
  191. if(APPLE)
  192. # macOS requires this explicit flag on the linker command line to allow the
  193. # references to the Python symbols to resolve at dynamic link time
  194. string(APPEND CMAKE_MODULE_LINKER_FLAGS " -undefined dynamic_lookup")
  195. endif()
  196. else()
  197. # On every other platform, guessing is a bad idea - insist the user upgrade
  198. # their CMake instead.
  199. message(WARNING "For Python support on this platform, please use CMake >= 3.15!")
  200. set(PYTHON_FOUND OFF)
  201. endif()
  202. endif()
  203. package_option(Python
  204. DEFAULT ON
  205. "Enables support for Python. If INTERROGATE_PYTHON_INTERFACE
  206. is also enabled, Python bindings will be generated."
  207. IMPORTED_AS Python::Module)
  208. # Also detect the optimal install paths:
  209. if(HAVE_PYTHON)
  210. if(WIN32 AND NOT CYGWIN)
  211. set(_LIB_DIR ".")
  212. set(_ARCH_DIR ".")
  213. elseif(PYTHON_EXECUTABLE)
  214. execute_process(
  215. COMMAND ${PYTHON_EXECUTABLE}
  216. -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
  217. OUTPUT_VARIABLE _LIB_DIR
  218. OUTPUT_STRIP_TRAILING_WHITESPACE)
  219. execute_process(
  220. COMMAND ${PYTHON_EXECUTABLE}
  221. -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
  222. OUTPUT_VARIABLE _ARCH_DIR
  223. OUTPUT_STRIP_TRAILING_WHITESPACE)
  224. else()
  225. set(_LIB_DIR "")
  226. set(_ARCH_DIR "")
  227. endif()
  228. execute_process(
  229. COMMAND ${PYTHON_EXECUTABLE}
  230. -c "from sysconfig import get_config_var as g; print((g('EXT_SUFFIX') or g('SO'))[:])"
  231. OUTPUT_VARIABLE _EXT_SUFFIX
  232. ERROR_QUIET
  233. OUTPUT_STRIP_TRAILING_WHITESPACE)
  234. if(NOT _EXT_SUFFIX)
  235. if(CYGWIN)
  236. set(_EXT_SUFFIX ".dll")
  237. elseif(WIN32)
  238. set(_EXT_SUFFIX ".pyd")
  239. else()
  240. set(_EXT_SUFFIX ".so")
  241. endif()
  242. endif()
  243. set(PYTHON_LIB_INSTALL_DIR "${_LIB_DIR}" CACHE PATH
  244. "Path to the Python architecture-independent package directory.")
  245. set(PYTHON_ARCH_INSTALL_DIR "${_ARCH_DIR}" CACHE PATH
  246. "Path to the Python architecture-dependent package directory.")
  247. set(PYTHON_EXTENSION_SUFFIX "${_EXT_SUFFIX}" CACHE STRING
  248. "Suffix for Python binary extension modules.")
  249. endif()
  250. if(NOT DEFINED _PREV_PYTHON_VALUES)
  251. # We need to make note of all auto-defined Python variables
  252. set(_prev_python_values)
  253. get_directory_property(_new_cache_vars CACHE_VARIABLES)
  254. foreach(_cache_var ${_new_cache_vars})
  255. if(_cache_var MATCHES "^(Python|PYTHON)_" AND NOT _old_cache_vars MATCHES ";${_cache_var};")
  256. string(SHA1 _cache_var_sha1 "${${_cache_var}}")
  257. list(APPEND _prev_python_values "${_cache_var}=${_cache_var_sha1}")
  258. endif()
  259. endforeach(_cache_var)
  260. set(_PREV_PYTHON_VALUES "${_prev_python_values}" CACHE INTERNAL "Internal." FORCE)
  261. endif()
  262. set(_PREV_WANT_PYTHON_VERSION "${WANT_PYTHON_VERSION}" CACHE INTERNAL "Internal." FORCE)
  263. #
  264. # ------------ Data handling libraries ------------
  265. #
  266. # OpenSSL
  267. find_package(OpenSSL COMPONENTS SSL Crypto QUIET)
  268. package_option(OpenSSL
  269. DEFAULT ON
  270. "Enable OpenSSL support"
  271. IMPORTED_AS OpenSSL::SSL OpenSSL::Crypto)
  272. option(REPORT_OPENSSL_ERRORS
  273. "Define this true to include the OpenSSL code to report verbose
  274. error messages when they occur." OFF)
  275. option(REPORT_OPENSSL_ERRORS_Debug "" ON)
  276. package_status(OpenSSL "OpenSSL")
  277. # zlib
  278. find_package(ZLIB QUIET)
  279. package_option(ZLIB
  280. "Enables support for compression of Panda assets."
  281. IMPORTED_AS ZLIB::ZLIB)
  282. package_status(ZLIB "zlib")
  283. #
  284. # ------------ Image formats ------------
  285. #
  286. # JPEG
  287. find_package(JPEG QUIET)
  288. package_option(JPEG "Enable support for loading .jpg images.")
  289. package_status(JPEG "libjpeg")
  290. # PNG
  291. find_package(PNG QUIET)
  292. package_option(PNG
  293. "Enable support for loading .png images."
  294. IMPORTED_AS PNG::PNG)
  295. package_status(PNG "libpng")
  296. # TIFF
  297. find_package(TIFF QUIET)
  298. package_option(TIFF "Enable support for loading .tif images.")
  299. package_status(TIFF "libtiff")
  300. # OpenEXR
  301. find_package(OpenEXR QUIET MODULE)
  302. package_option(OpenEXR "Enable support for loading .exr images.")
  303. package_status(OpenEXR "OpenEXR")
  304. # libsquish
  305. find_package(LibSquish QUIET)
  306. package_option(SQUISH
  307. "Enables support for automatic compression of DXT textures."
  308. FOUND_AS LibSquish)
  309. package_status(SQUISH "libsquish")
  310. #
  311. # ------------ Asset formats ------------
  312. #
  313. # Assimp
  314. find_package(Assimp QUIET MODULE)
  315. package_option(Assimp
  316. "Build pandatool with support for loading 3D assets supported by Assimp.")
  317. package_status(Assimp "Assimp")
  318. # FCollada
  319. find_package(FCollada QUIET)
  320. package_option(FCollada
  321. "Build pandatool with support for loading Collada files using FCollada."
  322. IMPORTED_AS FCollada::FCollada)
  323. package_status(FCollada "FCollada")
  324. #
  325. # ------------ Math libraries ------------
  326. #
  327. # Eigen
  328. find_package(Eigen3 QUIET)
  329. package_option(EIGEN
  330. "Enables use of the Eigen linear algebra library.
  331. If this is provided, Panda will use this library as the fundamental
  332. implementation of its own linmath library; otherwise, it will use
  333. its own internal implementation. The primary advantage of using
  334. Eigen is SSE2 support, which is only activated if LINMATH_ALIGN
  335. is also enabled."
  336. FOUND_AS Eigen3
  337. LICENSE "MPL-2")
  338. option(LINMATH_ALIGN
  339. "This is required for activating SSE2 support using Eigen.
  340. Activating this does constrain most objects in Panda to 16-byte
  341. alignment, which could impact memory usage on very-low-memory
  342. platforms. Currently experimental." ON)
  343. if(LINMATH_ALIGN)
  344. package_status(EIGEN "Eigen linear algebra library" "vectorization enabled in build")
  345. else()
  346. package_status(EIGEN "Eigen linear algebra library" "vectorization NOT enabled in build")
  347. endif()
  348. # FFTW
  349. # FFTW 3.3.7, when built with autotools, doesn't install
  350. # FFTW3LibraryDepends.cmake, which will crash us if we use CONFIG mode. BAH!
  351. # Force MODULE mode to fix that.
  352. find_package(FFTW3 MODULE QUIET)
  353. package_option(FFTW
  354. "This enables support for compression of animations in .bam files.
  355. This is only necessary for creating or reading .bam files containing
  356. compressed animations."
  357. FOUND_AS "FFTW3"
  358. LICENSE "GPL")
  359. package_status(FFTW "FFTW")
  360. #
  361. # ------------ Multimedia formats ------------
  362. #
  363. # FFmpeg
  364. find_package(FFMPEG QUIET)
  365. find_package(SWScale QUIET)
  366. find_package(SWResample QUIET)
  367. package_option(FFMPEG
  368. "Enables support for audio- and video-decoding using the FFmpeg library.")
  369. package_option(SWScale
  370. "Enables support for FFmpeg's libswscale for video rescaling.")
  371. package_option(SWResample
  372. "Enables support for FFmpeg's libresample for audio resampling.")
  373. if(HAVE_SWSCALE AND HAVE_SWRESAMPLE)
  374. set(ffmpeg_features "with swscale and swresample")
  375. elseif(HAVE_SWSCALE)
  376. set(ffmpeg_features "with swscale")
  377. elseif(HAVE_SWRESAMPLE)
  378. set(ffmpeg_features "with swresample")
  379. else()
  380. set(ffmpeg_features "without resampling/rescaling support")
  381. endif()
  382. package_status(FFMPEG "FFmpeg" "${ffmpeg_features}")
  383. # Vorbis
  384. find_package(VorbisFile QUIET)
  385. package_option(VORBIS
  386. FOUND_AS VorbisFile
  387. "Enables support for decoding Vorbis-encoded .ogg audio files via libvorbisfile.")
  388. package_status(VORBIS "Vorbis")
  389. # Opus
  390. find_package(OpusFile QUIET)
  391. package_option(OPUS
  392. FOUND_AS OpusFile
  393. "Enables support for decoding .opus audio files via libopusfile.")
  394. package_status(OPUS "Opus")
  395. #
  396. # ------------ Audio libraries ------------
  397. #
  398. # FMOD Ex
  399. find_package(FMODEx QUIET)
  400. package_option(FMODEx
  401. "This enables support for the FMOD Ex sound library,
  402. from Firelight Technologies. This audio library is free for non-commercial
  403. use."
  404. LICENSE "FMOD")
  405. package_status(FMODEx "FMOD Ex sound library")
  406. # OpenAL
  407. find_package(OpenAL QUIET)
  408. package_option(OpenAL
  409. "This enables support for audio output via OpenAL. Some platforms, such as
  410. macOS, provide their own OpenAL implementation, which Panda3D can use. But,
  411. on most platforms this will imply OpenAL Soft, which is LGPL licensed."
  412. IMPORTED_AS OpenAL::OpenAL
  413. LICENSE "LGPL")
  414. package_status(OpenAL "OpenAL sound library")
  415. if(OpenAL_FOUND AND APPLE OR OPENAL_FOUND AND APPLE)
  416. set(HAVE_OPENAL_FRAMEWORK YES)
  417. endif()
  418. #
  419. # ------------ UI libraries ------------
  420. #
  421. # Freetype
  422. find_package(Freetype QUIET)
  423. package_option(Freetype
  424. "This enables support for the FreeType font-rendering library. If disabled,
  425. Panda3D will only be able to read fonts specially made with egg-mkfont."
  426. IMPORTED_AS freetype)
  427. package_status(Freetype "FreeType")
  428. # HarfBuzz
  429. # Some versions of harfbuzz-config.cmake contain an endless while loop, so we
  430. # force MODULE mode here.
  431. find_package(HarfBuzz MODULE QUIET)
  432. package_option(HarfBuzz
  433. "This enables support for the HarfBuzz text shaping library."
  434. IMPORTED_AS harfbuzz::harfbuzz)
  435. package_status(HarfBuzz "HarfBuzz")
  436. # GTK2
  437. set(Freetype_FIND_QUIETLY TRUE) # Fix for builtin FindGTK2
  438. set(GTK2_GTK_FIND_QUIETLY TRUE) # Fix for builtin FindGTK2
  439. find_package(GTK2 QUIET COMPONENTS gtk)
  440. package_option(GTK2)
  441. package_status(GTK2 "gtk+-2")
  442. #
  443. # ------------ Physics engines ------------
  444. #
  445. # Bullet
  446. find_package(Bullet MODULE QUIET)
  447. package_option(Bullet
  448. "Enable this option to support game dynamics with the Bullet physics library.")
  449. package_status(Bullet "Bullet physics")
  450. # ODE
  451. find_package(ODE QUIET)
  452. package_option(ODE
  453. "Enable this option to support game dynamics with the Open Dynamics Engine (ODE)."
  454. LICENSE "BSD-3"
  455. IMPORTED_AS ODE::ODE)
  456. package_status(ODE "Open Dynamics Engine")
  457. #
  458. # ------------ SpeedTree ------------
  459. #
  460. # SpeedTree
  461. find_package(SpeedTree QUIET)
  462. package_option(SpeedTree
  463. "Enable this option to include scenegraph support for SpeedTree trees."
  464. LICENSE "SpeedTree")
  465. package_status(SpeedTree "SpeedTree")
  466. #
  467. # ------------ Rendering APIs ------------
  468. #
  469. # OpenGL
  470. find_package(OpenGL QUIET)
  471. package_option(GL
  472. "Enable OpenGL support."
  473. FOUND_AS OPENGL
  474. IMPORTED_AS OpenGL::GL)
  475. package_status(GL "OpenGL")
  476. # OpenGL ES 1
  477. if(NOT APPLE) # Apple X11 ships the GLES headers but they're broken
  478. find_package(OpenGLES1 QUIET)
  479. endif()
  480. package_option(GLES1
  481. "Enable support for OpenGL ES 1.x rendering APIs."
  482. FOUND_AS OPENGLES1)
  483. package_status(GLES1 "OpenGL ES 1.x")
  484. # OpenGL ES 2
  485. if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") # Apple X11 ships the GLES headers but they're broken
  486. find_package(OpenGLES2 QUIET)
  487. endif()
  488. package_option(GLES2
  489. "Enable support for OpenGL ES 2.x rendering APIs."
  490. FOUND_AS OPENGLES2)
  491. package_status(GLES2 "OpenGL ES 2.x")
  492. # Direct3D 9
  493. find_package(Direct3D9 QUIET COMPONENTS dxguid dxerr d3dx9)
  494. package_option(DX9
  495. "Enable support for DirectX 9. This is typically only viable on Windows."
  496. FOUND_AS Direct3D9)
  497. package_status(DX9 "Direct3D 9.x")
  498. # Nvidia Cg
  499. find_package(Cg QUIET)
  500. package_option(CG
  501. "Enable support for Nvidia Cg Shading Language"
  502. LICENSE "Nvidia")
  503. package_option(CGGL
  504. "Enable support for Nvidia Cg's OpenGL API."
  505. LICENSE "Nvidia")
  506. package_option(CGD3D9
  507. "Enable support for Nvidia Cg's Direct3D 9 API."
  508. LICENSE "Nvidia")
  509. if(HAVE_CGGL AND HAVE_CGD3D9)
  510. set(cg_apis "supporting OpenGL and Direct3D 9")
  511. elseif(HAVE_CGGL)
  512. set(cg_apis "supporting OpenGL")
  513. elseif(HAVE_CGDX9)
  514. set(cg_apis "supporting Direct3D 9")
  515. else()
  516. set(cg_apis "WITHOUT rendering backend support")
  517. endif()
  518. package_status(CG "Nvidia Cg Shading Language" "${cg_apis}")
  519. #
  520. # ------------ Display APIs ------------
  521. #
  522. # X11 (and GLX)
  523. if(NOT APPLE)
  524. find_package(X11 QUIET)
  525. endif()
  526. if(NOT X11_Xkb_FOUND OR NOT X11_Xutil_FOUND)
  527. # Panda implicitly requires these supplementary X11 libs; if we can't find
  528. # them, we just say we didn't find X11 at all.
  529. set(X11_FOUND OFF)
  530. endif()
  531. package_option(X11
  532. "Provides X-server support on Unix platforms. X11 may need to be linked
  533. against for tinydisplay, but probably only on a Linux platform.")
  534. set(HAVE_GLX_AVAILABLE OFF)
  535. if(HAVE_GL AND HAVE_X11 AND NOT APPLE)
  536. set(HAVE_GLX_AVAILABLE ON)
  537. endif()
  538. option(HAVE_GLX "Enables GLX. Requires OpenGL and X11." ${HAVE_GLX_AVAILABLE})
  539. if(HAVE_GLX AND NOT HAVE_GLX_AVAILABLE)
  540. message(SEND_ERROR "HAVE_GLX manually set to ON but it is not available!")
  541. endif()
  542. if(HAVE_GLX)
  543. package_status(X11 "X11" "with GLX")
  544. else()
  545. package_status(X11 "X11" "without GLX")
  546. endif()
  547. # EGL
  548. find_package(EGL QUIET)
  549. package_option(EGL
  550. "Enable support for the Khronos EGL context management interface for
  551. OpenGL ES. This is necessary to support OpenGL ES under X11.")
  552. package_status(EGL "EGL")
  553. #
  554. # ------------ Vision tools ------------
  555. #
  556. # OpenCV
  557. find_package(OpenCV QUIET COMPONENTS core highgui OPTIONAL_COMPONENTS videoio)
  558. package_option(OpenCV
  559. "Enable support for OpenCV. This will be built into the 'vision' package."
  560. FOUND_AS OpenCV)
  561. package_status(OpenCV "OpenCV")
  562. # CMake <3.7 doesn't support GREATER_EQUAL, so this uses NOT LESS instead.
  563. if(NOT OpenCV_VERSION_MAJOR LESS 3)
  564. set(OPENCV_VER_3 ON)
  565. elseif(NOT OpenCV_VERSION_MAJOR LESS 2 AND
  566. NOT OpenCV_VERSION_MINOR LESS 3)
  567. set(OPENCV_VER_23 ON)
  568. endif()
  569. # ARToolKit
  570. find_package(ARToolKit QUIET)
  571. package_option(ARToolKit
  572. "Enable support for ARToolKit. This will be built into the 'vision' package.")
  573. package_status(ARToolKit "ARToolKit")
  574. #
  575. # ------------ VR integration ------------
  576. #
  577. # VRPN
  578. find_package(VRPN QUIET)
  579. package_option(VRPN
  580. "Enables support for connecting to VRPN servers. This is only needed if you
  581. are building Panda3D for a fixed VRPN-based VR installation.")
  582. package_status(VRPN "VRPN")