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 (-DNOMINMAX)
48 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
49 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
51 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
52 add_definitions (-wd4505) # unreferenced local function has been removed
53 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
54 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
55 add_definitions (-wd4018) # signed/unsigned mismatch
58 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
60 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
61 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
63 if (${flag_var} MATCHES "/MD")
64 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
65 endif (${flag_var} MATCHES "/MD")
69 add_definitions (-Wall)
70 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
71 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
74 # Use bundled ZLIB if system one can't be found
76 include_directories (${ZLIB_INCLUDE_DIRS})
77 link_libraries (${ZLIB_LIBRARIES})
79 add_library (zlib STATIC
93 include_directories (zlib)
97 # Use bundled LIBPNG if system one can't be found
99 include_directories (${PNG_INCLUDE_DIR})
100 add_definitions (${PNG_DEFINITIONS})
101 link_libraries (${PNG_LIBRARIES})
103 add_library (png STATIC
120 include_directories (libpng)
124 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
127 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
128 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
129 DEPENDS glproc.py dispatch.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
133 # Put wrappers in a separate directory
134 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
137 #if (DirectX_D3D8_FOUND)
138 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
139 # add_custom_command (
141 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
142 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
144 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
145 # set_target_properties (d3d8 PROPERTIES PREFIX "")
146 #endif (DirectX_D3D8_FOUND)
149 if (DirectX_D3DX9_FOUND)
150 include_directories (${DirectX_D3DX9_INCLUDE_DIR})
153 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
154 DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
156 add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
157 set_target_properties (d3d9 PROPERTIES PREFIX "")
158 endif (DirectX_D3DX9_FOUND)
161 #if (DirectX_D3D10_FOUND)
162 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
163 # add_custom_command (
165 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
166 # DEPENDS d3d10misc.py winapi.py stdapi.py
168 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
169 # set_target_properties (d3d10 PROPERTIES PREFIX "")
170 #endif (DirectX_D3D10_FOUND)
175 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
176 DEPENDS wgltrace.py gltrace.py trace.py wglapi.py wglenum.py glapi.py glenum.py winapi.py stdapi.py
178 add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
179 set_target_properties (opengl PROPERTIES
181 OUTPUT_NAME opengl32)
183 set_target_properties(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
187 include_directories (${X11_INCLUDE_DIR})
192 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
193 DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py
196 add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
198 set_target_properties (glxtrace PROPERTIES
202 target_link_libraries (glxtrace dl)
206 set (os os_win32.cpp)
207 set (glws glws_wgl.cpp)
209 set (os os_posix.cpp)
210 set (glws glws_glx.cpp)
213 add_library (trace trace_model.cpp trace_parser.cpp trace_write.cpp ${os})
215 add_executable (tracedump tracedump.cpp)
216 target_link_libraries (tracedump trace)
219 OUTPUT glretrace_gl.cpp
220 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
221 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
225 OUTPUT glretrace_state.cpp
226 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_state.cpp
227 DEPENDS glstate.py glapi.py glenum.py stdapi.py
230 include_directories (
231 ${CMAKE_CURRENT_BINARY_DIR}
232 ${OPENGL_INCLUDE_PATH}
235 add_executable (glretrace
242 ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
248 PROPERTY COMPILE_DEFINITIONS "RETRACE"
251 target_link_libraries (glretrace
254 ${OPENGL_glu_LIBRARY}
259 target_link_libraries (glretrace ${X11_LIBRARIES})
262 if (QT4_FOUND AND QJSON_FOUND)
263 add_subdirectory(gui)
264 endif (QT4_FOUND AND QJSON_FOUND)