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