]> git.cworth.org Git - apitrace/blob - wrappers/CMakeLists.txt
Merge branch 'master' into mt-trace
[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/winapi.py
105                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
106         )
107         add_library (d3d9trace MODULE d3d9.def d3d9trace.cpp d3d9shader.cpp)
108         target_link_libraries (d3d9trace
109             common_trace
110             common
111             ${ZLIB_LIBRARIES}
112             ${SNAPPY_LIBRARIES}
113         )
114         set_target_properties (d3d9trace PROPERTIES
115             PREFIX ""
116             OUTPUT_NAME d3d9
117         )
118         install (TARGETS d3d9trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
119     endif ()
120
121     # d3d10.dll
122     if (DirectX_D3D10_INCLUDE_DIR)
123         include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR})
124         add_custom_command (
125             OUTPUT d3d10trace.cpp
126             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
127             DEPENDS
128                 d3d10trace.py
129                 d3dcommontrace.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                 d3dcommontrace.py
168                 dlltrace.py
169                 trace.py
170                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
171                 ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py
172                 ${CMAKE_SOURCE_DIR}/specs/d3d10.py
173                 ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
174                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
175                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
176                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
177                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
178                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
179                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
180         )
181         add_library (d3d10_1trace MODULE d3d10_1.def d3d10_1trace.cpp d3d10shader.cpp)
182         target_link_libraries (d3d10_1trace
183             common_trace
184             common
185             ${ZLIB_LIBRARIES}
186             ${SNAPPY_LIBRARIES}
187         )
188         set_target_properties (d3d10_1trace
189             PROPERTIES PREFIX ""
190             OUTPUT_NAME d3d10_1
191         )
192         install (TARGETS d3d10_1trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
193     endif ()
194
195     # d3d11.dll
196     if (DirectX_D3D11_INCLUDE_DIR)
197         if (DirectX_D3D11_1_INCLUDE_DIR)
198             set (HAVE_D3D11_1 1)
199         else ()
200             set (HAVE_D3D11_1 0)
201         endif ()
202
203         include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR})
204         add_custom_command (
205             OUTPUT d3d11trace.cpp
206             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp
207             DEPENDS
208                 d3d11trace.py
209                 dlltrace.py
210                 trace.py
211                 ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py
212                 ${CMAKE_SOURCE_DIR}/specs/d3d11.py
213                 ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py
214                 ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
215                 ${CMAKE_SOURCE_DIR}/specs/dxgi.py
216                 ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
217                 ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
218                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
219                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
220         )
221         add_library (d3d11trace MODULE d3d11.def d3d11trace.cpp)
222         target_link_libraries (d3d11trace
223             common_trace
224             common
225             ${ZLIB_LIBRARIES}
226             ${SNAPPY_LIBRARIES}
227         )
228         set_target_properties (d3d11trace
229             PROPERTIES PREFIX ""
230             OUTPUT_NAME d3d11
231         )
232         install (TARGETS d3d11trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
233     endif ()
234
235     # opengl32.dll
236     add_custom_command (
237         OUTPUT wgltrace.cpp
238         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
239         DEPENDS
240                 wgltrace.py
241                 gltrace.py
242                 trace.py
243                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
244                 ${CMAKE_SOURCE_DIR}/specs/wglapi.py
245                 ${CMAKE_SOURCE_DIR}/specs/wglenum.py
246                 ${CMAKE_SOURCE_DIR}/specs/glapi.py
247                 ${CMAKE_SOURCE_DIR}/specs/glparams.py
248                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
249                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
250                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
251     )
252     add_library (wgltrace MODULE opengl32.def
253         wgltrace.cpp
254         glcaps.cpp
255         gltrace_state.cpp
256     )
257     add_dependencies (wgltrace glproc)
258     target_link_libraries (wgltrace
259         glproc_gl
260         common_trace
261         common
262         ${ZLIB_LIBRARIES}
263         ${SNAPPY_LIBRARIES}
264     )
265     set_target_properties (wgltrace PROPERTIES
266         PREFIX ""
267         OUTPUT_NAME opengl32
268     )
269     install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
270
271 elseif (APPLE)
272     # OpenGL framework
273     add_custom_command (
274         OUTPUT cgltrace.cpp
275         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
276         DEPENDS
277             cgltrace.py
278             gltrace.py
279             trace.py
280             ${CMAKE_SOURCE_DIR}/specs/cglapi.py
281             ${CMAKE_SOURCE_DIR}/specs/glapi.py
282             ${CMAKE_SOURCE_DIR}/specs/glparams.py
283             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
284             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
285     )
286
287     add_library (cgltrace SHARED
288         cgltrace.cpp
289         glcaps.cpp
290         gltrace_state.cpp
291     )
292
293     add_dependencies (cgltrace glproc)
294
295     set_target_properties (cgltrace PROPERTIES
296         # OpenGL framework name
297         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
298         # Specificy the version and reexport GLU symbols
299         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
300     )
301
302     target_link_libraries (cgltrace
303         glproc_gl
304         common_trace
305         common
306         ${ZLIB_LIBRARIES}
307         ${SNAPPY_LIBRARIES}
308         ${CMAKE_THREAD_LIBS_INIT}
309         dl
310     )
311
312     install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
313 elseif (X11_FOUND)
314     # libGL.so
315     add_custom_command (
316         OUTPUT glxtrace.cpp
317         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
318         DEPENDS
319             glxtrace.py
320             gltrace.py
321             trace.py
322             ${CMAKE_SOURCE_DIR}/specs/glxapi.py
323             ${CMAKE_SOURCE_DIR}/specs/glapi.py
324             ${CMAKE_SOURCE_DIR}/specs/glparams.py
325             ${CMAKE_SOURCE_DIR}/specs/gltypes.py
326             ${CMAKE_SOURCE_DIR}/specs/stdapi.py
327     )
328
329     add_library (glxtrace SHARED
330         glxtrace.cpp
331         glcaps.cpp
332         gltrace_state.cpp
333     )
334
335     add_dependencies (glxtrace glproc)
336
337     set_target_properties (glxtrace PROPERTIES
338         # avoid the default "lib" prefix
339         PREFIX ""
340         # Prevent symbol relocations internal to our wrapper library to be
341         # overwritten by the application.
342         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
343     )
344
345     target_link_libraries (glxtrace
346         glproc_gl
347         common_trace
348         common
349         ${ZLIB_LIBRARIES}
350         ${SNAPPY_LIBRARIES}
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         ${CMAKE_SOURCE_DIR}/helpers/eglsize.cpp
381     )
382
383     add_dependencies (egltrace glproc)
384
385     set_target_properties (egltrace PROPERTIES
386         # avoid the default "lib" prefix
387         PREFIX ""
388         # Prevent symbol relocations internal to our wrapper library to be
389         # overwritten by the application.
390         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
391     )
392
393     target_link_libraries (egltrace
394         glproc_egl
395         common_trace
396         common
397         ${ZLIB_LIBRARIES}
398         ${SNAPPY_LIBRARIES}
399         ${CMAKE_THREAD_LIBS_INIT}
400         dl
401     )
402
403     install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
404 endif ()