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