CMakeLists.txt 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. # ***** BEGIN GPL LICENSE BLOCK *****
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # The Original Code is Copyright (C) 2006, Blender Foundation
  18. # All rights reserved.
  19. # ***** END GPL LICENSE BLOCK *****
  20. setup_libdirs()
  21. blender_include_dirs(
  22. ../../intern/clog
  23. ../../intern/glew-mx
  24. ../../intern/guardedalloc
  25. ../blender/blenkernel
  26. ../blender/blenlib
  27. ../blender/blenloader
  28. ../blender/depsgraph
  29. ../blender/editors/include
  30. ../blender/imbuf
  31. ../blender/makesrna
  32. ../blender/render/extern/include
  33. ../blender/gpu
  34. ../blender/makesdna
  35. ../blender/windowmanager
  36. )
  37. set(LIB
  38. bf_blenloader
  39. bf_blenkernel
  40. bf_blenlib
  41. bf_depsgraph
  42. bf_dna
  43. bf_editor_datafiles
  44. bf_imbuf
  45. bf_intern_clog
  46. bf_intern_guardedalloc
  47. bf_intern_memutil
  48. bf_intern_opencolorio
  49. bf_python
  50. bf_render
  51. bf_rna
  52. bf_windowmanager
  53. )
  54. add_definitions(${GL_DEFINITIONS})
  55. blender_include_dirs("${GLEW_INCLUDE_PATH}")
  56. if(WIN32)
  57. blender_include_dirs(../../intern/utfconv)
  58. endif()
  59. if(WITH_LIBMV)
  60. blender_include_dirs(../../intern/libmv)
  61. add_definitions(-DWITH_LIBMV)
  62. endif()
  63. if(WITH_CYCLES)
  64. if(WITH_CYCLES_LOGGING)
  65. blender_include_dirs(../../intern/cycles/blender)
  66. add_definitions(-DWITH_CYCLES_LOGGING)
  67. endif()
  68. list(APPEND LIB
  69. bf_intern_cycles
  70. )
  71. endif()
  72. if(WITH_CODEC_FFMPEG)
  73. add_definitions(-DWITH_FFMPEG)
  74. endif()
  75. if(WITH_PYTHON)
  76. blender_include_dirs(../blender/python)
  77. add_definitions(-DWITH_PYTHON)
  78. if(WITH_PYTHON_SECURITY)
  79. add_definitions(-DWITH_PYTHON_SECURITY)
  80. endif()
  81. endif()
  82. if(WITH_HEADLESS)
  83. add_definitions(-DWITH_HEADLESS)
  84. endif()
  85. if(WITH_SDL)
  86. if(WITH_SDL_DYNLOAD)
  87. blender_include_dirs(../../extern/sdlew/include)
  88. add_definitions(-DWITH_SDL_DYNLOAD)
  89. endif()
  90. add_definitions(-DWITH_SDL)
  91. endif()
  92. if(WITH_BINRELOC)
  93. blender_include_dirs(${BINRELOC_INCLUDE_DIRS})
  94. list(APPEND LIB
  95. extern_binreloc
  96. )
  97. add_definitions(-DWITH_BINRELOC)
  98. endif()
  99. if(WITH_FREESTYLE)
  100. blender_include_dirs(../blender/freestyle)
  101. list(APPEND LIB
  102. bf_freestyle
  103. )
  104. add_definitions(-DWITH_FREESTYLE)
  105. endif()
  106. # Setup the exe sources and buildinfo
  107. set(SRC
  108. creator.c
  109. creator_args.c
  110. creator_signals.c
  111. creator_intern.h
  112. )
  113. # MSVC 2010 gives linking errors with the manifest
  114. if(WIN32 AND NOT UNIX)
  115. string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
  116. string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
  117. string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
  118. add_definitions(
  119. -DBLEN_VER_RC_STR=${BLENDER_VERSION}
  120. -DBLEN_VER_RC_1=${bver1}
  121. -DBLEN_VER_RC_2=${bver2}
  122. -DBLEN_VER_RC_3=${bver3}
  123. -DBLEN_VER_RC_4=0
  124. )
  125. list(APPEND SRC
  126. ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc
  127. )
  128. endif()
  129. if(WITH_BUILDINFO)
  130. add_definitions(-DWITH_BUILDINFO)
  131. # --------------------------------------------------------------------------
  132. # These defines could all be moved into the header below
  133. string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
  134. string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
  135. string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
  136. add_definitions(
  137. # # define in header now, else these get out of date on rebuilds.
  138. # -DBUILD_DATE="${BUILD_DATE}"
  139. # -DBUILD_TIME="${BUILD_TIME}"
  140. # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}"
  141. # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}"
  142. # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}"
  143. # -DBUILD_HASH="${BUILD_HASH}"
  144. # -DBUILD_BRANCH="${BUILD_BRANCH}"
  145. -DWITH_BUILDINFO_HEADER # alternative to lines above
  146. -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
  147. -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
  148. -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
  149. -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
  150. -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
  151. -DBUILD_SYSTEM="CMake"
  152. )
  153. # --------------------------------------------------------------------------
  154. # write header for values that change each build
  155. # note, generaed file is in build dir's source/creator
  156. # except when used as an include path.
  157. # include the output directory, where the buildinfo.h file is generated
  158. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  159. # XXX, ${buildinfo_h_fake} is used here,
  160. # because we rely on that file being detected as missing
  161. # every build so that the real header "buildinfo.h" is updated.
  162. #
  163. # Keep this until we find a better way to resolve!
  164. set(buildinfo_h_real "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h")
  165. set(buildinfo_h_fake "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h_fake")
  166. if(EXISTS ${buildinfo_h_fake})
  167. message(FATAL_ERROR "File \"${buildinfo_h_fake}\" found, this should never be created, remove!")
  168. endif()
  169. # a custom target that is always built
  170. add_custom_target(buildinfo ALL
  171. DEPENDS ${buildinfo_h_fake})
  172. # creates buildinfo.h using cmake script
  173. add_custom_command(
  174. OUTPUT
  175. ${buildinfo_h_fake} # ensure we always run
  176. ${buildinfo_h_real}
  177. COMMAND ${CMAKE_COMMAND}
  178. -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
  179. # overrides only used when non-empty strings
  180. -DBUILD_DATE=${BUILDINFO_OVERRIDE_DATE}
  181. -DBUILD_TIME=${BUILDINFO_OVERRIDE_TIME}
  182. -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
  183. # buildinfo.h is a generated file
  184. set_source_files_properties(
  185. ${buildinfo_h_real}
  186. PROPERTIES GENERATED TRUE
  187. HEADER_FILE_ONLY TRUE)
  188. unset(buildinfo_h_real)
  189. unset(buildinfo_h_fake)
  190. # add deps below, after adding blender
  191. # -------------- done with header values.
  192. list(APPEND SRC
  193. buildinfo.c
  194. )
  195. # make an object library so can load with it in tests
  196. add_library(buildinfoobj OBJECT buildinfo.c)
  197. add_dependencies(buildinfoobj buildinfo)
  198. endif()
  199. add_cc_flags_custom_test(blender)
  200. # message(STATUS "Configuring blender")
  201. if(WITH_PYTHON_MODULE)
  202. add_definitions(-DWITH_PYTHON_MODULE)
  203. # creates ./bin/bpy.so which can be imported as a python module.
  204. #
  205. # note that 'SHARED' works on Linux and Windows,
  206. # but not OSX which _must_ be 'MODULE'
  207. add_library(blender MODULE ${SRC})
  208. set_target_properties(
  209. blender
  210. PROPERTIES
  211. PREFIX ""
  212. OUTPUT_NAME bpy
  213. LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
  214. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin # only needed on windows
  215. )
  216. if(APPLE)
  217. set_target_properties(
  218. blender
  219. PROPERTIES
  220. MACOSX_BUNDLE TRUE
  221. LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
  222. LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
  223. )
  224. endif()
  225. if(WIN32)
  226. # python modules use this
  227. set_target_properties(
  228. blender
  229. PROPERTIES
  230. SUFFIX ".pyd"
  231. )
  232. endif()
  233. else()
  234. add_executable(blender ${EXETYPE} ${SRC})
  235. WINDOWS_SIGN_TARGET(blender)
  236. endif()
  237. if(WITH_BUILDINFO)
  238. # explicitly say that the executable depends on the buildinfo
  239. add_dependencies(blender buildinfo)
  240. endif()
  241. set(BLENDER_TEXT_FILES
  242. ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
  243. ${CMAKE_SOURCE_DIR}/release/text/GPL3-license.txt
  244. ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
  245. # generate this file
  246. # ${CMAKE_SOURCE_DIR}/release/text/readme.html
  247. ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bfont.ttf.txt
  248. )
  249. if(WITH_PYTHON)
  250. list(APPEND BLENDER_TEXT_FILES
  251. ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
  252. )
  253. endif()
  254. if(WITH_OPENCOLORIO)
  255. list(APPEND BLENDER_TEXT_FILES
  256. ${CMAKE_SOURCE_DIR}/release/text/ocio-license.txt
  257. )
  258. endif()
  259. if(WITH_MEM_JEMALLOC)
  260. list(APPEND BLENDER_TEXT_FILES
  261. ${CMAKE_SOURCE_DIR}/release/text/jemalloc-license.txt
  262. )
  263. endif()
  264. if(WITH_INTERNATIONAL)
  265. list(APPEND BLENDER_TEXT_FILES
  266. ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-droidsans.ttf.txt
  267. ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bmonofont-i18n.ttf.txt
  268. )
  269. endif()
  270. # -----------------------------------------------------------------------------
  271. # Platform Specific Var: TARGETDIR_VER
  272. if(UNIX AND NOT APPLE)
  273. if(WITH_PYTHON_MODULE)
  274. if(WITH_INSTALL_PORTABLE)
  275. set(TARGETDIR_VER ${BLENDER_VERSION})
  276. else()
  277. set(TARGETDIR_VER ${PYTHON_SITE_PACKAGES}/${BLENDER_VERSION})
  278. endif()
  279. else()
  280. if(WITH_INSTALL_PORTABLE)
  281. set(TARGETDIR_VER ${BLENDER_VERSION})
  282. else()
  283. set(TARGETDIR_VER share/blender/${BLENDER_VERSION})
  284. endif()
  285. endif()
  286. elseif(WIN32)
  287. set(TARGETDIR_VER ${BLENDER_VERSION})
  288. elseif(APPLE)
  289. if(WITH_PYTHON_MODULE)
  290. set(TARGETDIR_VER ${BLENDER_VERSION})
  291. else()
  292. set(TARGETDIR_VER Blender.app/Contents/Resources/${BLENDER_VERSION})
  293. endif()
  294. # Skip relinking on cpack / install
  295. set_target_properties(blender PROPERTIES BUILD_WITH_INSTALL_RPATH true)
  296. endif()
  297. # -----------------------------------------------------------------------------
  298. # Install Targets (Generic, All Platforms)
  299. # important to make a clean install each time, else old scripts get loaded.
  300. install(
  301. CODE
  302. "file(REMOVE_RECURSE ${TARGETDIR_VER})"
  303. )
  304. if(WITH_PYTHON)
  305. # install(CODE "message(\"copying blender scripts...\")")
  306. # exclude addons_contrib if release
  307. if("${BLENDER_VERSION_CYCLE}" STREQUAL "release" OR
  308. "${BLENDER_VERSION_CYCLE}" STREQUAL "rc")
  309. set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
  310. else()
  311. set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*") # dummy, wont do anything
  312. endif()
  313. # do not install freestyle dir if disabled
  314. if(NOT WITH_FREESTYLE)
  315. set(FREESTYLE_EXCLUDE_CONDITIONAL "freestyle/*")
  316. else()
  317. set(FREESTYLE_EXCLUDE_CONDITIONAL "_freestyle/*") # dummy, wont do anything
  318. endif()
  319. install(
  320. DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
  321. DESTINATION ${TARGETDIR_VER}
  322. PATTERN ".git" EXCLUDE
  323. PATTERN ".gitignore" EXCLUDE
  324. PATTERN ".arcconfig" EXCLUDE
  325. PATTERN "__pycache__" EXCLUDE
  326. PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
  327. PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
  328. )
  329. unset(ADDON_EXCLUDE_CONDITIONAL)
  330. unset(FREESTYLE_EXCLUDE_CONDITIONAL)
  331. endif()
  332. # localization
  333. if(WITH_INTERNATIONAL)
  334. install(
  335. DIRECTORY
  336. ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
  337. DESTINATION ${TARGETDIR_VER}/datafiles
  338. )
  339. set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
  340. set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale)
  341. file(GLOB _po_files "${_locale_dir}/po/*.po")
  342. foreach(_po_file ${_po_files})
  343. msgfmt_simple(${_po_file} _all_mo_files)
  344. endforeach()
  345. # Create a custom target which will compile all po to mo
  346. add_custom_target(
  347. locales
  348. DEPENDS ${_all_mo_files})
  349. add_dependencies(blender locales)
  350. # Generate INSTALL rules
  351. install(
  352. FILES ${_locale_dir}/languages
  353. DESTINATION ${_locale_target_dir}
  354. )
  355. foreach(_mo_file ${_all_mo_files})
  356. get_filename_component(_locale_name ${_mo_file} NAME_WE)
  357. install(
  358. FILES ${_mo_file}
  359. DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES
  360. RENAME blender.mo
  361. )
  362. unset(_locale_name)
  363. endforeach()
  364. unset(_all_mo_files)
  365. unset(_po_files)
  366. unset(_po_file)
  367. unset(_mo_file)
  368. unset(_locale_target_dir)
  369. unset(_locale_dir)
  370. endif()
  371. # color management
  372. if(WITH_OPENCOLORIO)
  373. install(
  374. DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement
  375. DESTINATION ${TARGETDIR_VER}/datafiles
  376. )
  377. endif()
  378. # helpful tip when using make
  379. if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
  380. # message after building.
  381. add_custom_command(
  382. TARGET blender POST_BUILD MAIN_DEPENDENCY blender
  383. COMMAND ${CMAKE_COMMAND} -E
  384. echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
  385. )
  386. endif()
  387. # -----------------------------------------------------------------------------
  388. # Install Targets (Platform Specific)
  389. if(UNIX AND NOT APPLE)
  390. if(NOT WITH_PYTHON_MODULE)
  391. if(WITH_DOC_MANPAGE)
  392. add_custom_target(
  393. blender_man_page ALL
  394. COMMAND ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py
  395. ${EXECUTABLE_OUTPUT_PATH}/blender
  396. ${CMAKE_CURRENT_BINARY_DIR}/blender.1)
  397. add_dependencies(blender_man_page blender)
  398. endif()
  399. endif()
  400. # there are a few differences between portable and system install
  401. if(WITH_PYTHON_MODULE)
  402. if(WITH_INSTALL_PORTABLE)
  403. install(
  404. TARGETS blender
  405. DESTINATION "."
  406. )
  407. else()
  408. install(
  409. TARGETS blender
  410. LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}
  411. )
  412. endif()
  413. # none of the other files are needed currently
  414. elseif(WITH_INSTALL_PORTABLE)
  415. install(
  416. TARGETS blender
  417. DESTINATION "."
  418. )
  419. if(WITH_DOC_MANPAGE)
  420. install(
  421. FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1
  422. DESTINATION "."
  423. )
  424. endif()
  425. install(
  426. FILES
  427. ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
  428. ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
  429. ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/symbolic/apps/blender-symbolic.svg
  430. DESTINATION "."
  431. )
  432. install(
  433. PROGRAMS
  434. ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
  435. DESTINATION "."
  436. )
  437. set(BLENDER_TEXT_FILES_DESTINATION ".")
  438. else()
  439. # main blender binary
  440. install(
  441. TARGETS blender
  442. DESTINATION bin
  443. )
  444. if(WITH_DOC_MANPAGE)
  445. # manpage only with 'blender' binary
  446. install(
  447. FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1
  448. DESTINATION share/man/man1
  449. )
  450. endif()
  451. # misc files
  452. install(
  453. FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
  454. DESTINATION share/applications
  455. )
  456. install(
  457. FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
  458. DESTINATION share/icons/hicolor/scalable/apps
  459. )
  460. install(
  461. FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/symbolic/apps/blender-symbolic.svg
  462. DESTINATION share/icons/hicolor/symbolic/apps
  463. )
  464. install(
  465. PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
  466. DESTINATION bin
  467. )
  468. set(BLENDER_TEXT_FILES_DESTINATION share/doc/blender)
  469. endif()
  470. if(WITH_PYTHON)
  471. if(WITH_PYTHON_INSTALL)
  472. install(
  473. PROGRAMS ${PYTHON_EXECUTABLE}
  474. DESTINATION ${TARGETDIR_VER}/python/bin
  475. )
  476. # on some platforms (like openSUSE) Python is linked
  477. # to be used from lib64 folder.
  478. # determine this from Python's libraries path
  479. #
  480. # ugh, its possible 'lib64' is just a symlink to 'lib' which causes incorrect use of 'lib64'
  481. get_filename_component(_pypath_real ${PYTHON_LIBPATH} REALPATH)
  482. if(${_pypath_real} MATCHES "lib64$")
  483. set(_target_LIB "lib64")
  484. else()
  485. set(_target_LIB "lib")
  486. endif()
  487. unset(_pypath_real)
  488. # Copy the systems python into the install directory
  489. # install(CODE "message(\"copying a subset of the systems python...\")")
  490. install(
  491. DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
  492. DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
  493. PATTERN "__pycache__" EXCLUDE # * any cache *
  494. PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE # static lib
  495. PATTERN "lib2to3" EXCLUDE # ./lib2to3
  496. PATTERN "site-packages/*" EXCLUDE # ./site-packages/*
  497. PATTERN "tkinter" EXCLUDE # ./tkinter
  498. PATTERN "lib-dynload/_tkinter.*" EXCLUDE # ./lib-dynload/_tkinter.co
  499. PATTERN "idlelib" EXCLUDE # ./idlelib
  500. PATTERN "test" EXCLUDE # ./test
  501. PATTERN "turtledemo" EXCLUDE # ./turtledemo
  502. PATTERN "turtle.py" EXCLUDE # ./turtle.py
  503. )
  504. # Needed for distutils/pip
  505. # get the last part of the include dir, will be 'python{version}{abiflag}',
  506. get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
  507. install(
  508. FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
  509. DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
  510. )
  511. unset(_py_inc_suffix)
  512. if(WITH_PYTHON_INSTALL_NUMPY)
  513. # Install to the same directory as the source, so debian-like
  514. # distros are happy with their policy.
  515. set(_suffix "site-packages")
  516. if(${PYTHON_NUMPY_PATH} MATCHES "dist-packages")
  517. set(_suffix "dist-packages")
  518. endif()
  519. install(
  520. DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
  521. DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
  522. PATTERN ".svn" EXCLUDE
  523. PATTERN "__pycache__" EXCLUDE # * any cache *
  524. PATTERN "*.pyc" EXCLUDE # * any cache *
  525. PATTERN "*.pyo" EXCLUDE # * any cache *
  526. PATTERN "oldnumeric" EXCLUDE # ./oldnumeric
  527. PATTERN "doc" EXCLUDE # ./doc
  528. PATTERN "tests" EXCLUDE # ./tests
  529. PATTERN "f2py" EXCLUDE # ./f2py - fortran/python interface code, not for blender.
  530. PATTERN "include" EXCLUDE # include dirs all over, we wont use NumPy/CAPI
  531. PATTERN "*.h" EXCLUDE # some includes are not in include dirs
  532. PATTERN "*.a" EXCLUDE # ./core/lib/libnpymath.a - for linking, we dont need.
  533. )
  534. unset(_suffix)
  535. endif()
  536. # Copy requests, we need to generalize site-packages
  537. if(WITH_PYTHON_INSTALL_REQUESTS)
  538. set(_suffix "site-packages")
  539. if(${PYTHON_REQUESTS_PATH} MATCHES "dist-packages")
  540. set(_suffix "dist-packages")
  541. endif()
  542. install(
  543. DIRECTORY ${PYTHON_REQUESTS_PATH}/requests
  544. DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
  545. PATTERN ".svn" EXCLUDE
  546. PATTERN "__pycache__" EXCLUDE # * any cache *
  547. PATTERN "*.pyc" EXCLUDE # * any cache *
  548. PATTERN "*.pyo" EXCLUDE # * any cache *
  549. )
  550. # On some platforms requests does have extra dependencies.
  551. set(_requests_deps "certifi" "chardet" "idna" "urllib3")
  552. foreach(_requests_dep ${_requests_deps})
  553. if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
  554. install(
  555. DIRECTORY ${PYTHON_REQUESTS_PATH}/${_requests_dep}
  556. DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
  557. PATTERN ".svn" EXCLUDE
  558. PATTERN "__pycache__" EXCLUDE # * any cache *
  559. PATTERN "*.pyc" EXCLUDE # * any cache *
  560. PATTERN "*.pyo" EXCLUDE # * any cache *
  561. )
  562. endif()
  563. endforeach()
  564. if(EXISTS ${PYTHON_REQUESTS_PATH}/six.py)
  565. install(
  566. FILES ${PYTHON_REQUESTS_PATH}/six.py
  567. DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
  568. )
  569. endif()
  570. unset(_requests_dep)
  571. unset(_requests_deps)
  572. unset(_suffix)
  573. endif()
  574. unset(_target_LIB)
  575. endif()
  576. endif()
  577. if(WITH_DRACO)
  578. install(
  579. PROGRAMS $<TARGET_FILE:extern_draco>
  580. DESTINATION ${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}/site-packages
  581. )
  582. endif()
  583. elseif(WIN32)
  584. set(BLENDER_TEXT_FILES_DESTINATION ".")
  585. if(WITH_PYTHON)
  586. string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
  587. if(NOT CMAKE_COMPILER_IS_GNUCC)
  588. install(
  589. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
  590. DESTINATION "."
  591. CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
  592. )
  593. install(
  594. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
  595. DESTINATION "."
  596. CONFIGURATIONS Debug
  597. )
  598. endif()
  599. if(WITH_PYTHON_INSTALL)
  600. # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
  601. install(DIRECTORY DESTINATION ${TARGETDIR_VER}/python)
  602. install(DIRECTORY DESTINATION ${TARGETDIR_VER}/python/lib)
  603. # WARNING: its important that 'CMAKE_INSTALL_CONFIG_NAME' is evaluated at build time
  604. # and _NOT_ configuration time, when modifying the lines below,
  605. # check it works in both Release & Debug mode.
  606. #
  607. # Edit with extreme care! - Campbell
  608. # extract python
  609. install(
  610. CODE
  611. "
  612. message(STATUS \"Extracting Python to: \${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\")
  613. if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")
  614. set(PYTHON_ZIP \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_d.tar.gz\")
  615. else()
  616. set(PYTHON_ZIP \"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}.tar.gz\")
  617. endif()
  618. execute_process(
  619. COMMAND \${CMAKE_COMMAND} -E make_directory
  620. \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\"
  621. COMMAND \${CMAKE_COMMAND} -E
  622. chdir \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\"
  623. \${CMAKE_COMMAND} -E
  624. tar xzfv \"\${PYTHON_ZIP}\"
  625. )
  626. unset(PYTHON_ZIP)
  627. "
  628. )
  629. # release/site-packages
  630. install(
  631. DIRECTORY ${LIBDIR}/release/site-packages
  632. DESTINATION ${BLENDER_VERSION}/python/lib
  633. PATTERN ".svn" EXCLUDE
  634. PATTERN "__pycache__" EXCLUDE # * any cache *
  635. PATTERN "*.pyc" EXCLUDE # * any cache *
  636. PATTERN "*.pyo" EXCLUDE # * any cache *)
  637. )
  638. if(WITH_PYTHON_INSTALL_NUMPY)
  639. set(PYTHON_NUMPY_VERSION 1.15)
  640. add_custom_command(
  641. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy/__init__.py
  642. COMMAND ${CMAKE_COMMAND} -E
  643. tar xzvf "${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$<CONFIG:Debug>:d>.tar.gz"
  644. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
  645. )
  646. add_custom_target(
  647. python_numpy ALL
  648. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy/__init__.py
  649. )
  650. install(
  651. DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
  652. DESTINATION ${BLENDER_VERSION}/python/lib/site-packages
  653. )
  654. endif()
  655. # TODO(sergey): For unti we've got better way to deal with python binary
  656. install(
  657. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
  658. DESTINATION ${BLENDER_VERSION}/python/bin
  659. CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
  660. )
  661. install(
  662. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
  663. DESTINATION ${BLENDER_VERSION}/python/bin
  664. CONFIGURATIONS Debug
  665. )
  666. if(WINDOWS_PYTHON_DEBUG)
  667. install(
  668. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.pdb
  669. DESTINATION "."
  670. CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
  671. )
  672. install(
  673. FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.pdb
  674. DESTINATION "."
  675. CONFIGURATIONS Debug
  676. )
  677. endif()
  678. endif()
  679. unset(_PYTHON_VERSION_NO_DOTS)
  680. endif()
  681. # EGL Runtime Components
  682. if(WITH_GL_EGL)
  683. if(WIN32)
  684. install(FILES "${OPENGLES_DLL}" DESTINATION ".")
  685. install(FILES "${OPENGLES_EGL_DLL}" DESTINATION ".")
  686. if(WITH_GL_ANGLE)
  687. install(FILES "${D3DCOMPILER_DLL}" DESTINATION ".")
  688. endif()
  689. endif()
  690. endif()
  691. if(WITH_CODEC_FFMPEG)
  692. install(
  693. FILES
  694. ${LIBDIR}/ffmpeg/lib/avcodec-58.dll
  695. ${LIBDIR}/ffmpeg/lib/avformat-58.dll
  696. ${LIBDIR}/ffmpeg/lib/avdevice-58.dll
  697. ${LIBDIR}/ffmpeg/lib/avutil-56.dll
  698. ${LIBDIR}/ffmpeg/lib/swscale-5.dll
  699. ${LIBDIR}/ffmpeg/lib/swresample-3.dll
  700. DESTINATION "."
  701. )
  702. endif()
  703. if(WITH_CODEC_SNDFILE)
  704. install(
  705. FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
  706. DESTINATION "."
  707. )
  708. endif()
  709. if(WITH_OPENAL)
  710. install(
  711. FILES
  712. ${LIBDIR}/openal/lib/OpenAL32.dll
  713. DESTINATION "."
  714. )
  715. endif()
  716. if(WITH_SDL)
  717. install(
  718. FILES ${LIBDIR}/sdl/lib/SDL2.dll
  719. DESTINATION "."
  720. )
  721. endif()
  722. if(WITH_SYSTEM_AUDASPACE)
  723. install(
  724. FILES
  725. ${LIBDIR}/audaspace/lib/audaspace.dll
  726. ${LIBDIR}/audaspace/lib/audaspace-c.dll
  727. ${LIBDIR}/audaspace/lib/audaspace-py.dll
  728. DESTINATION "."
  729. )
  730. endif()
  731. if(NOT CMAKE_CL_64)
  732. install(
  733. FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
  734. DESTINATION "."
  735. )
  736. endif()
  737. install( # x86 builds can run on x64 Windows, so this is required at all times
  738. FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
  739. DESTINATION "."
  740. )
  741. install(
  742. FILES
  743. ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu.cmd
  744. ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_gpu_glitchworkaround.cmd
  745. ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_debug_log.cmd
  746. ${CMAKE_SOURCE_DIR}/release/windows/batch/blender_factory_startup.cmd
  747. DESTINATION "."
  748. )
  749. if(WITH_DRACO)
  750. install(
  751. PROGRAMS $<TARGET_FILE:extern_draco>
  752. DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
  753. )
  754. endif()
  755. elseif(APPLE)
  756. # Uppercase name for app bundle
  757. set_target_properties(blender PROPERTIES OUTPUT_NAME Blender)
  758. # handy install macro to exclude files, we use \$ escape for the "to"
  759. # argument when calling so ${BUILD_TYPE} does not get expanded
  760. macro(install_dir from to)
  761. install(
  762. DIRECTORY ${from}
  763. DESTINATION ${to}
  764. PATTERN ".git" EXCLUDE
  765. PATTERN ".svn" EXCLUDE
  766. PATTERN "*.pyc" EXCLUDE
  767. PATTERN "*.pyo" EXCLUDE
  768. PATTERN "*.orig" EXCLUDE
  769. PATTERN "*.rej" EXCLUDE
  770. PATTERN "__pycache__" EXCLUDE
  771. PATTERN "__MACOSX" EXCLUDE
  772. PATTERN ".DS_Store" EXCLUDE
  773. PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE # static lib
  774. PATTERN "lib2to3" EXCLUDE # ./lib2to3
  775. PATTERN "tkinter" EXCLUDE # ./tkinter
  776. PATTERN "lib-dynload/_tkinter.*" EXCLUDE # ./lib-dynload/_tkinter.co
  777. PATTERN "idlelib" EXCLUDE # ./idlelib
  778. PATTERN "test" EXCLUDE # ./test
  779. PATTERN "turtledemo" EXCLUDE # ./turtledemo
  780. PATTERN "turtle.py" EXCLUDE # ./turtle.py
  781. )
  782. endmacro()
  783. set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/Blender.app)
  784. # setup Info.plist
  785. execute_process(COMMAND date "+%Y-%m-%d"
  786. OUTPUT_VARIABLE BLENDER_DATE
  787. OUTPUT_STRIP_TRAILING_WHITESPACE)
  788. set_target_properties(blender PROPERTIES
  789. MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
  790. MACOSX_BUNDLE_SHORT_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR}"
  791. MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR} ${BLENDER_DATE}")
  792. # Gather the date in finder-style
  793. execute_process(COMMAND date "+%m/%d/%Y/%H:%M"
  794. OUTPUT_VARIABLE SETFILE_DATE
  795. OUTPUT_STRIP_TRAILING_WHITESPACE)
  796. # Give the bundle actual creation/modification date
  797. execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
  798. ${EXECUTABLE_OUTPUT_PATH}/Blender.app)
  799. install(
  800. TARGETS blender
  801. DESTINATION "."
  802. )
  803. # install release and app files
  804. set(BLENDER_TEXT_FILES_DESTINATION Blender.app/Contents/Resources/text)
  805. install(
  806. FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
  807. DESTINATION Blender.app/Contents
  808. )
  809. install_dir(
  810. ${OSX_APP_SOURCEDIR}/Contents/Resources
  811. Blender.app/Contents/
  812. )
  813. if(WITH_OPENMP AND OPENMP_CUSTOM)
  814. install(
  815. FILES ${LIBDIR}/openmp/lib/libomp.dylib
  816. DESTINATION Blender.app/Contents/Resources/lib
  817. )
  818. endif()
  819. if(WITH_LLVM AND NOT LLVM_STATIC)
  820. install(
  821. FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib
  822. DESTINATION Blender.app/Contents/MacOS
  823. )
  824. endif()
  825. # python
  826. if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
  827. # Copy the python libs into the install directory
  828. install_dir(
  829. ${PYTHON_LIBPATH}
  830. ${TARGETDIR_VER}/python/lib
  831. )
  832. install(DIRECTORY ${LIBDIR}/python/bin
  833. DESTINATION ${TARGETDIR_VER}/python
  834. USE_SOURCE_PERMISSIONS
  835. )
  836. # Needed for distutils/pip
  837. # get the last part of the include dir, will be 'python{version}{abiflag}',
  838. get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
  839. install(
  840. FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
  841. DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
  842. )
  843. unset(_py_inc_suffix)
  844. endif()
  845. if(WITH_DRACO)
  846. install(
  847. PROGRAMS $<TARGET_FILE:extern_draco>
  848. DESTINATION ${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}/site-packages
  849. )
  850. endif()
  851. endif()
  852. # -----------------------------------------------------------------------------
  853. # Generic Install, for all targets
  854. if(DEFINED BLENDER_TEXT_FILES_DESTINATION)
  855. install(
  856. CODE
  857. "
  858. file(READ \"${CMAKE_SOURCE_DIR}/release/text/readme.html\" DATA_SRC)
  859. string(REGEX REPLACE \"BLENDER_VERSION\" \"${BLENDER_VERSION}\" DATA_DST \"\${DATA_SRC}\")
  860. file(WRITE \"${CMAKE_BINARY_DIR}/release/text/readme.html\" \"\${DATA_DST}\")
  861. unset(DATA_SRC)
  862. unset(DATA_DST)
  863. "
  864. )
  865. list(APPEND BLENDER_TEXT_FILES
  866. ${CMAKE_BINARY_DIR}/release/text/readme.html
  867. )
  868. install(
  869. FILES ${BLENDER_TEXT_FILES}
  870. DESTINATION "${BLENDER_TEXT_FILES_DESTINATION}"
  871. )
  872. endif()
  873. # install more files specified elsewhere
  874. delayed_do_install(${TARGETDIR_VER})
  875. unset(BLENDER_TEXT_FILES)
  876. unset(BLENDER_TEXT_FILES_DESTINATION)
  877. # -----------------------------------------------------------------------------
  878. # Geometry Icons
  879. # Geometry icons.
  880. get_property(_icon_names GLOBAL PROPERTY ICON_GEOM_NAMES)
  881. set(_icon_files)
  882. foreach(_f ${_icon_names})
  883. list(APPEND _icon_files
  884. "${CMAKE_SOURCE_DIR}/release/datafiles/icons/${_f}.dat"
  885. )
  886. endforeach()
  887. install(
  888. FILES ${_icon_files}
  889. DESTINATION ${TARGETDIR_VER}/datafiles/icons
  890. )
  891. unset(_icon_names)
  892. unset(_icon_files)
  893. unset(_f)
  894. # -----------------------------------------------------------------------------
  895. # Studio Lights
  896. install(
  897. DIRECTORY
  898. ${CMAKE_SOURCE_DIR}/release/datafiles/studiolights
  899. DESTINATION ${TARGETDIR_VER}/datafiles
  900. )
  901. # -----------------------------------------------------------------------------
  902. # Setup link libs
  903. add_dependencies(blender makesdna)
  904. target_link_libraries(blender ${LIB})
  905. unset(LIB)
  906. setup_liblinks(blender)
  907. # -----------------------------------------------------------------------------
  908. # Setup launcher
  909. if(WIN32 AND NOT WITH_PYTHON_MODULE)
  910. install(
  911. TARGETS blender
  912. COMPONENT Blender
  913. DESTINATION "."
  914. )
  915. set_target_properties(
  916. blender
  917. PROPERTIES
  918. VS_USER_PROPS "blender.Cpp.user.props"
  919. )
  920. endif()