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