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