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