Merge trunk up to revision 40611
[blender.git] / source / blenderplayer / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Jacques Beaurain.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 # message(STATUS "Configuring blenderplayer")
29
30 setup_libdirs()
31
32 if(WITH_CODEC_QUICKTIME)
33         add_definitions(-DWITH_QUICKTIME)
34 endif()
35
36 add_custom_command(
37         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c
38         COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/
39         DEPENDS ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna
40 )
41
42 if(WIN32 AND NOT UNIX)
43         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
44         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
45         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
46         if(MINGW)
47                 add_definitions(
48                         -DWINDRES
49                         -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
50                         -DBLEN_VER_RC_1=${bver1}
51                         -DBLEN_VER_RC_2=${bver2}
52                         -DBLEN_VER_RC_3=${bver3}
53                         -DBLEN_VER_RC_4=0
54                 )
55         else()
56                 add_definitions(
57                         -DBLEN_VER_RC_STR=${BLENDER_VERSION}
58                         -DBLEN_VER_RC_1=${bver1}
59                         -DBLEN_VER_RC_2=${bver2}
60                         -DBLEN_VER_RC_3=${bver3}
61                         -DBLEN_VER_RC_4=0
62                 )
63         endif()
64
65         add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc)
66
67 elseif(APPLE)
68         add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
69         # setup Info.plist
70         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
71         set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blenderplayer.app)
72         set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
73         set_target_properties(blenderplayer PROPERTIES
74                 MACOSX_BUNDLE_INFO_PLIST ${PLAYER_SOURCEINFO}
75                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
76                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
77
78 else()
79         add_executable(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
80 endif()
81
82 add_dependencies(blenderplayer makesdna)
83
84 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
85
86 list(APPEND BLENDER_LINK_LIBS
87         ge_player_common
88         ge_player_ghost
89         blenkernel_blc
90 )
91
92 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
93         list(APPEND BLENDER_LINK_LIBS extern_binreloc)
94 endif()
95
96 # if(UNIX)
97         # Sort libraries
98         set(BLENDER_SORTED_LIBS
99                 ge_player_ghost 
100                 ge_player_common 
101                 bf_intern_string 
102                 bf_intern_ghost
103                 bf_rna
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                 extern_binreloc
149                 extern_minilzo
150                 bf_intern_ghost # duplicate for linking
151                 bf_blenkernel # duplicate for linking
152                 bf_intern_mikktspace
153                 extern_recastnavigation
154         )
155
156         if(WITH_MOD_CLOTH_ELTOPO)
157                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
158         endif()
159
160         if(WITH_BUILTIN_GLEW)
161                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
162         endif()
163
164         if(WITH_LZMA)
165                 list(APPEND BLENDER_SORTED_LIBS extern_lzma)
166         endif()
167
168         if(WITH_LIBMV)
169                 list(APPEND BLENDER_SORTED_LIBS extern_libmv)
170         endif()
171
172         list(APPEND BLENDER_SORTED_LIBS extern_colamd)
173
174         if(WITH_MOD_DECIMATE)
175                 list(APPEND BLENDER_SORTED_LIBS bf_intern_decimate)
176         endif()
177
178         if(WITH_MOD_BOOLEAN)
179                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bsp)
180                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bop)
181                 list(APPEND BLENDER_SORTED_LIBS bf_intern_moto)
182         endif()
183
184         if(WITH_CODEC_QUICKTIME)
185                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
186         endif()
187
188         if(WITH_CXX_GUARDEDALLOC)
189                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
190         endif()
191
192         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
193                 set(REMLIB ${SORTLIB})
194                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
195                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
196                                 set(REMLIB "")
197                         endif()
198                 endforeach()
199                 if(REMLIB)
200                         # message(STATUS "Removing library ${REMLIB} from blenderplayer linking because: not configured")
201                         list(APPEND REM_MSG ${REMLIB})
202                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
203                 endif()
204         endforeach()
205         if(REM_MSG)
206                 list(SORT REM_MSG)
207                 message(STATUS "Player Skipping: (${REM_MSG})")
208         endif()
209         target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
210
211         unset(SEARCHLIB)
212         unset(SORTLIB)
213         unset(REMLIB)
214         unset(REM_MSG)
215
216 # else()
217 #       target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
218 # endif()
219
220 if(WITH_PLAYER)
221         add_subdirectory(bad_level_call_stubs)
222 endif()
223
224 setup_liblinks(blenderplayer)