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