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
28 find_package (DirectX)
34 # MSVC & MinGW only define & use APIENTRY
35 add_definitions (-DGLAPIENTRY=__stdcall)
39 # Enable math constants defines
40 add_definitions (-D_USE_MATH_DEFINES)
43 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
44 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
46 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
47 add_definitions (-wd4505) # unreferenced local function has been removed
48 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
49 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
50 add_definitions (-wd4018) # signed/unsigned mismatch
53 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
55 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
56 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
58 if (${flag_var} MATCHES "/MD")
59 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
60 endif (${flag_var} MATCHES "/MD")
64 add_definitions (-Wall)
65 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
66 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
69 # Use bundled ZLIB if system one can't be found
71 include_directories (${ZLIB_INCLUDE_DIRS})
72 link_libraries (${ZLIB_LIBRARIES})
74 add_library (zlib STATIC
88 include_directories (zlib)
92 # Use bundled LIBPNG if system one can't be found
94 include_directories (${PNG_INCLUDE_DIR})
95 add_definitions (${PNG_DEFINITIONS})
96 link_libraries (${PNG_LIBRARIES})
98 add_library (png STATIC
115 include_directories (libpng)
119 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
122 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
123 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
124 DEPENDS glproc.py dispatch.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
128 # Put wrappers in a separate directory
129 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
132 #if (DirectX_D3D8_FOUND)
133 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
134 # add_custom_command (
136 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
137 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
139 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
140 # set_target_properties (d3d8 PROPERTIES PREFIX "")
141 #endif (DirectX_D3D8_FOUND)
144 if (DirectX_D3DX9_FOUND)
145 include_directories (${DirectX_D3DX9_INCLUDE_DIR})
148 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
149 DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
151 add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
152 set_target_properties (d3d9 PROPERTIES PREFIX "")
153 endif (DirectX_D3DX9_FOUND)
156 #if (DirectX_D3D10_FOUND)
157 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
158 # add_custom_command (
160 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
161 # DEPENDS d3d10misc.py winapi.py stdapi.py
163 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
164 # set_target_properties (d3d10 PROPERTIES PREFIX "")
165 #endif (DirectX_D3D10_FOUND)
170 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
171 DEPENDS wgltrace.py gltrace.py trace.py wglapi.py wglenum.py glapi.py glenum.py winapi.py stdapi.py
173 add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
174 set_target_properties (opengl PROPERTIES
176 OUTPUT_NAME opengl32)
178 set_target_properties(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
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 set_target_properties (glxtrace PROPERTIES
192 COMPILER_DEFINITIONS "-DRETRACE"
195 target_link_libraries (glxtrace dl)
199 set (os os_win32.cpp)
201 set (os os_posix.cpp)
204 add_library (trace trace_model.cpp trace_parser.cpp ${os})
206 add_executable (dump dump.cpp)
207 target_link_libraries (dump trace)
209 if (GLUT_INCLUDE_DIR)
212 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
213 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
218 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate.cpp
219 DEPENDS glstate.py glenum.py stdapi.py
222 include_directories (
223 ${CMAKE_CURRENT_BINARY_DIR}
224 ${OPENGL_INCLUDE_PATH}
228 add_executable (glretrace
232 ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
235 target_link_libraries (glretrace
238 ${OPENGL_glu_LIBRARY}
241 endif (GLUT_INCLUDE_DIR)
243 if (QT4_FOUND AND QJSON_FOUND)
244 # Include the cmake file needed to use qt4
245 include( ${QT_USE_FILE} )
246 add_subdirectory(gui)
247 endif (QT4_FOUND AND QJSON_FOUND)