CMake: add WITH_LINKER_LLD option for unix platforms
[blender-staging.git] / source / blender / makesrna / intern / 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 # ***** END GPL LICENSE BLOCK *****
20
21 if(CMAKE_COMPILER_IS_GNUCC)
22   # add here so we fail early.
23   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
24 endif()
25
26 # files rna_access.c rna_define.c makesrna.c intentionally excluded.
27 set(DEFSRC
28   rna_ID.c
29   rna_action.c
30   rna_animation.c
31   rna_animviz.c
32   rna_armature.c
33   rna_boid.c
34   rna_brush.c
35   rna_cachefile.c
36   rna_camera.c
37   rna_cloth.c
38   rna_collection.c
39   rna_color.c
40   rna_constraint.c
41   rna_context.c
42   rna_curve.c
43   rna_curveprofile.c
44   rna_depsgraph.c
45   rna_dynamicpaint.c
46   rna_fcurve.c
47   rna_fluid.c
48   rna_gpencil.c
49   rna_gpencil_modifier.c
50   rna_image.c
51   rna_key.c
52   rna_lattice.c
53   rna_layer.c
54   rna_light.c
55   rna_lightprobe.c
56   rna_linestyle.c
57   rna_main.c
58   rna_mask.c
59   rna_material.c
60   rna_mesh.c
61   rna_meta.c
62   rna_modifier.c
63   rna_movieclip.c
64   rna_nla.c
65   rna_nodetree.c
66   rna_object.c
67   rna_object_force.c
68   rna_packedfile.c
69   rna_palette.c
70   rna_particle.c
71   rna_pose.c
72   rna_render.c
73   rna_rigidbody.c
74   rna_rna.c
75   rna_scene.c
76   rna_screen.c
77   rna_sculpt_paint.c
78   rna_sequencer.c
79   rna_shader_fx.c
80   rna_sound.c
81   rna_space.c
82   rna_speaker.c
83   rna_test.c
84   rna_text.c
85   rna_texture.c
86   rna_timeline.c
87   rna_tracking.c
88   rna_ui.c
89   rna_userdef.c
90   rna_vfont.c
91   rna_volume.c
92   rna_wm.c
93   rna_wm_gizmo.c
94   rna_workspace.c
95   rna_world.c
96   rna_xr.c
97 )
98
99 if(WITH_NEW_OBJECT_TYPES)
100   list(APPEND DEFSRC
101     rna_hair.c
102     rna_pointcloud.c
103   )
104 endif()
105
106 if (WITH_NEW_SIMULATION_TYPE)
107   list(APPEND DEFSRC
108     rna_simulation.c
109   )
110 endif()
111
112
113 set(APISRC
114   rna_action_api.c
115   rna_animation_api.c
116   rna_armature_api.c
117   rna_camera_api.c
118   rna_curve_api.c
119   rna_fcurve_api.c
120   rna_image_api.c
121   rna_lattice_api.c
122   rna_main_api.c
123   rna_material_api.c
124   rna_mesh_api.c
125   rna_meta_api.c
126   rna_object_api.c
127   rna_pose_api.c
128   rna_scene_api.c
129   rna_sequencer_api.c
130   rna_sound_api.c
131   rna_space_api.c
132   rna_text_api.c
133   rna_texture_api.c
134   rna_ui_api.c
135   rna_vfont_api.c
136   rna_wm_api.c
137   rna_wm_gizmo_api.c
138   rna_workspace_api.c
139 )
140
141 string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
142 list(APPEND GENSRC
143   "${CMAKE_CURRENT_BINARY_DIR}/rna_prototypes_gen.h"
144 )
145 set_source_files_properties(${GENSRC} PROPERTIES GENERATED TRUE)
146
147 # --------------------------
148 # CFLAGS for Generated Files
149 #
150 # less strict flags for generated source
151 set(GENSRC_CFLAGS)
152 if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
153   set(GENSRC_CFLAGS "-Wno-missing-prototypes")
154 endif()
155 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
156   set(GENSRC_CFLAGS "${GENSRC_CFLAGS} -Wno-missing-variable-declarations")
157 endif()
158
159 if(GENSRC_CFLAGS)
160   set_source_files_properties(${GENSRC} PROPERTIES COMPILE_FLAGS "${GENSRC_CFLAGS}")
161 endif()
162 unset(GENSRC_CFLAGS)
163
164
165 set(SRC_RNA_INC
166   ../RNA_access.h
167   ../RNA_define.h
168   ../RNA_documentation.h
169   ../RNA_enum_types.h
170   ../RNA_types.h
171 )
172
173 set(SRC
174   makesrna.c
175   rna_define.c
176   ${DEFSRC}
177   ${APISRC}
178   ../../../../intern/clog/clog.c
179   ../../../../intern/guardedalloc/intern/mallocn.c
180   ../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
181   ../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
182   ../../../../intern/guardedalloc/intern/mmap_win.c
183
184   # Needed for defaults.
185   ../../../../release/datafiles/userdef/userdef_default.c
186   ../../../../release/datafiles/userdef/userdef_default_theme.c
187 )
188
189 set(INC
190   ../../../../intern/clog
191
192   # Needed for defaults forward declarations.
193   ../../blenloader
194
195   ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
196 )
197
198 set(INC_SYS
199
200 )
201
202 if(WITH_CYCLES)
203   add_definitions(-DWITH_CYCLES)
204 endif()
205
206 if(WITH_PYTHON)
207   add_definitions(-DWITH_PYTHON)
208   list(APPEND INC
209     ../../python
210   )
211 endif()
212
213 if(WITH_IMAGE_OPENEXR)
214   add_definitions(-DWITH_OPENEXR)
215 endif()
216
217 if(WITH_OPENIMAGEIO)
218   add_definitions(-DWITH_OPENIMAGEIO)
219 endif()
220
221 if(WITH_IMAGE_TIFF)
222   add_definitions(-DWITH_TIFF)
223 endif()
224
225 if(WITH_IMAGE_OPENJPEG)
226   add_definitions(-DWITH_OPENJPEG)
227 endif()
228
229 if(WITH_IMAGE_DDS)
230   add_definitions(-DWITH_DDS)
231 endif()
232
233 if(WITH_IMAGE_CINEON)
234   add_definitions(-DWITH_CINEON)
235 endif()
236
237 if(WITH_IMAGE_HDR)
238   add_definitions(-DWITH_HDR)
239 endif()
240
241 if(WITH_AUDASPACE)
242   add_definitions(-DWITH_AUDASPACE)
243
244   list(APPEND INC_SYS
245     ${AUDASPACE_C_INCLUDE_DIRS}
246   )
247   list(APPEND LIB
248     ${AUDASPACE_C_LIBRARIES}
249     ${AUDASPACE_PY_LIBRARIES}
250   )
251 endif()
252
253 if(WITH_CODEC_FFMPEG)
254   list(APPEND INC
255     ../../../../intern/ffmpeg
256   )
257   list(APPEND INC_SYS
258     ${FFMPEG_INCLUDE_DIRS}
259   )
260   list(APPEND LIB
261     ${FFMPEG_LIBRARIES}
262   )
263   add_definitions(-DWITH_FFMPEG)
264 endif()
265
266 if(WITH_FFTW3)
267   add_definitions(-DWITH_FFTW3)
268 endif()
269
270 if(WITH_MOD_FLUID)
271   add_definitions(-DWITH_FLUID)
272 endif()
273
274 if(WITH_MOD_OCEANSIM)
275   add_definitions(-DWITH_OCEANSIM)
276 endif()
277
278 if(WITH_SDL)
279   if(WITH_SDL_DYNLOAD)
280     add_definitions(-DWITH_SDL_DYNLOAD)
281     list(APPEND INC
282       ../../../../extern/sdlew/include
283     )
284   endif()
285   add_definitions(-DWITH_SDL)
286 endif()
287
288 if(WITH_OPENAL)
289   add_definitions(-DWITH_OPENAL)
290 endif()
291
292 if(WITH_JACK)
293   add_definitions(-DWITH_JACK)
294 endif()
295
296 if(WITH_OPENCOLLADA)
297   add_definitions(-DWITH_COLLADA)
298 endif()
299
300 if(WITH_INTERNATIONAL)
301   add_definitions(-DWITH_INTERNATIONAL)
302 endif()
303
304 if(WITH_ALEMBIC)
305   list(APPEND INC
306     ../../io/alembic
307   )
308   add_definitions(-DWITH_ALEMBIC)
309 endif()
310
311 if(WITH_BULLET)
312   list(APPEND INC
313     ../../../../intern/rigidbody
314   )
315   add_definitions(-DWITH_BULLET)
316 endif()
317
318 if(WITH_FREESTYLE)
319   list(APPEND INC
320     ../../freestyle
321   )
322   add_definitions(-DWITH_FREESTYLE)
323 endif()
324
325 if(WITH_OPENSUBDIV)
326   list(APPEND INC
327     ../../../../intern/opensubdiv
328   )
329   add_definitions(-DWITH_OPENSUBDIV)
330 endif()
331
332 if(WITH_OPENVDB)
333   add_definitions(-DWITH_OPENVDB)
334
335   if(WITH_OPENVDB_BLOSC)
336     add_definitions(-DWITH_OPENVDB_BLOSC)
337   endif()
338 endif()
339
340 if(WITH_INPUT_NDOF)
341   add_definitions(-DWITH_INPUT_NDOF)
342 endif()
343
344 if(WITH_XR_OPENXR)
345   add_definitions(-DWITH_XR_OPENXR)
346 endif()
347
348 if(WITH_NEW_OBJECT_TYPES)
349   add_definitions(-DWITH_NEW_OBJECT_TYPES)
350 endif()
351
352 if (WITH_NEW_SIMULATION_TYPE)
353   add_definitions(-DWITH_NEW_SIMULATION_TYPE)
354 endif()
355
356
357 # Build makesrna executable
358 blender_include_dirs(
359   .
360   ..
361   ../../blenfont
362   ../../blenkernel
363   ../../blenlib
364   ../../blentranslation
365   ../../bmesh
366   ../../depsgraph
367   ../../draw
368   ../../gpu
369   ../../ikplugin
370   ../../imbuf
371   ../../makesdna
372   ../../nodes/
373   ../../physics
374   ../../windowmanager
375   ../../editors/include
376   ../../render/extern/include
377   ../../../../intern/cycles/blender
378   ../../../../intern/atomic
379   ../../../../intern/glew-mx
380   ../../../../intern/guardedalloc
381   ../../../../intern/memutil
382   ../../../../intern/mantaflow/extern
383 )
384
385 blender_include_dirs_sys(
386   "${GLEW_INCLUDE_PATH}"
387 )
388
389 add_cc_flags_custom_test(makesrna)
390 setup_platform_linker_flags()
391
392 add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC})
393
394 target_link_libraries(makesrna bf_dna)
395 target_link_libraries(makesrna bf_dna_blenlib)
396
397 # Output rna_*_gen.c
398 # note (linux only): with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes
399 add_custom_command(
400   OUTPUT ${GENSRC}
401   COMMAND "$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/
402   DEPENDS makesrna
403 )
404
405 # Build bf_rna
406 set(SRC
407   rna_access.c
408   rna_access_compare_override.c
409   ${GENSRC}
410
411   ${SRC_RNA_INC}
412   rna_access_internal.h
413   rna_internal.h
414   rna_internal_types.h
415   rna_mesh_utils.h
416 )
417
418 set(LIB
419   bf_dna
420   bf_editor_space_api
421
422   bf_editor_animation
423   bf_editor_armature
424   bf_editor_curve
425   bf_editor_gizmo_library
426   bf_editor_gpencil
427   bf_editor_io
428   bf_editor_mesh
429   bf_editor_object
430   bf_editor_physics
431   bf_editor_render
432   bf_editor_scene
433   bf_editor_sculpt_paint
434   bf_editor_sound
435   bf_editor_transform
436   bf_editor_undo
437 )
438
439 add_definitions(${GL_DEFINITIONS})
440
441 blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")