]> git.cworth.org Git - apitrace/blob - wrappers/CMakeLists.txt
Support apps that use DXVA.
[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                 dlltrace.py
131                 trace.py
132                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
133                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
134                 ${CMAKE_SOURCE_DIR}/specs/d3d10misc.py
135                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
136                 ${CMAKE_SOURCE_DIR}/specs/d3d10shader.py
137                 ${CMAKE_SOURCE_DIR}/specs/d3d10effect.py
138                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
139                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
140                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
141                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
142                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
143                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
144         )
145         add_library (d3d10trace MODULE d3d10.def d3d10trace.cpp d3d10shader.cpp)
146         target_link_libraries (d3d10trace
147             common_trace
148             common
149             ${ZLIB_LIBRARIES}
150             ${SNAPPY_LIBRARIES}
151         )
152         set_target_properties (d3d10trace PROPERTIES
153             PREFIX ""
154             OUTPUT_NAME d3d10
155         )
156         install (TARGETS d3d10trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
157     endif ()
158
159     # d3d10_1.dll
160     if (DirectX_D3D10_1_INCLUDE_DIR)
161         include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR})
162         add_custom_command (
163             OUTPUT d3d10_1trace.cpp
164             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10_1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10_1trace.cpp
165             DEPENDS
166                 d3d10_1trace.py
167                 dlltrace.py
168                 trace.py
169                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
170                 ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py
171                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
172                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
173                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
174                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
175                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
176                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
177                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
178                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
179         )
180         add_library (d3d10_1trace MODULE d3d10_1.def d3d10_1trace.cpp)
181         target_link_libraries (d3d10_1trace
182             common_trace
183             common
184             ${ZLIB_LIBRARIES}
185             ${SNAPPY_LIBRARIES}
186         )
187         set_target_properties (d3d10_1trace
188             PROPERTIES PREFIX ""
189             OUTPUT_NAME d3d10_1
190         )
191         install (TARGETS d3d10_1trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
192     endif ()
193
194     # d3d11.dll
195     if (DirectX_D3D11_INCLUDE_DIR)
196         if (DirectX_D3D11_1_INCLUDE_DIR)
197             set (HAVE_D3D11_1 1)
198         else ()
199             set (HAVE_D3D11_1 0)
200         endif ()
201
202         include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR})
203         add_custom_command (
204             OUTPUT d3d11trace.cpp
205             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp
206             DEPENDS
207                 d3d11trace.py
208                 dlltrace.py
209                 trace.py
210                 ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py
211                 ${CMAKE_SOURCE_DIR}/specs/d3d11.py
212                 ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py
213                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
214                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
215                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
216                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
217                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
218                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
219         )
220         add_library (d3d11trace MODULE d3d11.def d3d11trace.cpp)
221         target_link_libraries (d3d11trace
222             common_trace
223             common
224             ${ZLIB_LIBRARIES}
225             ${SNAPPY_LIBRARIES}
226         )
227         set_target_properties (d3d11trace
228             PROPERTIES PREFIX ""
229             OUTPUT_NAME d3d11
230         )
231         install (TARGETS d3d11trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
232     endif ()
233
234     # opengl32.dll
235     add_custom_command (
236         OUTPUT wgltrace.cpp
237         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
238         DEPENDS
239                 wgltrace.py
240                 gltrace.py
241                 trace.py
242                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
243                 ${CMAKE_SOURCE_DIR}/specs/wglapi.py
244                 ${CMAKE_SOURCE_DIR}/specs/wglenum.py
245                 ${CMAKE_SOURCE_DIR}/specs/glapi.py
246                 ${CMAKE_SOURCE_DIR}/specs/glparams.py
247                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
248                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
249                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
250     )
251     add_library (wgltrace MODULE opengl32.def
252         wgltrace.cpp
253         glcaps.cpp
254         gltrace_state.cpp
255     )
256     add_dependencies (wgltrace glproc)
257     target_link_libraries (wgltrace
258         glproc_gl
259         common_trace
260         common
261         ${ZLIB_LIBRARIES}
262         ${SNAPPY_LIBRARIES}
263     )
264     set_target_properties (wgltrace PROPERTIES
265         PREFIX ""
266         OUTPUT_NAME opengl32
267     )
268     install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
269
270 elseif (APPLE)
271     # OpenGL framework
272     add_custom_command (
273         OUTPUT cgltrace.cpp
274         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
275         DEPENDS
276             cgltrace.py
277             gltrace.py
278             trace.py
279             ${CMAKE_SOURCE_DIR}/specs/cglapi.py
280             ${CMAKE_SOURCE_DIR}/specs/glapi.py
281             ${CMAKE_SOURCE_DIR}/specs/glparams.py
282             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
283             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
284     )
285
286     add_library (cgltrace SHARED
287         cgltrace.cpp
288         glcaps.cpp
289         gltrace_state.cpp
290     )
291
292     add_dependencies (cgltrace glproc)
293
294     set_target_properties (cgltrace PROPERTIES
295         # OpenGL framework name
296         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
297         # Specificy the version and reexport GLU symbols
298         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
299     )
300
301     target_link_libraries (cgltrace
302         glproc_gl
303         common_trace
304         common
305         ${ZLIB_LIBRARIES}
306         ${SNAPPY_LIBRARIES}
307         ${CMAKE_THREAD_LIBS_INIT}
308         dl
309     )
310
311     install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
312 elseif (X11_FOUND)
313     # libGL.so
314     add_custom_command (
315         OUTPUT glxtrace.cpp
316         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
317         DEPENDS
318             glxtrace.py
319             gltrace.py
320             trace.py
321             ${CMAKE_SOURCE_DIR}/specs/glxapi.py
322             ${CMAKE_SOURCE_DIR}/specs/glapi.py
323             ${CMAKE_SOURCE_DIR}/specs/glparams.py
324             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
325             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
326     )
327
328     add_library (glxtrace SHARED
329         glxtrace.cpp
330         glcaps.cpp
331         gltrace_state.cpp
332     )
333
334     add_dependencies (glxtrace glproc)
335
336     set_target_properties (glxtrace PROPERTIES
337         # avoid the default "lib" prefix
338         PREFIX ""
339         # Prevent symbol relocations internal to our wrapper library to be
340         # overwritten by the application.
341         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
342     )
343
344     target_link_libraries (glxtrace
345         glproc_gl
346         common_trace
347         common
348         ${ZLIB_LIBRARIES}
349         ${SNAPPY_LIBRARIES}
350         ${X11_X11_LIB}
351         ${CMAKE_THREAD_LIBS_INIT}
352         dl
353     )
354
355     install (TARGETS glxtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
356 endif ()
357
358
359 if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
360     # libEGL.so/libGL.so
361     add_custom_command (
362         OUTPUT egltrace.cpp
363         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp
364         DEPENDS
365             egltrace.py
366             gltrace.py
367             trace.py
368             ${CMAKE_SOURCE_DIR}/specs/eglapi.py
369             ${CMAKE_SOURCE_DIR}/specs/glesapi.py
370             ${CMAKE_SOURCE_DIR}/specs/glapi.py
371             ${CMAKE_SOURCE_DIR}/specs/glparams.py
372             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
373             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
374     )
375
376     add_library (egltrace SHARED
377         egltrace.cpp
378         glcaps.cpp
379         gltrace_state.cpp
380     )
381
382     add_dependencies (egltrace glproc)
383
384     set_target_properties (egltrace PROPERTIES
385         # avoid the default "lib" prefix
386         PREFIX ""
387         # Prevent symbol relocations internal to our wrapper library to be
388         # overwritten by the application.
389         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
390     )
391
392     target_link_libraries (egltrace
393         glproc_egl
394         common_trace
395         common
396         ${ZLIB_LIBRARIES}
397         ${SNAPPY_LIBRARIES}
398         ${CMAKE_THREAD_LIBS_INIT}
399         dl
400     )
401
402     install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
403 endif ()