Adds support for utf paths on Windows.
[blender-staging.git] / source / creator / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 setup_libdirs()
28
29 blender_include_dirs(
30         ../../intern/guardedalloc
31         ../blender/blenlib
32         ../blender/blenkernel
33         ../blender/blenloader
34         ../blender/editors/include
35         ../blender/makesrna
36         ../blender/imbuf
37         ../blender/render/extern/include
38         ../blender/makesdna
39         ../blender/gpu
40         ../blender/windowmanager
41 )
42
43 if(WIN32)
44         blender_include_dirs(../../intern/utfconv)
45 endif()
46
47 if(WITH_LIBMV)
48         blender_include_dirs(../../extern/libmv)
49         add_definitions(-DWITH_LIBMV)
50 endif()
51
52 if(WITH_PYTHON)
53         blender_include_dirs(../blender/python)
54         add_definitions(-DWITH_PYTHON)
55
56         if(WITH_PYTHON_SECURITY)
57                 add_definitions(-DWITH_PYTHON_SECURITY)
58         endif()
59 endif()
60
61 if(WITH_HEADLESS)
62         add_definitions(-DWITH_HEADLESS)
63 endif()
64
65 if(WITH_GAMEENGINE)
66         blender_include_dirs(../gameengine/BlenderRoutines)
67
68         add_definitions(-DWITH_GAMEENGINE)
69 endif()
70
71 if(WITH_SDL)
72         add_definitions(-DWITH_SDL)
73 endif()
74
75 if(WITH_BINRELOC)
76         add_definitions(-DWITH_BINRELOC)
77         blender_include_dirs(${BINRELOC_INCLUDE_DIRS})
78 endif()
79
80 # Setup the exe sources and buildinfo
81 set(SRC
82         creator.c
83 )
84
85 # MSVC 2010 gives linking errors with the manifest
86 if(WIN32 AND NOT UNIX)
87         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
88         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
89         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
90         if(MINGW)
91                 add_definitions(
92                         -DWINDRES
93                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
94                         -DBLEN_VER_RC_1=${bver1}
95                         -DBLEN_VER_RC_2=${bver2}
96                         -DBLEN_VER_RC_3=${bver3}
97                         -DBLEN_VER_RC_4=0
98                 )
99         else()
100                 add_definitions(
101                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
102                         -DBLEN_VER_RC_1=${bver1}
103                         -DBLEN_VER_RC_2=${bver2}
104                         -DBLEN_VER_RC_3=${bver3}
105                         -DBLEN_VER_RC_4=0
106                 )
107         endif()
108
109
110         list(APPEND SRC
111                 ../icons/winblender.rc
112         )
113 endif()
114
115 if(WITH_BUILDINFO)
116         add_definitions(-DWITH_BUILDINFO)
117         # --------------------------------------------------------------------------
118         # These defines could all be moved into the header below
119         string(REPLACE " " "\ " BUILDINFO_CFLAGS "${CMAKE_C_FLAGS}")
120         string(REPLACE " " "\ " BUILDINFO_CXXFLAGS "${CMAKE_CXX_FLAGS}")
121         string(REPLACE " " "\ " BUILDINFO_LINKFLAGS "${PLATFORM_LINKFLAGS}")
122         add_definitions(
123                 # # define in header now, else these get out of date on rebuilds.
124                 # -DBUILD_DATE="${BUILD_DATE}"
125                 # -DBUILD_TIME="${BUILD_TIME}"
126                 # -DBUILD_REV="${BUILD_REV}"
127                 -DWITH_BUILDINFO_HEADER # alternative to lines above
128                 -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}"
129                 -DBUILD_TYPE="${CMAKE_BUILD_TYPE}"
130                 -DBUILD_CFLAGS="${BUILDINFO_CFLAGS}"
131                 -DBUILD_CXXFLAGS="${BUILDINFO_CXXFLAGS}"
132                 -DBUILD_LINKFLAGS="${BUILDINFO_LINKFLAGS}"
133                 -DBUILD_SYSTEM="CMake"
134         )
135
136         # --------------------------------------------------------------------------
137         # write header for values that change each build
138         # note, generaed file is in build dir's source/creator
139         #       except when used as an include path.
140
141         # include the output directory, where the buildinfo.h file is generated
142         include_directories(${CMAKE_BINARY_DIR}/source/creator)
143
144         # a custom target that is always built
145         add_custom_target(buildinfo ALL
146                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h)
147
148         # creates svnheader.h using cmake script
149         add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
150                 COMMAND ${CMAKE_COMMAND}
151                 -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
152                 -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
153
154         # buildinfo.h is a generated file
155         set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/buildinfo.h
156                 PROPERTIES GENERATED TRUE
157                 HEADER_FILE_ONLY TRUE)
158
159         # add deps below, after adding blender
160         # -------------- done with header values.
161
162         list(APPEND SRC
163                 buildinfo.c
164         )
165 endif()
166
167 # message(STATUS "Configuring blender")
168 if(WITH_PYTHON_MODULE)
169         add_definitions(-DWITH_PYTHON_MODULE)
170
171         # creates ./bin/bpy.so which can be imported as a python module.
172         #
173         # note that 'SHARED' works on Linux and Windows,
174         # but not OSX which _must_ be 'MODULE'
175         add_library(blender MODULE ${SRC})
176         set_target_properties(
177                 blender
178                 PROPERTIES
179                         PREFIX ""
180                         OUTPUT_NAME bpy
181                         LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
182                         RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
183         )
184
185         if(APPLE)
186                 set_target_properties(
187                         blender
188                         PROPERTIES
189                                 LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
190                                 LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
191                 )
192         endif()
193
194         if(WIN32)
195                 # python modules use this
196                 set_target_properties(
197                         blender
198                         PROPERTIES
199                         SUFFIX ".pyd"
200                 )
201         endif()
202
203 else()
204         add_executable(blender ${EXETYPE} ${SRC})
205 endif()
206
207 if(WITH_BUILDINFO)
208         # explicitly say that the executable depends on the buildinfo
209         add_dependencies(blender buildinfo)
210 endif()
211
212 # Post build steps for bundling/packaging.
213
214
215 if(MSVC_IDE)
216         # ${CMAKE_CFG_INTDIR} should replace \${BUILD_TYPE} when using add_command
217         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
218 elseif(APPLE)
219         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE})
220 else()
221         set(TARGETDIR ${EXECUTABLE_OUTPUT_PATH})
222 endif()
223
224 set(BLENDER_TEXT_FILES
225         ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
226         ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
227         ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
228         ${CMAKE_SOURCE_DIR}/release/text/readme.html
229 )
230
231
232 # -----------------------------------------------------------------------------
233 # Platform Spesific Var: TARGETDIR_VER
234
235 if(UNIX AND NOT APPLE)
236         if(WITH_INSTALL_PORTABLE)
237                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
238         else()
239                 if(WITH_PYTHON_MODULE)
240                         set(TARGETDIR_VER ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${BLENDER_VERSION})
241                 else()
242                         set(TARGETDIR_VER ${CMAKE_INSTALL_PREFIX}/share/blender/${BLENDER_VERSION})
243                 endif()
244         endif()
245
246 elseif(WIN32)
247         set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
248
249 elseif(APPLE)
250         if(WITH_PYTHON_MODULE)
251                 set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
252         else()
253                 set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
254         endif()
255
256 endif()
257
258
259 # -----------------------------------------------------------------------------
260 # Install Targets (Generic, All Platforms)
261
262
263 # important to make a clean  install each time, else old scripts get loaded.
264 install(
265         CODE
266         "file(REMOVE_RECURSE ${TARGETDIR_VER})"
267 )
268
269 if(WITH_PYTHON)
270         # install(CODE "message(\"copying blender scripts...\")")
271         
272         # exclude addons_contrib if release
273         if("${BLENDER_VERSION_CYCLE}" STREQUAL "release")
274                 set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
275         else()
276                 set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*")  # dummy, wont do anything
277         endif()
278
279         install(
280                 DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
281                 DESTINATION ${TARGETDIR_VER}
282                 PATTERN ".svn" EXCLUDE
283                 PATTERN "__pycache__" EXCLUDE
284                 PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
285         )
286         
287         unset(ADDON_EXCLUDE_CONDITIONAL)
288 endif()
289
290 # localization
291 if(WITH_INTERNATIONAL)
292         install(
293                 DIRECTORY
294                         ${CMAKE_SOURCE_DIR}/release/datafiles/locale
295                         ${CMAKE_SOURCE_DIR}/release/datafiles/fonts
296                 DESTINATION ${TARGETDIR_VER}/datafiles
297                 PATTERN ".svn" EXCLUDE
298         )
299 endif()
300
301 # helpful tip when using make
302 if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
303         # message after building.
304         add_custom_command(
305                 TARGET blender POST_BUILD MAIN_DEPENDENCY blender
306                 COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
307         )
308 endif()
309
310
311 # -----------------------------------------------------------------------------
312 # Install Targets (Platform Specific)
313
314 if(UNIX AND NOT APPLE)
315
316         # there are a few differences between portable and system install
317         if(WITH_INSTALL_PORTABLE)
318                 install(
319                         FILES
320                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
321                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
322                                 ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
323                         DESTINATION ${TARGETDIR}
324                 )
325
326                 install(
327                         PROGRAMS
328                         ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
329                         DESTINATION ${TARGETDIR}
330                 )
331
332                 install(
333                         FILES ${BLENDER_TEXT_FILES}
334                         DESTINATION ${TARGETDIR}
335                 )
336
337         else()
338                 # main blender binary
339                 if(WITH_PYTHON_MODULE)
340                         install(
341                                 TARGETS blender
342                                 LIBRARY
343                                 DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages
344                         )
345                 else()
346                         install(
347                                 PROGRAMS ${TARGETDIR}/blender
348                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
349                         )
350                 endif()
351
352
353                 if(WITH_GAMEENGINE AND WITH_PLAYER)
354                         install(
355                                 PROGRAMS ${TARGETDIR}/blenderplayer
356                                 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
357                         )
358                 endif()
359
360                 # misc files
361                 install(
362                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop
363                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications
364                 )
365                 install(
366                         DIRECTORY
367                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/16x16
368                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/22x22
369                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/24x24
370                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32
371                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48
372                                 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256
373                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor
374                         PATTERN ".svn" EXCLUDE
375                         PATTERN "*.svg" EXCLUDE
376                 )
377                 install(
378                         FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/scalable/apps/blender.svg
379                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps
380                 )
381                 install(
382                         PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py
383                         DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
384                 )
385                 install(
386                         FILES ${CMAKE_SOURCE_DIR}/doc/manpage/blender.1
387                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
388                 )
389                 install(
390                         FILES ${BLENDER_TEXT_FILES}
391                         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender
392                 )
393         endif()
394
395                 # plugins in blender 2.5 don't work at the moment.
396                 #
397                 # install(
398                 #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
399                 #       DESTINATION ${TARGETDIR_VER}
400                 #       PATTERN ".svn" EXCLUDE
401                 # )
402
403         if(WITH_PYTHON)
404                 if(WITH_PYTHON_INSTALL)
405                         # on some platforms (like openSUSE) Python is linked
406                         # to be used from lib64 folder.
407                         # determine this from Python's libraries path
408                         if(${PYTHON_LIBPATH} MATCHES "lib64$")
409                                 set(_target_LIB "lib64")
410                         else()
411                                 set(_target_LIB "lib")
412                         endif()
413
414                         # Copy the systems python into the install directory
415                         # Scons copy in tools/Blender.py
416                         # install(CODE "message(\"copying a subset of the systems python...\")")
417                         install(
418                                 DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
419                                 DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
420                                 PATTERN ".svn" EXCLUDE
421                                 PATTERN "__pycache__" EXCLUDE               # * any cache *
422                                 PATTERN "distutils" EXCLUDE                 # ./distutils
423                                 PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
424                                 PATTERN "config" EXCLUDE                    # ./config
425                                 PATTERN "config-*" EXCLUDE                  # ./config-*
426                                 PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
427                                 PATTERN "tkinter" EXCLUDE                   # ./tkinter
428                                 PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
429                                 PATTERN "idlelib" EXCLUDE                   # ./idlelib
430                                 PATTERN "test" EXCLUDE                      # ./test
431                                 PATTERN "turtledemo" EXCLUDE                # ./turtledemo
432                                 PATTERN "turtle.py" EXCLUDE                                     # ./turtle.py
433                         )
434
435                         # # doesnt work, todo
436                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
437                         unset(_target_LIB)
438                 endif()
439         endif()
440 elseif(WIN32)
441
442         install(
443                 FILES ${BLENDER_TEXT_FILES}
444                 DESTINATION ${TARGETDIR}
445         )
446
447         if(WITH_INTERNATIONAL)
448                 install(
449                         FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
450                         DESTINATION ${TARGETDIR}
451                 )
452
453                 if(NOT CMAKE_CL_64)
454                         install(
455                                 FILES ${LIBDIR}/iconv/lib/iconv.dll
456                                 DESTINATION ${TARGETDIR}
457                         )
458                 endif()
459         endif()
460
461         # plugins in blender 2.5 don't work at the moment.
462         #
463         # install(
464         #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
465         #       DESTINATION ${TARGETDIR_VER}
466         #       PATTERN ".svn" EXCLUDE
467         # )
468
469         if(WITH_PYTHON)
470                 set_lib_path(PYLIB "python/lib")
471                 install(
472                         FILES ${PYLIB}/python32.dll
473                         DESTINATION ${TARGETDIR}
474                         CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
475                 )
476
477                 install(
478                         FILES ${PYLIB}/python32_d.dll
479                         DESTINATION ${TARGETDIR}
480                         CONFIGURATIONS Debug
481                 )
482
483                 if(WITH_PYTHON_INSTALL)
484                         # note, as far as python is concerned 'RelWithDebInfo' is not debug since its without debug flags.
485
486                         # create the directory in multiple steps, so it actually gets created when it doesn't exist yet
487                         install(
488                                 CODE
489                                 "
490                                 message(\"creating ${TARGETDIR_VER}/python/lib\")
491                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\")
492                                 file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\")
493                                 message(\"done creating dir\")
494                                 "
495                         )
496
497                         install(
498                                 CODE
499                                 "
500                                 if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
501                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
502                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\")
503                                 else()
504                                         execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\"
505                                                 \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\")
506                                 endif()
507                                 "
508                         )
509
510                         # doesnt work, todo
511                         # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
512                 endif()
513         endif()
514
515         if(CMAKE_CL_64)
516                 # gettext and png are statically linked on win64
517                 install(
518                         FILES ${LIBDIR}/zlib/lib/zlib.dll
519                         DESTINATION ${TARGETDIR}
520                 )
521         else()
522                 install(
523                         FILES
524                                 ${LIBDIR}/zlib/lib/zlib.dll
525                         DESTINATION ${TARGETDIR}
526                 )
527         endif()
528
529         if(MSVC)
530                 install(
531                         FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
532                         DESTINATION ${TARGETDIR}
533                 )
534         else()
535                 install(
536                         FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
537                         DESTINATION ${TARGETDIR}
538                 )
539         endif()
540
541         if(WITH_CODEC_FFMPEG)
542                 install(
543                         FILES
544                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
545                                 ${LIBDIR}/ffmpeg/lib/avformat-53.dll
546                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
547                                 ${LIBDIR}/ffmpeg/lib/avutil-51.dll
548                                 ${LIBDIR}/ffmpeg/lib/swscale-2.dll
549                         DESTINATION ${TARGETDIR}
550                 )
551
552         endif()
553
554         if(WITH_CODEC_SNDFILE)
555                 install(
556                         FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll
557                         DESTINATION ${TARGETDIR}
558                 )
559         endif()
560
561         if(WITH_OPENAL)
562                 install(
563                         FILES
564                                 ${LIBDIR}/openal/lib/OpenAL32.dll
565                                 ${LIBDIR}/openal/lib/wrap_oal.dll
566                         DESTINATION ${TARGETDIR}
567                 )
568         endif()
569
570         if(WITH_SDL)
571                 if(NOT CMAKE_CL_64)
572                         install(
573                                 FILES ${LIBDIR}/sdl/lib/SDL.dll
574                                 DESTINATION ${TARGETDIR}
575                         )
576                 endif()
577         endif()
578
579         if(NOT CMAKE_CL_64)
580                 install(
581                         FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll
582                         DESTINATION ${TARGETDIR}
583                 )
584         endif()
585                 
586         install( # x86 builds can run on x64 Windows, so this is required at all times
587                 FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
588                 DESTINATION ${TARGETDIR}
589         )       
590
591         if(WITH_OPENIMAGEIO)
592                 set_lib_path(OIIOBIN "openimageio/bin")
593                 install(
594                         FILES
595                                 ${OIIOBIN}/OpenImageIO.dll
596                         DESTINATION ${TARGETDIR}
597                 )
598         endif()
599
600 elseif(APPLE)
601
602         # handy install macro to exclude files, we use \$ escape for the "to"
603         # argument when calling so ${BUILD_TYPE} does not get expanded
604         macro(install_dir from to)
605                 install(
606                         DIRECTORY ${from}
607                         DESTINATION ${to}
608                         PATTERN ".svn" EXCLUDE
609                         PATTERN "*.pyc" EXCLUDE
610                         PATTERN "*.pyo" EXCLUDE
611                         PATTERN "*.orig" EXCLUDE
612                         PATTERN "*.rej" EXCLUDE
613                         PATTERN "__pycache__" EXCLUDE
614                         PATTERN "__MACOSX" EXCLUDE
615                         PATTERN ".DS_Store" EXCLUDE
616                 )
617         endmacro()
618
619         set(OSX_APP_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
620
621         # setup Info.plist
622         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
623
624         set_target_properties(blender PROPERTIES
625                 MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
626                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
627                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
628
629
630         # install release and app files
631         install(
632                 FILES ${BLENDER_TEXT_FILES}
633                 DESTINATION ${TARGETDIR}
634         )
635
636         install(
637                 FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo
638                 DESTINATION ${TARGETDIR}/blender.app/Contents
639         )
640
641         install_dir(
642                 ${OSX_APP_SOURCEDIR}/Contents/Resources
643                 \${TARGETDIR}/blender.app/Contents/
644         )
645
646         # python
647         if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
648                 # the python zip is first extract as part of the build process,
649                 # and then later installed as part of make install. this is much
650                 # quicker, and means we can easily exclude files on copy
651                 # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
652                 add_custom_target(
653                         extractpyzip
654                         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
655
656                 set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
657
658                 add_custom_command(
659                         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
660                         COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
661                         COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
662                         COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
663                         DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
664
665                 add_dependencies(blender extractpyzip)
666
667                 # copy extracted python files
668                 install_dir(
669                         ${CMAKE_CURRENT_BINARY_DIR}/python
670                         \${TARGETDIR_VER}
671                 )
672
673         endif()
674
675         # install blenderplayer bundle - copy of blender.app above. re-using macros et al
676         # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
677         if(WITH_GAMEENGINE AND WITH_PLAYER)
678                 set(OSX_APP_PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
679                 set(PLAYER_SOURCEINFO ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Info.plist)
680                 set(PLAYER_TARGETDIR_VER ${TARGETDIR}/blenderplayer.app/Contents/MacOS/${BLENDER_VERSION})
681
682
683                 # important to make a clean  install each time else old scripts get loaded.
684                 install(
685                         CODE
686                         "file(REMOVE_RECURSE ${PLAYER_TARGETDIR_VER})"
687                 )
688
689                 install(
690                         FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
691                         DESTINATION ${TARGETDIR}/blenderplayer.app/Contents
692                 )
693
694                 install_dir(
695                         ${OSX_APP_PLAYER_SOURCEDIR}/Contents/Resources
696                         \${TARGETDIR}/blenderplayer.app/Contents/
697                 )
698
699                 # python
700                 if(WITH_PYTHON)
701                         add_custom_command(
702                                 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
703                                 COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/
704                                 COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/python/
705                                 COMMAND unzip -q ${LIBDIR}/release/${PYTHON_ZIP} -d ${CMAKE_CURRENT_BINARY_DIR}/python/
706                                 DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
707
708                         # copy extracted python files
709                         install_dir(
710                                 ${CMAKE_CURRENT_BINARY_DIR}/python
711                                 \${PLAYER_TARGETDIR_VER}
712                         )
713                 endif()
714
715         endif()
716 endif()
717
718 # -----------------------------------------------------------------------------
719 # Generic Install, for all targets
720
721
722
723 # install more files specified elsewhere
724 delayed_do_install(${TARGETDIR_VER})
725
726 unset(BLENDER_TEXT_FILES)
727
728
729 # -----------------------------------------------------------------------------
730 # Setup link libs
731
732 add_dependencies(blender makesdna)
733
734 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
735
736 set(BLENDER_LINK_LIBS
737         ${BLENDER_LINK_LIBS}
738         bf_windowmanager
739         bf_render
740 )
741
742 if(WITH_MOD_FLUID)
743         list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem)
744 endif()
745
746 if(WITH_CYCLES)
747         list(APPEND BLENDER_LINK_LIBS
748                 cycles_render
749                 cycles_bvh
750                 cycles_device
751                 cycles_kernel
752                 cycles_util
753                 cycles_subd)
754 endif()
755
756 #if(UNIX)
757         # Sort libraries
758         set(BLENDER_SORTED_LIBS
759                 bf_windowmanager
760
761                 bf_editor_space_api
762                 bf_editor_space_action
763                 bf_editor_space_buttons
764                 bf_editor_space_console
765                 bf_editor_space_file
766                 bf_editor_space_graph
767                 bf_editor_space_image
768                 bf_editor_space_info
769                 bf_editor_space_logic
770                 bf_editor_space_nla
771                 bf_editor_space_node
772                 bf_editor_space_outliner
773                 bf_editor_space_script
774                 bf_editor_space_sequencer
775                 bf_editor_space_time
776                 bf_editor_space_userpref
777                 bf_editor_space_view3d
778                 bf_editor_space_clip
779
780                 bf_editor_text
781                 bf_editor_transform
782                 bf_editor_util
783                 bf_editor_uvedit
784                 bf_editor_curve
785                 bf_editor_armature
786                 bf_editor_gpencil
787                 bf_editor_interface
788                 bf_editor_mesh
789                 bf_editor_metaball
790                 bf_editor_object
791                 bf_editor_physics
792                 bf_editor_render
793                 bf_editor_screen
794                 bf_editor_sculpt_paint
795                 bf_editor_sound
796                 bf_editor_animation
797                 bf_editor_datafiles
798
799                 bf_render
800                 bf_intern_opennl
801                 bf_python
802                 bf_python_ext
803                 bf_python_mathutils
804                 bf_python_bmesh
805                 bf_ikplugin
806                 bf_modifiers
807                 bf_bmesh
808                 bf_blenkernel
809                 bf_nodes
810                 bf_gpu
811                 bf_blenloader
812                 bf_imbuf
813                 bf_blenlib
814                 bf_intern_ghost
815                 bf_intern_string
816                 bf_blenpluginapi
817                 bf_avi
818                 bf_imbuf_cineon
819                 bf_imbuf_openexr
820                 bf_imbuf_dds
821                 bf_collada
822                 bf_intern_bsp
823                 bf_intern_bop
824                 bf_intern_decimate
825                 bf_intern_elbeem
826                 bf_intern_ik
827                 bf_intern_memutil
828                 bf_intern_guardedalloc
829                 bf_intern_ctr
830                 bf_intern_utfconv
831                 ge_blen_routines
832                 ge_converter
833                 ge_phys_dummy
834                 ge_phys_bullet
835                 bf_intern_smoke
836                 extern_minilzo
837                 extern_lzma
838                 extern_colamd
839                 ge_logic_ketsji
840                 extern_recastnavigation
841                 ge_phys_common
842                 ge_logic
843                 ge_rasterizer
844                 ge_oglrasterizer
845                 ge_logic_expressions
846                 ge_scenegraph
847                 ge_logic_network
848                 ge_logic_ngnetwork
849                 extern_bullet
850                 ge_logic_loopbacknetwork
851                 bf_intern_moto
852                 extern_openjpeg
853                 extern_redcode
854                 ge_videotex
855                 bf_rna
856                 bf_dna
857                 bf_blenfont
858                 bf_intern_audaspace
859                 bf_intern_mikktspace
860                 bf_intern_dualcon
861                 bf_intern_cycles
862                 cycles_render
863                 cycles_bvh
864                 cycles_device
865                 cycles_kernel
866                 cycles_util
867                 cycles_subd
868         )
869
870         if(WITH_LIBMV)
871                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
872         endif()
873
874         if(WITH_MOD_CLOTH_ELTOPO)
875                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
876         endif()
877
878         if(WITH_BUILTIN_GLEW)
879                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
880         endif()
881
882         if(WITH_BINRELOC)
883                 list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
884         endif()
885
886         if(WITH_CXX_GUARDEDALLOC)
887                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
888         endif()
889
890         if(WITH_IK_ITASC)
891                 list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
892         endif()
893
894         if(WITH_CODEC_QUICKTIME)
895                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
896         endif()
897
898         if(WITH_CARVE)
899                 list(APPEND BLENDER_SORTED_LIBS extern_carve)
900         endif()
901
902         if(WITH_GHOST_XDND)
903                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
904         endif()
905
906         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
907                 set(REMLIB ${SORTLIB})
908                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
909                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
910                                 set(REMLIB "")
911                         endif()
912                 endforeach()
913                 if(REMLIB)
914                         # message(STATUS "Removing library ${REMLIB} from blender linking because: not configured")
915                         list(APPEND REM_MSG ${REMLIB})
916                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
917                 endif()
918         endforeach()
919         if(REM_MSG)
920                 list(SORT REM_MSG)
921                 message(STATUS "Blender Skipping: (${REM_MSG})")
922         endif()
923         target_link_libraries(blender ${BLENDER_SORTED_LIBS})
924
925         unset(SEARCHLIB)
926         unset(SORTLIB)
927         unset(REMLIB)
928         unset(REM_MSG)
929
930 #else()
931 #       target_link_libraries(blender ${BLENDER_LINK_LIBS})
932 #endif()
933
934 setup_liblinks(blender)