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 # C99 includes for msvc
39 include_directories (msvc)
41 # Enable math constants defines
42 add_definitions (-D_USE_MATH_DEFINES)
45 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
46 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
48 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
49 add_definitions (-wd4505) # unreferenced local function has been removed
50 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
51 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
52 add_definitions (-wd4018) # signed/unsigned mismatch
55 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
57 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
58 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
60 if (${flag_var} MATCHES "/MD")
61 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
62 endif (${flag_var} MATCHES "/MD")
66 add_definitions (-Wall)
67 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
68 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
71 # Use bundled ZLIB if system one can't be found
73 include_directories (${ZLIB_INCLUDE_DIRS})
74 link_libraries (${ZLIB_LIBRARIES})
76 add_library (zlib STATIC
90 include_directories (zlib)
94 # Use bundled LIBPNG if system one can't be found
96 include_directories (${PNG_INCLUDE_DIR})
97 add_definitions (${PNG_DEFINITIONS})
98 link_libraries (${PNG_LIBRARIES})
100 add_library (png STATIC
117 include_directories (libpng)
121 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
124 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
125 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
126 DEPENDS glproc.py dispatch.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
130 # Put wrappers in a separate directory
131 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
134 #if (DirectX_D3D8_FOUND)
135 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
136 # add_custom_command (
138 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
139 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
141 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
142 # set_target_properties (d3d8 PROPERTIES PREFIX "")
143 #endif (DirectX_D3D8_FOUND)
146 if (DirectX_D3DX9_FOUND)
147 include_directories (${DirectX_D3DX9_INCLUDE_DIR})
150 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
151 DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
153 add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
154 set_target_properties (d3d9 PROPERTIES PREFIX "")
155 endif (DirectX_D3DX9_FOUND)
158 #if (DirectX_D3D10_FOUND)
159 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
160 # add_custom_command (
162 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
163 # DEPENDS d3d10misc.py winapi.py stdapi.py
165 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
166 # set_target_properties (d3d10 PROPERTIES PREFIX "")
167 #endif (DirectX_D3D10_FOUND)
172 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
173 DEPENDS wgltrace.py gltrace.py trace.py wglapi.py wglenum.py glapi.py glenum.py winapi.py stdapi.py
175 add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
176 set_target_properties (opengl PROPERTIES
178 OUTPUT_NAME opengl32)
180 set_target_properties(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
184 include_directories (${X11_INCLUDE_DIR})
189 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
190 DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py
193 add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
195 set_target_properties (glxtrace PROPERTIES
199 target_link_libraries (glxtrace dl)
203 set (os os_win32.cpp)
204 set (glws glws_wgl.cpp)
206 set (os os_posix.cpp)
207 set (glws glws_glx.cpp)
210 add_library (trace trace_model.cpp trace_parser.cpp ${os})
212 add_executable (dump dump.cpp)
213 target_link_libraries (dump trace)
216 OUTPUT glretrace_gl.cpp
217 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
218 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
222 OUTPUT glretrace_state.cpp
223 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_state.cpp
224 DEPENDS glstate.py glapi.py glenum.py stdapi.py
227 include_directories (
228 ${CMAKE_CURRENT_BINARY_DIR}
229 ${OPENGL_INCLUDE_PATH}
232 add_executable (glretrace
239 ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
245 PROPERTY COMPILE_DEFINITIONS "RETRACE"
248 target_link_libraries (glretrace
251 ${OPENGL_glu_LIBRARY}
256 target_link_libraries (glretrace ${X11_LIBRARIES})
259 if (QT4_FOUND AND QJSON_FOUND)
260 add_subdirectory(gui)
261 endif (QT4_FOUND AND QJSON_FOUND)