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