]> git.cworth.org Git - apitrace/blob - retrace/CMakeLists.txt
644fe987d4e17a85d46d39edb01e87293ab11378
[apitrace] / retrace / CMakeLists.txt
1 ##############################################################################
2 # API retracers
3
4 include_directories (
5     ${CMAKE_CURRENT_SOURCE_DIR}
6     ${CMAKE_BINARY_DIR}/dispatch
7 )
8
9 add_definitions (-DRETRACE)
10
11 add_custom_command (
12     OUTPUT glretrace_gl.cpp
13     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
14     DEPENDS
15                 glretrace.py
16                 retrace.py
17                 ${CMAKE_SOURCE_DIR}/specs/glapi.py
18                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
19                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
20 )
21
22 add_custom_command (
23     OUTPUT glstate_params.cpp
24     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp
25     DEPENDS
26                 glstate_params.py
27                 ${CMAKE_SOURCE_DIR}/specs/glparams.py
28                 ${CMAKE_SOURCE_DIR}/specs/gltypes.py
29                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
30 )
31
32 add_library (retrace_common
33     glretrace_gl.cpp
34     glretrace_cgl.cpp
35     glretrace_glx.cpp
36     glretrace_wgl.cpp
37     glretrace_egl.cpp
38     glretrace_main.cpp
39     glstate.cpp
40     glstate_images.cpp
41     glstate_params.cpp
42     glstate_shaders.cpp
43     retrace.cpp
44     retrace_stdc.cpp
45     glws.cpp
46 )
47
48 add_dependencies (retrace_common glproc)
49
50 if (WIN32 OR APPLE OR X11_FOUND)
51     add_executable (glretrace
52         ${glws_os}
53     )
54
55     add_dependencies (glretrace glproc)
56
57     target_link_libraries (glretrace
58         retrace_common
59         glproc_gl
60         common
61         ${PNG_LIBRARIES}
62         ${ZLIB_LIBRARIES}
63         ${SNAPPY_LIBRARIES}
64     )
65
66     if (WIN32)
67     else ()
68         if (APPLE)
69             target_link_libraries (glretrace
70                 "-framework Cocoa"
71                 "-framework ApplicationServices" # CGS*
72                 #"-framework OpenGL" # CGL*
73             )
74         else ()
75             target_link_libraries (glretrace ${X11_X11_LIB})
76         endif ()
77
78         target_link_libraries (glretrace
79             # gdb doesn't like when pthreads is loaded through dlopen (which happens
80             # when dlopen'ing libGL), so link pthreads to avoid this issue.  See also
81             # http://stackoverflow.com/questions/2702628/gdb-cannot-find-new-threads-generic-error
82             ${CMAKE_THREAD_LIBS_INIT}
83             dl
84         )
85
86         if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
87             target_link_libraries (glretrace rt)
88         endif ()
89
90     endif ()
91
92     install (TARGETS glretrace RUNTIME DESTINATION bin) 
93 endif ()
94
95 if (ENABLE_EGL AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
96     add_executable (eglretrace
97         glws_egl_xlib.cpp
98     )
99
100     add_dependencies (eglretrace glproc)
101
102     target_link_libraries (eglretrace
103         retrace_common
104         glproc_egl
105         common
106         ${PNG_LIBRARIES}
107         ${ZLIB_LIBRARIES}
108         ${SNAPPY_LIBRARIES}
109         ${X11_X11_LIB}
110         ${CMAKE_THREAD_LIBS_INIT}
111         dl
112     )
113
114     if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
115         target_link_libraries (eglretrace rt)
116     endif ()
117
118     install (TARGETS eglretrace RUNTIME DESTINATION bin) 
119 endif ()
120
121 if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
122     add_custom_command (
123         OUTPUT d3dretrace_d3d9.cpp
124         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3dretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp
125         DEPENDS
126                 d3dretrace.py
127                 dllretrace.py
128                 retrace.py
129                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
130                 ${CMAKE_SOURCE_DIR}/specs/d3d9.py
131                 ${CMAKE_SOURCE_DIR}/specs/d3d9types.py
132                 ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py
133                 ${CMAKE_SOURCE_DIR}/specs/winapi.py
134                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
135     )
136
137     include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
138     add_executable (d3dretrace
139         retrace.cpp
140         retrace_stdc.cpp
141         d3dretrace_main.cpp
142         d3dretrace_d3d9.cpp
143     )
144     target_link_libraries (d3dretrace
145         common
146         ${ZLIB_LIBRARIES}
147         ${SNAPPY_LIBRARIES}
148     )
149 endif ()
150