1 cmake_minimum_required (VERSION 2.8)
5 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
7 # Set default built type
8 if (NOT CMAKE_BUILD_TYPE)
9 set (CMAKE_BUILD_TYPE Debug
11 STRING "Choose the build type, options are: None, Debug, Release, RelWithDebInfo, or MinSizeRel."
13 endif (NOT CMAKE_BUILD_TYPE)
15 set (CMAKE_USE_PYTHON_VERSION 2.6)
17 find_package (PythonInterp REQUIRED)
18 find_package (OpenGL REQUIRED)
19 find_package (Qt4 COMPONENTS QtCore QtGui QtWebKit)
23 # Always use the bundled zlib and libpng sources on Windows to make it easy
24 # to deploy the wrappers DLLs
27 find_package (X11 REQUIRED)
29 find_package (DirectX)
33 # MSVC & MinGW only define & use APIENTRY
34 add_definitions (-DGLAPIENTRY=__stdcall)
38 # Enable math constants defines
39 add_definitions (-D_USE_MATH_DEFINES)
42 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
43 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
45 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
46 add_definitions (-wd4505) # unreferenced local function has been removed
47 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
48 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
49 add_definitions (-wd4018) # signed/unsigned mismatch
52 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
54 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
55 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
57 if (${flag_var} MATCHES "/MD")
58 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
59 endif (${flag_var} MATCHES "/MD")
63 add_definitions (-Wall)
64 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
65 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
68 # Use bundled ZLIB if system one can't be found
70 include_directories (${ZLIB_INCLUDE_DIRS})
71 link_libraries (${ZLIB_LIBRARIES})
73 add_library (zlib STATIC
87 include_directories (zlib)
91 # Use bundled LIBPNG if system one can't be found
93 include_directories (${PNG_INCLUDE_DIR})
94 add_definitions (${PNG_DEFINITIONS})
95 link_libraries (${PNG_LIBRARIES})
97 add_library (png STATIC
114 include_directories (libpng)
118 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
121 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
122 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
123 DEPENDS glproc.py dispatch.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
127 # Put wrappers in a separate directory
128 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
131 #if (DirectX_D3D8_FOUND)
132 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
133 # add_custom_command (
135 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
136 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
138 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
139 # set_target_properties (d3d8 PROPERTIES PREFIX "")
140 #endif (DirectX_D3D8_FOUND)
143 if (DirectX_D3DX9_FOUND)
144 include_directories (${DirectX_D3DX9_INCLUDE_DIR})
147 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
148 DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
150 add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
151 set_target_properties (d3d9 PROPERTIES PREFIX "")
152 endif (DirectX_D3DX9_FOUND)
155 #if (DirectX_D3D10_FOUND)
156 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
157 # add_custom_command (
159 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
160 # DEPENDS d3d10misc.py winapi.py stdapi.py
162 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
163 # set_target_properties (d3d10 PROPERTIES PREFIX "")
164 #endif (DirectX_D3D10_FOUND)
169 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
170 DEPENDS wgltrace.py gltrace.py trace.py wglapi.py wglenum.py glapi.py glenum.py winapi.py stdapi.py
172 add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
173 set_target_properties (opengl PROPERTIES
175 OUTPUT_NAME opengl32)
177 set_target_properties(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
181 include_directories (${X11_INCLUDE_DIR})
186 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
187 DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py
190 add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
191 target_link_libraries (glxtrace dl)
195 set (os os_win32.cpp)
196 set (glws glws_wgl.cpp)
198 set (os os_posix.cpp)
199 set (glws glws_glx.cpp)
202 add_library (trace trace_model.cpp trace_parser.cpp ${os})
204 add_executable (dump dump.cpp)
205 target_link_libraries (dump trace)
208 OUTPUT glretrace_gl.cpp
209 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
210 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
214 OUTPUT glretrace_state.cpp
215 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_state.cpp
216 DEPENDS glstate.py glenum.py stdapi.py
219 include_directories (
220 ${CMAKE_CURRENT_BINARY_DIR}
221 ${OPENGL_INCLUDE_PATH}
224 add_executable (glretrace
231 ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
237 PROPERTY COMPILE_DEFINITIONS "RETRACE"
240 target_link_libraries (glretrace
243 ${OPENGL_glu_LIBRARY}
248 target_link_libraries (glretrace ${X11_LIBRARIES})
251 if (QT4_FOUND AND QJSON_FOUND)
252 add_subdirectory(gui)
253 endif (QT4_FOUND AND QJSON_FOUND)