]> git.cworth.org Git - apitrace/blob - wrappers/CMakeLists.txt
Merge branch 'master' into 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 d3d10.def d3d10trace.cpp d3d10shader.cpp)
147         target_link_libraries (d3d10trace
148             common_trace
149             common
150             ${ZLIB_LIBRARIES}
151             ${SNAPPY_LIBRARIES}
152         )
153         set_target_properties (d3d10trace PROPERTIES
154             PREFIX ""
155             OUTPUT_NAME d3d10
156         )
157         install (TARGETS d3d10trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
158     endif ()
159
160     # d3d10_1.dll
161     if (DirectX_D3D10_1_INCLUDE_DIR)
162         include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR})
163         add_custom_command (
164             OUTPUT d3d10_1trace.cpp
165             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10_1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10_1trace.cpp
166             DEPENDS
167                 d3d10_1trace.py
168                 d3dcommontrace.py
169                 dlltrace.py
170                 trace.py
171                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
172                 ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py
173                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
174                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
175                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
176                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
177                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
178                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
179                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
180                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
181         )
182         add_library (d3d10_1trace MODULE d3d10_1.def d3d10_1trace.cpp d3d10shader.cpp)
183         target_link_libraries (d3d10_1trace
184             common_trace
185             common
186             ${ZLIB_LIBRARIES}
187             ${SNAPPY_LIBRARIES}
188         )
189         set_target_properties (d3d10_1trace
190             PROPERTIES PREFIX ""
191             OUTPUT_NAME d3d10_1
192         )
193         install (TARGETS d3d10_1trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
194     endif ()
195
196     # d3d11.dll
197     if (DirectX_D3D11_INCLUDE_DIR)
198         if (DirectX_D3D11_1_INCLUDE_DIR)
199             set (HAVE_D3D11_1 1)
200         else ()
201             set (HAVE_D3D11_1 0)
202         endif ()
203
204         include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR})
205         add_custom_command (
206             OUTPUT d3d11trace.cpp
207             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp
208             DEPENDS
209                 d3d11trace.py
210                 dlltrace.py
211                 trace.py
212                 ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py
213                 ${CMAKE_SOURCE_DIR}/specs/d3d11.py
214                 ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py
215                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
216                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
217                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
218                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
219                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
220                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
221         )
222         add_library (d3d11trace MODULE d3d11.def d3d11trace.cpp)
223         target_link_libraries (d3d11trace
224             common_trace
225             common
226             ${ZLIB_LIBRARIES}
227             ${SNAPPY_LIBRARIES}
228         )
229         set_target_properties (d3d11trace
230             PROPERTIES PREFIX ""
231             OUTPUT_NAME d3d11
232         )
233         install (TARGETS d3d11trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
234     endif ()
235
236     # d2d1.dll, dwrite.dll
237     if (DirectX_D2D1_INCLUDE_DIR)
238         include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
239
240         add_custom_command (
241             OUTPUT d2d1trace.cpp
242             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
243             DEPENDS
244                 d2d1trace.py
245                 trace.py
246                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
247                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
248                 ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
249                 ${CMAKE_SOURCE_DIR}/specs/d2derr.py
250                 ${CMAKE_SOURCE_DIR}/specs/dwrite.py
251                 ${CMAKE_SOURCE_DIR}/specs/dcommon.py
252                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
253                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
254                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
255                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
256                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
257         )
258         add_library (d2d1 MODULE d2d1.def d2d1trace.cpp)
259         target_link_libraries (d2d1
260             common_trace
261             common
262             ${ZLIB_LIBRARIES}
263             ${SNAPPY_LIBRARIES}
264         )
265         set_target_properties (d2d1
266             PROPERTIES PREFIX ""
267             OUTPUT_NAME d2d1
268         )
269         install (TARGETS d2d1 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
270
271         add_custom_command (
272             OUTPUT dwritetrace.cpp
273             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
274             DEPENDS
275                 dwritetrace.py
276                 trace.py
277                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
278                 ${CMAKE_SOURCE_DIR}/specs/d2d1.py
279                 ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
280                 ${CMAKE_SOURCE_DIR}/specs/d2derr.py
281                 ${CMAKE_SOURCE_DIR}/specs/dwrite.py
282                 ${CMAKE_SOURCE_DIR}/specs/dcommon.py
283                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
284                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
285                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
286                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
287                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
288         )
289         add_library (dwrite MODULE dwrite.def dwritetrace.cpp)
290         target_link_libraries (dwrite
291             common_trace
292             common
293             ${ZLIB_LIBRARIES}
294             ${SNAPPY_LIBRARIES}
295         )
296         set_target_properties (dwrite
297             PROPERTIES PREFIX ""
298             OUTPUT_NAME dwrite
299         )
300         install (TARGETS dwrite LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
301     endif (DirectX_D2D1_INCLUDE_DIR)
302
303     # opengl32.dll
304     add_custom_command (
305         OUTPUT wgltrace.cpp
306         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
307         DEPENDS
308                 wgltrace.py
309                 gltrace.py
310                 trace.py
311                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
312                 ${CMAKE_SOURCE_DIR}/specs/wglapi.py
313                 ${CMAKE_SOURCE_DIR}/specs/wglenum.py
314                 ${CMAKE_SOURCE_DIR}/specs/glapi.py
315                 ${CMAKE_SOURCE_DIR}/specs/glparams.py
316                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
317                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
318                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
319     )
320     add_library (wgltrace MODULE opengl32.def
321         wgltrace.cpp
322         glcaps.cpp
323         gltrace_state.cpp
324     )
325     add_dependencies (wgltrace glproc)
326     target_link_libraries (wgltrace
327         glproc_gl
328         common_trace
329         common
330         ${ZLIB_LIBRARIES}
331         ${SNAPPY_LIBRARIES}
332     )
333     set_target_properties (wgltrace PROPERTIES
334         PREFIX ""
335         OUTPUT_NAME opengl32
336     )
337     install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
338
339 elseif (APPLE)
340     # OpenGL framework
341     add_custom_command (
342         OUTPUT cgltrace.cpp
343         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
344         DEPENDS
345             cgltrace.py
346             gltrace.py
347             trace.py
348             ${CMAKE_SOURCE_DIR}/specs/cglapi.py
349             ${CMAKE_SOURCE_DIR}/specs/glapi.py
350             ${CMAKE_SOURCE_DIR}/specs/glparams.py
351             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
352             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
353     )
354
355     add_library (cgltrace SHARED
356         cgltrace.cpp
357         glcaps.cpp
358         gltrace_state.cpp
359     )
360
361     add_dependencies (cgltrace glproc)
362
363     set_target_properties (cgltrace PROPERTIES
364         # OpenGL framework name
365         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
366         # Specificy the version and reexport GLU symbols
367         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
368     )
369
370     target_link_libraries (cgltrace
371         glproc_gl
372         common_trace
373         common
374         ${ZLIB_LIBRARIES}
375         ${SNAPPY_LIBRARIES}
376         ${CMAKE_THREAD_LIBS_INIT}
377         dl
378     )
379
380     install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
381 elseif (X11_FOUND)
382     # libGL.so
383     add_custom_command (
384         OUTPUT glxtrace.cpp
385         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
386         DEPENDS
387             glxtrace.py
388             gltrace.py
389             trace.py
390             ${CMAKE_SOURCE_DIR}/specs/glxapi.py
391             ${CMAKE_SOURCE_DIR}/specs/glapi.py
392             ${CMAKE_SOURCE_DIR}/specs/glparams.py
393             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
394             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
395     )
396
397     add_library (glxtrace SHARED
398         glxtrace.cpp
399         glcaps.cpp
400         gltrace_state.cpp
401     )
402
403     add_dependencies (glxtrace glproc)
404
405     set_target_properties (glxtrace PROPERTIES
406         # avoid the default "lib" prefix
407         PREFIX ""
408         # Prevent symbol relocations internal to our wrapper library to be
409         # overwritten by the application.
410         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
411     )
412
413     target_link_libraries (glxtrace
414         glproc_gl
415         common_trace
416         common
417         ${ZLIB_LIBRARIES}
418         ${SNAPPY_LIBRARIES}
419         ${CMAKE_THREAD_LIBS_INIT}
420         dl
421     )
422
423     install (TARGETS glxtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
424 endif ()
425
426
427 if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
428     # libEGL.so/libGL.so
429     add_custom_command (
430         OUTPUT egltrace.cpp
431         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp
432         DEPENDS
433             egltrace.py
434             gltrace.py
435             trace.py
436             ${CMAKE_SOURCE_DIR}/specs/eglapi.py
437             ${CMAKE_SOURCE_DIR}/specs/glesapi.py
438             ${CMAKE_SOURCE_DIR}/specs/glapi.py
439             ${CMAKE_SOURCE_DIR}/specs/glparams.py
440             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
441             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
442     )
443
444     add_library (egltrace SHARED
445         egltrace.cpp
446         glcaps.cpp
447         gltrace_state.cpp
448         ${CMAKE_SOURCE_DIR}/helpers/eglsize.cpp
449     )
450
451     add_dependencies (egltrace glproc)
452
453     set_target_properties (egltrace PROPERTIES
454         # avoid the default "lib" prefix
455         PREFIX ""
456         # Prevent symbol relocations internal to our wrapper library to be
457         # overwritten by the application.
458         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
459     )
460
461     target_link_libraries (egltrace
462         glproc_egl
463         common_trace
464         common
465         ${ZLIB_LIBRARIES}
466         ${SNAPPY_LIBRARIES}
467         ${CMAKE_THREAD_LIBS_INIT}
468         dl
469     )
470
471     install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
472 endif ()