svn merge ^/trunk/blender -r42333:42361
[blender.git] / source / blenderplayer / 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 # message(STATUS "Configuring blenderplayer")
28
29 setup_libdirs()
30
31 if(WITH_CODEC_QUICKTIME)
32         add_definitions(-DWITH_QUICKTIME)
33 endif()
34
35 add_custom_command(
36         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c
37         COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/
38         DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna
39 )
40
41 if(WIN32 AND NOT UNIX)
42         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
43         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
44         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
45         if(MINGW)
46                 add_definitions(
47                         -DWINDRES
48                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
49                         -DBLEN_VER_RC_1=${bver1}
50                         -DBLEN_VER_RC_2=${bver2}
51                         -DBLEN_VER_RC_3=${bver3}
52                         -DBLEN_VER_RC_4=0
53                 )
54         else()
55                 add_definitions(
56                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
57                         -DBLEN_VER_RC_1=${bver1}
58                         -DBLEN_VER_RC_2=${bver2}
59                         -DBLEN_VER_RC_3=${bver3}
60                         -DBLEN_VER_RC_4=0
61                 )
62         endif()
63
64         add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc)
65
66 elseif(APPLE)
67         add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
68         # setup Info.plist
69         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
70         set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
71         set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
72         set_target_properties(blenderplayer PROPERTIES
73                 MACOSX_BUNDLE_INFO_PLIST ${PLAYER_SOURCEINFO}
74                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
75                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
76
77 else()
78         add_executable(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
79 endif()
80
81 add_dependencies(blenderplayer makesdna)
82
83 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
84
85 list(APPEND BLENDER_LINK_LIBS
86         ge_player_common
87         ge_player_ghost
88         blenkernel_blc
89 )
90
91 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
92         list(APPEND BLENDER_LINK_LIBS extern_binreloc)
93 endif()
94
95 # if(UNIX)
96         # Sort libraries
97         set(BLENDER_SORTED_LIBS
98                 ge_player_ghost 
99                 ge_player_common 
100                 bf_intern_string 
101                 bf_intern_ghost
102                 bf_rna
103                 bf_bmesh
104                 bf_blenkernel
105                 bf_blenloader 
106                 bf_blenpluginapi 
107                 ge_blen_routines
108                 bf_editor_datafiles
109                 ge_converter 
110                 ge_logic_ketsji 
111                 ge_phys_bullet 
112                 ge_phys_dummy
113                 ge_phys_common 
114                 ge_logic 
115                 ge_rasterizer 
116                 ge_oglrasterizer 
117                 ge_logic_expressions 
118                 ge_scenegraph
119                 bf_ikplugin
120                 bf_intern_itasc
121                 bf_intern_ik
122                 bf_intern_smoke
123                 bf_modifiers
124                 bf_intern_moto 
125                 bf_nodes
126                 bf_gpu
127                 bf_imbuf
128                 bf_avi 
129                 ge_logic_network 
130                 ge_logic_ngnetwork 
131                 ge_logic_loopbacknetwork 
132                 extern_bullet 
133                 bf_intern_guardedalloc 
134                 bf_intern_memutil 
135                 bf_python_ext
136                 bf_python_mathutils
137                 bf_blenlib 
138                 bf_imbuf_cineon
139                 bf_imbuf_openexr 
140                 extern_openjpeg
141                 extern_redcode
142                 bf_imbuf_dds
143                 bf_dna
144                 ge_videotex
145                 bf_blenfont
146                 bf_intern_audaspace
147                 blenkernel_blc
148                 bf_bmesh
149                 extern_binreloc
150                 extern_minilzo
151                 bf_intern_ghost # duplicate for linking
152                 bf_blenkernel # duplicate for linking
153                 bf_intern_mikktspace
154                 extern_recastnavigation
155         )
156
157         if(WITH_MOD_CLOTH_ELTOPO)
158                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
159         endif()
160
161         if(WITH_BUILTIN_GLEW)
162                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
163         endif()
164
165         if(WITH_LZMA)
166                 list(APPEND BLENDER_SORTED_LIBS extern_lzma)
167         endif()
168
169         if(WITH_LIBMV)
170                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
171         endif()
172
173         list(APPEND BLENDER_SORTED_LIBS extern_colamd)
174
175         if(WITH_MOD_DECIMATE)
176                 list(APPEND BLENDER_SORTED_LIBS bf_intern_decimate)
177         endif()
178
179         if(WITH_MOD_BOOLEAN)
180                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bsp)
181                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bop)
182                 list(APPEND BLENDER_SORTED_LIBS bf_intern_moto)
183         endif()
184
185         if(WITH_CODEC_QUICKTIME)
186                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
187         endif()
188
189         if(WITH_CXX_GUARDEDALLOC)
190                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
191         endif()
192
193         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
194                 set(REMLIB ${SORTLIB})
195                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
196                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
197                                 set(REMLIB "")
198                         endif()
199                 endforeach()
200                 if(REMLIB)
201                         # message(STATUS "Removing library ${REMLIB} from blenderplayer linking because: not configured")
202                         list(APPEND REM_MSG ${REMLIB})
203                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
204                 endif()
205         endforeach()
206         if(REM_MSG)
207                 list(SORT REM_MSG)
208                 message(STATUS "Player Skipping: (${REM_MSG})")
209         endif()
210         target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
211
212         unset(SEARCHLIB)
213         unset(SORTLIB)
214         unset(REMLIB)
215         unset(REM_MSG)
216
217 # else()
218 #       target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
219 # endif()
220
221 if(WITH_PLAYER)
222         add_subdirectory(bad_level_call_stubs)
223 endif()
224
225 setup_liblinks(blenderplayer)