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