OSX - cmake: blenderplayer part 2: Jens Verwiever co-patch
[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 elseif(APPLE)
67         add_executable(blenderplayer MACOSX_BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
68 else()
69         add_executable(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c)
70 endif()
71
72 add_dependencies(blenderplayer makesdna)
73
74 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
75
76 list(APPEND BLENDER_LINK_LIBS
77         ge_player_common
78         ge_player_ghost
79         blenkernel_blc
80 )
81
82 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
83         list(APPEND BLENDER_LINK_LIBS extern_binreloc)
84 endif()
85
86 # if(UNIX)
87         # Sort libraries
88         set(BLENDER_SORTED_LIBS
89                 ge_player_ghost 
90                 ge_player_common 
91                 bf_intern_string 
92                 bf_intern_ghost
93                 bf_rna
94                 bf_blenkernel
95                 bf_blenloader 
96                 bf_blenpluginapi 
97                 ge_blen_routines
98                 bf_editor_datafiles
99                 ge_converter 
100                 ge_logic_ketsji 
101                 ge_phys_bullet 
102                 ge_phys_dummy
103                 ge_phys_common 
104                 ge_logic 
105                 ge_rasterizer 
106                 ge_oglrasterizer 
107                 ge_logic_expressions 
108                 ge_scenegraph
109                 bf_ikplugin
110                 bf_intern_itasc
111                 bf_intern_ik
112                 bf_intern_smoke
113                 bf_modifiers
114                 bf_intern_moto 
115                 bf_nodes
116                 bf_gpu
117                 bf_imbuf
118                 bf_avi 
119                 ge_logic_network 
120                 ge_logic_ngnetwork 
121                 ge_logic_loopbacknetwork 
122                 extern_bullet 
123                 bf_intern_guardedalloc 
124                 bf_intern_memutil 
125                 bf_python_ext
126                 bf_python_mathutils
127                 bf_blenlib 
128                 bf_imbuf_cineon
129                 bf_imbuf_openexr 
130                 extern_openjpeg
131                 extern_redcode
132                 bf_imbuf_dds
133                 bf_dna
134                 ge_videotex
135                 bf_blenfont
136                 bf_intern_audaspace
137                 blenkernel_blc
138                 extern_binreloc
139                 extern_minilzo
140                 bf_intern_ghost # duplicate for linking
141                 bf_blenkernel # duplicate for linking
142                 bf_intern_mikktspace
143                 extern_recastnavigation
144         )
145
146         if(WITH_MOD_CLOTH_ELTOPO)
147                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
148         endif()
149
150         if(WITH_BUILTIN_GLEW)
151                 list(APPEND BLENDER_SORTED_LIBS extern_glew)
152         endif()
153
154         if(WITH_LZMA)
155                 list(APPEND BLENDER_SORTED_LIBS extern_lzma)
156         endif()
157
158         if(WITH_MOD_DECIMATE)
159                 list(APPEND BLENDER_SORTED_LIBS bf_intern_decimate)
160         endif()
161
162         if(WITH_MOD_BOOLEAN)
163                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bsp)
164                 list(APPEND BLENDER_SORTED_LIBS bf_intern_bop)
165                 list(APPEND BLENDER_SORTED_LIBS bf_intern_moto)
166         endif()
167
168         if(WITH_CODEC_QUICKTIME)
169                 list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
170         endif()
171
172         if(WITH_CXX_GUARDEDALLOC)
173                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
174         endif()
175
176         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
177                 set(REMLIB ${SORTLIB})
178                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
179                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
180                                 set(REMLIB "")
181                         endif()
182                 endforeach()
183                 if(REMLIB)
184                         # message(STATUS "Removing library ${REMLIB} from blenderplayer linking because: not configured")
185                         list(APPEND REM_MSG ${REMLIB})
186                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
187                 endif()
188         endforeach()
189         if(REM_MSG)
190                 list(SORT REM_MSG)
191                 message(STATUS "Player Skipping: (${REM_MSG})")
192         endif()
193         target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
194
195         unset(SEARCHLIB)
196         unset(SORTLIB)
197         unset(REMLIB)
198         unset(REM_MSG)
199
200 # else()
201 #       target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
202 # endif()
203
204 if(WITH_PLAYER)
205         add_subdirectory(bad_level_call_stubs)
206 endif()
207
208 setup_liblinks(blenderplayer)