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)
32 # MSVC & MinGW only define & use APIENTRY
33 add_definitions (-DGLAPIENTRY=__stdcall)
37 # Enable math constants defines
38 add_definitions (-D_USE_MATH_DEFINES)
41 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
42 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
44 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
45 add_definitions (-wd4505) # unreferenced local function has been removed
46 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
47 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
48 add_definitions (-wd4018) # signed/unsigned mismatch
51 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
53 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
54 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
56 if (${flag_var} MATCHES "/MD")
57 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
58 endif (${flag_var} MATCHES "/MD")
62 add_definitions (-Wall)
63 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
64 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
67 # Use bundled ZLIB if system one can't be found
69 include_directories (${ZLIB_INCLUDE_DIRS})
70 link_libraries (${ZLIB_LIBRARIES})
72 add_library (zlib STATIC
86 include_directories (zlib)
90 # Use bundled LIBPNG if system one can't be found
92 include_directories (${PNG_INCLUDE_DIR})
93 add_definitions (${PNG_DEFINITIONS})
94 link_libraries (${PNG_LIBRARIES})
96 add_library (png STATIC
113 include_directories (libpng)
117 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
120 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
121 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
122 DEPENDS glproc.py dispatch.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
126 # Put wrappers in a separate directory
127 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
130 #if (DirectX_D3D8_FOUND)
131 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
132 # add_custom_command (
134 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
135 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
137 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
138 # set_target_properties (d3d8 PROPERTIES PREFIX "")
139 #endif (DirectX_D3D8_FOUND)
142 if (DirectX_D3DX9_FOUND)
143 include_directories (${DirectX_D3DX9_INCLUDE_DIR})
146 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
147 DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
149 add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
150 set_target_properties (d3d9 PROPERTIES PREFIX "")
151 endif (DirectX_D3DX9_FOUND)
154 #if (DirectX_D3D10_FOUND)
155 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
156 # add_custom_command (
158 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
159 # DEPENDS d3d10misc.py winapi.py stdapi.py
161 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
162 # set_target_properties (d3d10 PROPERTIES PREFIX "")
163 #endif (DirectX_D3D10_FOUND)
168 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
169 DEPENDS wgltrace.py gltrace.py trace.py wglapi.py wglenum.py glapi.py glenum.py winapi.py stdapi.py
171 add_library (opengl SHARED opengl32.def wgltrace.cpp trace_write.cpp os_win32.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
172 set_target_properties (opengl PROPERTIES
174 OUTPUT_NAME opengl32)
176 set_target_properties(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
184 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
185 DEPENDS glxtrace.py gltrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py
188 add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
189 target_link_libraries (glxtrace dl)
193 set (os os_win32.cpp)
194 set (glws glws_wgl.cpp)
196 set (os os_posix.cpp)
197 set (glws glws_glx.cpp)
200 add_library (trace trace_model.cpp trace_parser.cpp ${os})
202 add_executable (dump dump.cpp)
203 target_link_libraries (dump trace)
207 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
208 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
213 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate.cpp
214 DEPENDS glstate.py glenum.py stdapi.py
217 include_directories (
218 ${CMAKE_CURRENT_BINARY_DIR}
219 ${OPENGL_INCLUDE_PATH}
222 add_executable (glretrace
227 ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
233 PROPERTY COMPILE_DEFINITIONS "RETRACE"
236 target_link_libraries (glretrace
239 ${OPENGL_glu_LIBRARY}
242 if (QT4_FOUND AND QJSON_FOUND)
243 add_subdirectory(gui)
244 endif (QT4_FOUND AND QJSON_FOUND)