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