]> git.cworth.org Git - apitrace/blob - wrappers/CMakeLists.txt
Merge branch 'd2d'
[apitrace] / wrappers / CMakeLists.txt
1 ##############################################################################
2 # API tracers
3
4
5 include_directories (
6     ${CMAKE_CURRENT_SOURCE_DIR}
7     ${CMAKE_SOURCE_DIR}/helpers
8     ${CMAKE_BINARY_DIR}/dispatch
9     ${CMAKE_SOURCE_DIR}/dispatch
10 )
11
12 add_library (common_trace STATIC
13     trace.cpp
14 )
15
16 set_target_properties (common_trace PROPERTIES
17     # Ensure it can be statically linked in shared libraries
18     COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
19 )
20
21 if (WIN32)
22     if (MINGW)
23         # Silence warnings about @nn suffix mismatch
24         set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-stdcall-fixup")
25     endif ()
26
27     # ddraw.dll
28     if (DirectX_D3D_INCLUDE_DIR)
29         include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR})
30         add_custom_command (
31             OUTPUT ddrawtrace.cpp
32             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp
33             DEPENDS
34                 ddrawtrace.py
35                 dlltrace.py
36                 trace.py
37                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
38                 ${CMAKE_SOURCE_DIR}/specs/d3d.py
39                 ${CMAKE_SOURCE_DIR}/specs/d3dtypes.py
40                 ${CMAKE_SOURCE_DIR}/specs/d3dcaps.py
41                 ${CMAKE_SOURCE_DIR}/specs/ddraw.py
42                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
43                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
44         )
45         add_library (ddrawtrace MODULE ddraw.def ddrawtrace.cpp)
46         target_link_libraries (ddrawtrace
47             common_trace
48             common
49             ${ZLIB_LIBRARIES}
50             ${SNAPPY_LIBRARIES}
51         )
52         set_target_properties (ddrawtrace PROPERTIES
53             PREFIX ""
54             OUTPUT_NAME ddraw
55         )
56         install (TARGETS ddrawtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
57     endif ()
58
59     # d3d8.dll
60     if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
61         include_directories (SYSTEM ${DirectX_D3D8_INCLUDE_DIR} ${DirectX_D3DX9_INCLUDE_DIR})
62         add_custom_command (
63             OUTPUT d3d8trace.cpp
64             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp
65             DEPENDS
66                 d3d8trace.py
67                 dlltrace.py
68                 trace.py
69                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
70                 ${CMAKE_SOURCE_DIR}/specs/d3d8.py
71                 ${CMAKE_SOURCE_DIR}/specs/d3d8types.py
72                 ${CMAKE_SOURCE_DIR}/specs/d3d8caps.py
73                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
74                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
75         )
76         add_library (d3d8trace MODULE d3d8.def d3d8trace.cpp d3d9shader.cpp)
77         target_link_libraries (d3d8trace
78             common_trace
79             common
80             ${ZLIB_LIBRARIES}
81             ${SNAPPY_LIBRARIES}
82         )
83         set_target_properties (d3d8trace PROPERTIES
84             PREFIX ""
85             OUTPUT_NAME d3d8
86         )
87         install (TARGETS d3d8trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
88     endif ()
89
90     # d3d9.dll
91     if (DirectX_D3DX9_INCLUDE_DIR)
92         include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
93         add_custom_command (
94             OUTPUT d3d9trace.cpp
95             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp
96             DEPENDS
97                 d3d9trace.py
98                 dlltrace.py
99                 trace.py
100                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
101                 ${CMAKE_SOURCE_DIR}/specs/d3d9.py
102                 ${CMAKE_SOURCE_DIR}/specs/d3d9types.py
103                 ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py
104                 ${CMAKE_SOURCE_DIR}/specs/d3d9dxva2.py
105                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
106                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
107         )
108         add_library (d3d9trace MODULE d3d9.def d3d9trace.cpp d3d9shader.cpp)
109         target_link_libraries (d3d9trace
110             common_trace
111             common
112             ${ZLIB_LIBRARIES}
113             ${SNAPPY_LIBRARIES}
114         )
115         set_target_properties (d3d9trace PROPERTIES
116             PREFIX ""
117             OUTPUT_NAME d3d9
118         )
119         install (TARGETS d3d9trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
120     endif ()
121
122     # d3d10.dll
123     if (DirectX_D3D10_INCLUDE_DIR)
124         include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR})
125         add_custom_command (
126             OUTPUT d3d10trace.cpp
127             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
128             DEPENDS
129                 d3d10trace.py
130                 d3dcommontrace.py
131                 dlltrace.py
132                 trace.py
133                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
134                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
135                 ${CMAKE_SOURCE_DIR}/specs/d3d10misc.py
136                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
137                 ${CMAKE_SOURCE_DIR}/specs/d3d10shader.py
138                 ${CMAKE_SOURCE_DIR}/specs/d3d10effect.py
139                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
140                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
141                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
142                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
143                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
144                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
145         )
146         add_library (d3d10trace MODULE
147             d3d10.def
148             d3d10trace.cpp
149             d3dcommonshader.cpp
150         )
151         target_link_libraries (d3d10trace
152             common_trace
153             common
154             ${ZLIB_LIBRARIES}
155             ${SNAPPY_LIBRARIES}
156         )
157         set_target_properties (d3d10trace PROPERTIES
158             PREFIX ""
159             OUTPUT_NAME d3d10
160         )
161         install (TARGETS d3d10trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
162     endif ()
163
164     # d3d10_1.dll
165     if (DirectX_D3D10_1_INCLUDE_DIR)
166         include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR})
167         add_custom_command (
168             OUTPUT d3d10_1trace.cpp
169             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10_1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10_1trace.cpp
170             DEPENDS
171                 d3d10_1trace.py
172                 d3dcommontrace.py
173                 dlltrace.py
174                 trace.py
175                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
176                 ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py
177                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
178                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
179                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
180                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
181                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
182                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
183                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
184                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
185         )
186         add_library (d3d10_1trace MODULE
187             d3d10_1.def
188             d3d10_1trace.cpp
189             d3dcommonshader.cpp
190         )
191         target_link_libraries (d3d10_1trace
192             common_trace
193             common
194             ${ZLIB_LIBRARIES}
195             ${SNAPPY_LIBRARIES}
196         )
197         set_target_properties (d3d10_1trace
198             PROPERTIES PREFIX ""
199             OUTPUT_NAME d3d10_1
200         )
201         install (TARGETS d3d10_1trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
202     endif ()
203
204     # d3d11.dll
205     if (DirectX_D3D11_INCLUDE_DIR)
206         if (DirectX_D3D11_1_INCLUDE_DIR)
207             set (HAVE_D3D11_1 1)
208         else ()
209             set (HAVE_D3D11_1 0)
210         endif ()
211
212         include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR})
213         add_custom_command (
214             OUTPUT d3d11trace.cpp
215             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp
216             DEPENDS
217                 d3d11trace.py
218                 d3dcommontrace.py
219                 dlltrace.py
220                 trace.py
221                 ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py
222                 ${CMAKE_SOURCE_DIR}/specs/d3d11.py
223                 ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py
224                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
225                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
226                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
227                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
228                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
229                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
230         )
231         add_library (d3d11trace MODULE
232             d3d11.def
233             d3d11trace.cpp
234             d3dcommonshader.cpp
235         )
236         target_link_libraries (d3d11trace
237             common_trace
238             common
239             ${ZLIB_LIBRARIES}
240             ${SNAPPY_LIBRARIES}
241         )
242         set_target_properties (d3d11trace
243             PROPERTIES PREFIX ""
244             OUTPUT_NAME d3d11
245         )
246         install (TARGETS d3d11trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
247     endif ()
248
249     # d2d1.dll, dwrite.dll
250     if (DirectX_D2D1_INCLUDE_DIR)
251         include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
252
253         add_custom_command (
254             OUTPUT d2d1trace.cpp
255             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
256             DEPENDS
257                 d2d1trace.py
258                 trace.py
259                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
260                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
261                 ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
262                 ${CMAKE_SOURCE_DIR}/specs/d2derr.py
263                 ${CMAKE_SOURCE_DIR}/specs/dwrite.py
264                 ${CMAKE_SOURCE_DIR}/specs/dcommon.py
265                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
266                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
267                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
268                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
269                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
270         )
271         add_library (d2d1 MODULE d2d1.def d2d1trace.cpp)
272         target_link_libraries (d2d1
273             common_trace
274             common
275             ${ZLIB_LIBRARIES}
276             ${SNAPPY_LIBRARIES}
277         )
278         set_target_properties (d2d1
279             PROPERTIES PREFIX ""
280             OUTPUT_NAME d2d1
281         )
282         install (TARGETS d2d1 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
283
284         add_custom_command (
285             OUTPUT dwritetrace.cpp
286             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
287             DEPENDS
288                 dwritetrace.py
289                 trace.py
290                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
291                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
292                 ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
293                 ${CMAKE_SOURCE_DIR}/specs/d2derr.py
294                 ${CMAKE_SOURCE_DIR}/specs/dwrite.py
295                 ${CMAKE_SOURCE_DIR}/specs/dcommon.py
296                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
297                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
298                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
299                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
300                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
301         )
302         add_library (dwrite MODULE dwrite.def dwritetrace.cpp)
303         target_link_libraries (dwrite
304             common_trace
305             common
306             ${ZLIB_LIBRARIES}
307             ${SNAPPY_LIBRARIES}
308         )
309         set_target_properties (dwrite
310             PROPERTIES PREFIX ""
311             OUTPUT_NAME dwrite
312         )
313         install (TARGETS dwrite LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
314     endif (DirectX_D2D1_INCLUDE_DIR)
315
316     # opengl32.dll
317     add_custom_command (
318         OUTPUT wgltrace.cpp
319         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
320         DEPENDS
321                 wgltrace.py
322                 gltrace.py
323                 trace.py
324                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
325                 ${CMAKE_SOURCE_DIR}/specs/wglapi.py
326                 ${CMAKE_SOURCE_DIR}/specs/wglenum.py
327                 ${CMAKE_SOURCE_DIR}/specs/glapi.py
328                 ${CMAKE_SOURCE_DIR}/specs/glparams.py
329                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
330                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
331                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
332     )
333     add_library (wgltrace MODULE opengl32.def
334         wgltrace.cpp
335         glcaps.cpp
336         gltrace_state.cpp
337     )
338     add_dependencies (wgltrace glproc)
339     target_link_libraries (wgltrace
340         glproc_gl
341         common_trace
342         common
343         ${ZLIB_LIBRARIES}
344         ${SNAPPY_LIBRARIES}
345     )
346     set_target_properties (wgltrace PROPERTIES
347         PREFIX ""
348         OUTPUT_NAME opengl32
349     )
350     install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
351
352 elseif (APPLE)
353     # OpenGL framework
354     add_custom_command (
355         OUTPUT cgltrace.cpp
356         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
357         DEPENDS
358             cgltrace.py
359             gltrace.py
360             trace.py
361             ${CMAKE_SOURCE_DIR}/specs/cglapi.py
362             ${CMAKE_SOURCE_DIR}/specs/glapi.py
363             ${CMAKE_SOURCE_DIR}/specs/glparams.py
364             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
365             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
366     )
367
368     add_library (cgltrace SHARED
369         cgltrace.cpp
370         glcaps.cpp
371         gltrace_state.cpp
372     )
373
374     add_dependencies (cgltrace glproc)
375
376     set_target_properties (cgltrace PROPERTIES
377         # OpenGL framework name
378         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
379         # Specificy the version and reexport GLU symbols
380         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
381     )
382
383     target_link_libraries (cgltrace
384         glproc_gl
385         common_trace
386         common
387         ${ZLIB_LIBRARIES}
388         ${SNAPPY_LIBRARIES}
389         ${CMAKE_THREAD_LIBS_INIT}
390         dl
391     )
392
393     install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
394 elseif (X11_FOUND)
395     # libGL.so
396     add_custom_command (
397         OUTPUT glxtrace.cpp
398         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
399         DEPENDS
400             glxtrace.py
401             gltrace.py
402             trace.py
403             ${CMAKE_SOURCE_DIR}/specs/glxapi.py
404             ${CMAKE_SOURCE_DIR}/specs/glapi.py
405             ${CMAKE_SOURCE_DIR}/specs/glparams.py
406             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
407             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
408     )
409
410     add_library (glxtrace SHARED
411         glxtrace.cpp
412         glcaps.cpp
413         gltrace_state.cpp
414     )
415
416     add_dependencies (glxtrace glproc)
417
418     set_target_properties (glxtrace PROPERTIES
419         # avoid the default "lib" prefix
420         PREFIX ""
421         # Prevent symbol relocations internal to our wrapper library to be
422         # overwritten by the application.
423         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
424     )
425
426     target_link_libraries (glxtrace
427         glproc_gl
428         common_trace
429         common
430         ${ZLIB_LIBRARIES}
431         ${SNAPPY_LIBRARIES}
432         ${CMAKE_THREAD_LIBS_INIT}
433         dl
434     )
435
436     install (TARGETS glxtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
437 endif ()
438
439
440 if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
441     # libEGL.so/libGL.so
442     add_custom_command (
443         OUTPUT egltrace.cpp
444         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp
445         DEPENDS
446             egltrace.py
447             gltrace.py
448             trace.py
449             ${CMAKE_SOURCE_DIR}/specs/eglapi.py
450             ${CMAKE_SOURCE_DIR}/specs/glesapi.py
451             ${CMAKE_SOURCE_DIR}/specs/glapi.py
452             ${CMAKE_SOURCE_DIR}/specs/glparams.py
453             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
454             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
455     )
456
457     add_library (egltrace SHARED
458         egltrace.cpp
459         glcaps.cpp
460         gltrace_state.cpp
461         ${CMAKE_SOURCE_DIR}/helpers/eglsize.cpp
462     )
463
464     add_dependencies (egltrace glproc)
465
466     set_target_properties (egltrace PROPERTIES
467         # avoid the default "lib" prefix
468         PREFIX ""
469         # Prevent symbol relocations internal to our wrapper library to be
470         # overwritten by the application.
471         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
472     )
473
474     target_link_libraries (egltrace
475         glproc_egl
476         common_trace
477         common
478         ${ZLIB_LIBRARIES}
479         ${SNAPPY_LIBRARIES}
480         ${CMAKE_THREAD_LIBS_INIT}
481         dl
482     )
483
484     install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
485 endif ()