CMake: add libs needed for gtests
[blender.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_depsgraph.c
44         rna_dynamicpaint.c
45         rna_fcurve.c
46         rna_fluidsim.c
47         rna_gpencil.c
48         rna_gpencil_modifier.c
49         rna_image.c
50         rna_key.c
51         rna_lattice.c
52         rna_layer.c
53         rna_light.c
54         rna_lightprobe.c
55         rna_linestyle.c
56         rna_main.c
57         rna_mask.c
58         rna_material.c
59         rna_mesh.c
60         rna_meta.c
61         rna_modifier.c
62         rna_movieclip.c
63         rna_nla.c
64         rna_nodetree.c
65         rna_object.c
66         rna_object_force.c
67         rna_packedfile.c
68         rna_palette.c
69         rna_particle.c
70         rna_pose.c
71         rna_render.c
72         rna_rigidbody.c
73         rna_rna.c
74         rna_scene.c
75         rna_screen.c
76         rna_sculpt_paint.c
77         rna_sequencer.c
78         rna_shader_fx.c
79         rna_smoke.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_wm.c
92         rna_wm_gizmo.c
93         rna_workspace.c
94         rna_world.c
95 )
96
97 set(APISRC
98         rna_action_api.c
99         rna_animation_api.c
100         rna_armature_api.c
101         rna_camera_api.c
102         rna_curve_api.c
103         rna_fcurve_api.c
104         rna_image_api.c
105         rna_lattice_api.c
106         rna_main_api.c
107         rna_material_api.c
108         rna_mesh_api.c
109         rna_meta_api.c
110         rna_object_api.c
111         rna_pose_api.c
112         rna_scene_api.c
113         rna_sequencer_api.c
114         rna_sound_api.c
115         rna_space_api.c
116         rna_text_api.c
117         rna_texture_api.c
118         rna_ui_api.c
119         rna_vfont_api.c
120         rna_wm_api.c
121         rna_wm_gizmo_api.c
122         rna_workspace_api.c
123 )
124
125 string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
126 list(APPEND GENSRC
127         "${CMAKE_CURRENT_BINARY_DIR}/rna_prototypes_gen.h"
128 )
129 set_source_files_properties(${GENSRC} PROPERTIES GENERATED TRUE)
130
131 # --------------------------
132 # CFLAGS for Generated Files
133 #
134 # less strict flags for generated source
135 set(GENSRC_CFLAGS)
136 if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
137         set(GENSRC_CFLAGS "-Wno-missing-prototypes")
138 endif()
139 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
140         set(GENSRC_CFLAGS "${GENSRC_CFLAGS} -Wno-missing-variable-declarations")
141 endif()
142
143 if(GENSRC_CFLAGS)
144         set_source_files_properties(${GENSRC} PROPERTIES COMPILE_FLAGS "${GENSRC_CFLAGS}")
145 endif()
146 unset(GENSRC_CFLAGS)
147
148
149 set(SRC_RNA_INC
150         ../RNA_access.h
151         ../RNA_define.h
152         ../RNA_documentation.h
153         ../RNA_enum_types.h
154         ../RNA_types.h
155 )
156
157 set(SRC
158         makesrna.c
159         rna_define.c
160         ${DEFSRC}
161         ${APISRC}
162         ../../../../intern/clog/clog.c
163         ../../../../intern/guardedalloc/intern/mallocn.c
164         ../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
165         ../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
166         ../../../../intern/guardedalloc/intern/mmap_win.c
167 )
168
169 set(INC
170     ../../../../intern/clog
171 )
172
173 set(INC_SYS
174
175 )
176
177 if(WITH_CYCLES)
178         add_definitions(-DWITH_CYCLES)
179 endif()
180
181 if(WITH_PYTHON)
182         add_definitions(-DWITH_PYTHON)
183         list(APPEND INC
184                 ../../python
185         )
186 endif()
187
188 if(WITH_IMAGE_OPENEXR)
189         add_definitions(-DWITH_OPENEXR)
190 endif()
191
192 if(WITH_OPENIMAGEIO)
193         add_definitions(-DWITH_OPENIMAGEIO)
194 endif()
195
196 if(WITH_IMAGE_TIFF)
197         add_definitions(-DWITH_TIFF)
198 endif()
199
200 if(WITH_IMAGE_OPENJPEG)
201         add_definitions(-DWITH_OPENJPEG)
202 endif()
203
204 if(WITH_IMAGE_DDS)
205         add_definitions(-DWITH_DDS)
206 endif()
207
208 if(WITH_IMAGE_CINEON)
209         add_definitions(-DWITH_CINEON)
210 endif()
211
212 if(WITH_IMAGE_HDR)
213         add_definitions(-DWITH_HDR)
214 endif()
215
216 if(WITH_AUDASPACE)
217         add_definitions(-DWITH_AUDASPACE)
218
219         list(APPEND INC_SYS
220                 ${AUDASPACE_C_INCLUDE_DIRS}
221         )
222 endif()
223
224 if(WITH_CODEC_FFMPEG)
225         list(APPEND INC
226                 ../../../../intern/ffmpeg
227         )
228         list(APPEND INC_SYS
229                 ${FFMPEG_INCLUDE_DIRS}
230         )
231         add_definitions(-DWITH_FFMPEG)
232 endif()
233
234 if(WITH_MOD_FLUID)
235         add_definitions(-DWITH_MOD_FLUID)
236 endif()
237
238 if(WITH_FFTW3)
239         add_definitions(-DWITH_FFTW3)
240 endif()
241
242 if(WITH_MOD_SMOKE)
243         add_definitions(-DWITH_SMOKE)
244 endif()
245
246 if(WITH_MOD_OCEANSIM)
247         add_definitions(-DWITH_OCEANSIM)
248 endif()
249
250 if(WITH_SDL)
251         if(WITH_SDL_DYNLOAD)
252                 add_definitions(-DWITH_SDL_DYNLOAD)
253                 list(APPEND INC
254                         ../../../../extern/sdlew/include
255                 )
256         endif()
257         add_definitions(-DWITH_SDL)
258 endif()
259
260 if(WITH_OPENAL)
261         add_definitions(-DWITH_OPENAL)
262 endif()
263
264 if(WITH_JACK)
265         add_definitions(-DWITH_JACK)
266 endif()
267
268 if(WITH_OPENCOLLADA)
269         add_definitions(-DWITH_COLLADA)
270 endif()
271
272 if(WITH_INTERNATIONAL)
273         add_definitions(-DWITH_INTERNATIONAL)
274 endif()
275
276 if(WITH_ALEMBIC)
277         list(APPEND INC
278                 ../../alembic
279         )
280         add_definitions(-DWITH_ALEMBIC)
281 endif()
282
283 if(WITH_BULLET)
284         list(APPEND INC
285                 ../../../../intern/rigidbody
286         )
287         add_definitions(-DWITH_BULLET)
288 endif()
289
290 if(WITH_FREESTYLE)
291         list(APPEND INC
292                 ../../freestyle
293         )
294         add_definitions(-DWITH_FREESTYLE)
295 endif()
296
297 if(WITH_OPENSUBDIV)
298         list(APPEND INC
299                 ../../../../intern/opensubdiv
300         )
301         add_definitions(-DWITH_OPENSUBDIV)
302 endif()
303
304 if(WITH_OPENVDB)
305         add_definitions(-DWITH_OPENVDB)
306
307         if(WITH_OPENVDB_BLOSC)
308                 add_definitions(-DWITH_OPENVDB_BLOSC)
309         endif()
310 endif()
311
312 if(WITH_INPUT_NDOF)
313         add_definitions(-DWITH_INPUT_NDOF)
314 endif()
315
316 # Build makesrna executable
317 blender_include_dirs(
318         .
319         ..
320         ../../blenfont
321         ../../blenkernel
322         ../../blenlib
323         ../../bmesh
324         ../../blentranslation
325         ../../depsgraph
326         ../../draw
327         ../../gpu
328         ../../imbuf
329         ../../ikplugin
330         ../../makesdna
331         ../../nodes/
332         ../../physics
333         ../../windowmanager
334         ../../editors/include
335         ../../render/extern/include
336         ../../../../intern/cycles/blender
337         ../../../../intern/guardedalloc
338         ../../../../intern/glew-mx
339         ../../../../intern/atomic
340         ../../../../intern/memutil
341         ../../../../intern/smoke/extern
342 )
343
344 blender_include_dirs_sys(
345         "${GLEW_INCLUDE_PATH}"
346 )
347
348 add_cc_flags_custom_test(makesrna)
349 setup_platform_linker_flags()
350
351 add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC})
352
353 target_link_libraries(makesrna bf_dna)
354 target_link_libraries(makesrna bf_dna_blenlib)
355
356 # Output rna_*_gen.c
357 # note (linux only): with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes
358 add_custom_command(
359         OUTPUT ${GENSRC}
360         COMMAND "$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/
361         DEPENDS makesrna
362 )
363
364 # Build bf_rna
365 set(SRC
366         rna_access.c
367         ${GENSRC}
368
369         ${SRC_RNA_INC}
370         rna_internal.h
371         rna_internal_types.h
372         rna_mesh_utils.h
373 )
374
375 set(LIB
376         bf_dna
377         bf_editor_armature
378         bf_editor_curve
379         bf_editor_gizmo_library
380         bf_editor_gpencil
381         bf_editor_mesh
382         bf_editor_object
383         bf_editor_physics
384         bf_editor_render
385         bf_editor_scene
386         bf_editor_sculpt_paint
387         bf_editor_space_clip
388         bf_editor_space_file
389         bf_editor_space_image
390         bf_editor_space_info
391         bf_editor_space_node
392         bf_editor_space_view3d
393         bf_editor_transform
394 )
395
396 add_definitions(${GL_DEFINITIONS})
397
398 blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")