merge from master
[blender.git] / source / blenderplayer / CMakeLists.txt
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2006, Blender Foundation
18 # All rights reserved.
19 #
20 # The Original Code is: all of this file.
21 #
22 # Contributor(s): Jacques Beaurain.
23 #
24 # ***** END GPL LICENSE BLOCK *****
25
26 # message(STATUS "Configuring blenderplayer")
27
28 setup_libdirs()
29
30 if(WIN32 AND NOT UNIX)
31         string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
32         string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
33         string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
34         add_definitions(
35                 -DBLEN_VER_RC_STR=${BLENDER_VERSION}
36                 -DBLEN_VER_RC_1=${bver1}
37                 -DBLEN_VER_RC_2=${bver2}
38                 -DBLEN_VER_RC_3=${bver3}
39                 -DBLEN_VER_RC_4=0
40         )
41
42         add_executable(
43                         blenderplayer ${EXETYPE}
44                         bad_level_call_stubs/stubs.c
45                         ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc)
46         WINDOWS_SIGN_TARGET(blenderplayer)
47         install(TARGETS blenderplayer
48                         COMPONENT Blenderplayer
49                         DESTINATION ".")
50
51 add_cc_flags_custom_test(blenderplayer)
52
53 elseif(APPLE)
54         add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c)
55         # setup Info.plist
56         execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
57         set(PLAYER_SOURCEDIR ${CMAKE_SOURCE_DIR}/release/darwin/blenderplayer.app)
58         set(PLAYER_SOURCEINFO ${PLAYER_SOURCEDIR}/Contents/Info.plist)
59         set_target_properties(blenderplayer PROPERTIES
60                 MACOSX_BUNDLE_INFO_PLIST ${PLAYER_SOURCEINFO}
61                 MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
62                 MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
63
64 else()
65         add_executable(blenderplayer bad_level_call_stubs/stubs.c)
66
67         if(NOT WITH_INSTALL_PORTABLE)
68                 install(
69                         TARGETS blenderplayer
70                         DESTINATION bin
71                 )
72         else()
73                 install(
74                         TARGETS blenderplayer
75                         DESTINATION "."
76                 )
77         endif()
78 endif()
79
80 add_dependencies(blenderplayer makesdna)
81
82 get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
83
84 list(APPEND BLENDER_LINK_LIBS
85         ge_player_common
86         ge_player_ghost
87         blenkernel_blc
88 )
89
90 if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
91         list(APPEND BLENDER_LINK_LIBS
92                 audaspace
93                 audaspace-py)
94 endif()
95
96 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
97         list(APPEND BLENDER_LINK_LIBS extern_binreloc)
98 endif()
99
100 # if(UNIX)
101         # Sort libraries
102         set(BLENDER_SORTED_LIBS
103                 ge_player_ghost 
104                 ge_player_common 
105                 bf_intern_string 
106                 bf_intern_ghost
107                 bf_rna
108                 bf_blenkernel
109                 bf_depsgraph
110                 bf_physics
111                 bf_intern_rigidbody
112                 bf_blenloader
113                 ge_blen_routines
114                 bf_editor_datafiles
115                 ge_converter 
116                 ge_logic_ketsji 
117                 ge_phys_bullet 
118                 ge_phys_dummy
119                 ge_logic 
120                 ge_rasterizer 
121                 ge_oglrasterizer 
122                 ge_logic_expressions 
123                 ge_scenegraph
124                 bf_ikplugin
125                 bf_intern_itasc
126                 bf_intern_iksolver
127                 bf_intern_smoke
128                 bf_modifiers
129                 bf_intern_moto 
130                 bf_nodes
131                 bf_gpu
132                 bf_intern_gawain
133                 bf_imbuf
134                 bf_avi 
135                 ge_logic_network 
136                 ge_logic_ngnetwork 
137                 ge_logic_loopbacknetwork 
138                 extern_bullet 
139                 bf_intern_guardedalloc 
140                 bf_intern_memutil 
141                 bf_python_ext
142                 bf_python_mathutils
143                 bf_python_bmesh
144                 bf_intern_utfconv
145                 bf_imbuf_cineon
146                 bf_imbuf_openexr 
147                 bf_imbuf_openimageio
148                 extern_openjpeg
149                 bf_imbuf_dds
150                 bf_dna
151                 ge_videotex
152                 bf_blenfont
153                 bf_blentranslation
154                 bf_intern_audaspace
155                 audaspace
156                 audaspace-py
157                 blenkernel_blc
158                 bf_bmesh
159                 bf_blenlib
160                 bf_intern_utfconv
161                 extern_binreloc
162                 extern_minilzo
163                 bf_intern_ghost # duplicate for linking
164                 bf_blenkernel # duplicate for linking
165                 bf_intern_mikktspace
166                 extern_recastnavigation
167                 bf_intern_opencolorio
168                 bf_intern_glew_mx
169                 bf_intern_eigen
170                 extern_rangetree
171                 extern_wcwidth
172                 bf_intern_libmv
173                 extern_sdlew
174         )
175
176         if(NOT WITH_SYSTEM_GLOG)
177                 list(APPEND BLENDER_SORTED_LIBS extern_glog)
178         endif()
179
180         if(NOT WITH_SYSTEM_GFLAGS)
181                 list(APPEND BLENDER_SORTED_LIBS extern_gflags)
182         endif()
183
184         if(WITH_MOD_CLOTH_ELTOPO)
185                 list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
186         endif()
187
188         if(NOT WITH_SYSTEM_GLEW)
189                 list(APPEND BLENDER_SORTED_LIBS ${BLENDER_GLEW_LIBRARIES})
190         endif()
191
192         if(WITH_LZMA)
193                 list(APPEND BLENDER_SORTED_LIBS extern_lzma)
194         endif()
195
196         if(WITH_LIBMV)
197                 list(APPEND BLENDER_SORTED_LIBS extern_ceres)
198         endif()
199
200         if(WITH_GHOST_XDND)
201                 list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
202         endif()
203
204         if(WITH_CXX_GUARDEDALLOC)
205                 list(APPEND BLENDER_SORTED_LIBS bf_intern_guardedalloc_cpp)
206         endif()
207
208         if(WITH_INTERNATIONAL)
209                 list(APPEND BLENDER_SORTED_LIBS bf_intern_locale)
210         endif()
211
212         if(WITH_GAMEENGINE_DECKLINK)
213                 list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink)
214         endif()
215
216         if(WIN32)
217                 list(APPEND BLENDER_SORTED_LIBS bf_intern_gpudirect)
218         endif()
219
220         if(WITH_OPENSUBDIV)
221                 list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv)
222         endif()
223
224         if(WITH_OPENVDB)
225                 list(APPEND BLENDER_SORTED_LIBS bf_intern_openvdb)
226         endif()
227
228         if(WITH_ALEMBIC)
229                 list(APPEND BLENDER_SORTED_LIBS bf_alembic)
230         endif()
231
232         foreach(SORTLIB ${BLENDER_SORTED_LIBS})
233                 set(REMLIB ${SORTLIB})
234                 foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
235                         if(${SEARCHLIB} STREQUAL ${SORTLIB})
236                                 set(REMLIB "")
237                         endif()
238                 endforeach()
239                 if(REMLIB)
240                         # message(STATUS "Removing library ${REMLIB} from blenderplayer linking because: not configured")
241                         list(APPEND REM_MSG ${REMLIB})
242                         list(REMOVE_ITEM BLENDER_SORTED_LIBS ${REMLIB})
243                 endif()
244         endforeach()
245         if(REM_MSG)
246                 list(SORT REM_MSG)
247                 message(STATUS "Player Skipping: (${REM_MSG})")
248         endif()
249         target_link_libraries(blenderplayer ${BLENDER_SORTED_LIBS})
250
251         unset(SEARCHLIB)
252         unset(SORTLIB)
253         unset(REMLIB)
254         unset(REM_MSG)
255
256 # else()
257 #       target_link_libraries(blenderplayer ${BLENDER_LINK_LIBS})
258 # endif()
259
260 if(WITH_PLAYER)
261         add_subdirectory(bad_level_call_stubs)
262 endif()
263
264 setup_liblinks(blenderplayer)
265
266 # We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
267 if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
268         target_link_libraries(blenderplayer "extern_clew")
269         if(WITH_CUDA_DYNLOAD)
270                 target_link_libraries(blenderplayer "extern_cuew")
271         else()
272                 target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
273         endif()
274 endif()