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 find_package (PythonInterp REQUIRED)
16 find_package (OpenGL REQUIRED)
19 find_package (DirectX)
24 # MSVC & MinGW only define & use APIENTRY
25 add_definitions (-DGLAPIENTRY=__stdcall)
29 # Enable math constants defines
30 add_definitions (-D_USE_MATH_DEFINES)
33 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
34 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
36 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
37 add_definitions (-wd4505) # unreferenced local function has been removed
38 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
39 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
40 add_definitions (-wd4018) # signed/unsigned mismatch
43 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
45 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
46 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
48 if (${flag_var} MATCHES "/MD")
49 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
50 endif (${flag_var} MATCHES "/MD")
54 include_directories (c99)
57 add_definitions (-Wall)
58 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
59 add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
62 # Use bundled ZLIB if system one can't be found
64 add_library (zlib STATIC
79 include_directories (zlib)
82 include_directories (${ZLIB_INCLUDE_DIRS})
83 link_libraries (${ZLIB_LIBRARIES})
84 endif (NOT ZLIB_FOUND)
86 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
89 # Put wrappers in a separate directory
90 set (LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/wrappers)
93 #if (DirectX_D3D8_FOUND)
94 # include_directories (${DirectX_D3D8_INCLUDE_DIR})
95 # add_custom_command (
97 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
98 # DEPENDS d3d8.py d3d8types.py d3d8caps.py winapi.py stdapi.py
100 # add_library (d3d8 SHARED d3d8.def d3d8.cpp trace_write.cpp os_win32.cpp)
101 # set_target_properties (d3d8 PROPERTIES PREFIX "")
102 #endif (DirectX_D3D8_FOUND)
105 #if (DirectX_D3DX9_FOUND)
106 # include_directories (${DirectX_D3DX9_INCLUDE_DIR})
107 # add_custom_command (
109 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
110 # DEPENDS d3d9.py d3d9types.py d3d9caps.py d3dshader.py winapi.py stdapi.py
112 # add_library (d3d9 SHARED d3d9.def d3d9.cpp trace_write.cpp os_win32.cpp)
113 # set_target_properties (d3d9 PROPERTIES PREFIX "")
114 #endif (DirectX_D3DX9_FOUND)
117 #if (DirectX_D3D10_FOUND)
118 # include_directories (${DirectX_D3D10_INCLUDE_DIR})
119 # add_custom_command (
121 # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
122 # DEPENDS d3d10misc.py winapi.py stdapi.py
124 # add_library (d3d10 SHARED d3d10.def d3d10.cpp trace_write.cpp os_win32.cpp)
125 # set_target_properties (d3d10 PROPERTIES PREFIX "")
126 #endif (DirectX_D3D10_FOUND)
131 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/opengl32.cpp
132 DEPENDS wgltrace.py trace.py wglapi.py glapi.py glenum.py winapi.py stdapi.py
134 add_library (opengl SHARED opengl32.def opengl32.cpp trace_write.cpp os_win32.cpp)
135 set_target_properties (opengl PROPERTIES
137 OUTPUT_NAME opengl32)
139 SET_TARGET_PROPERTIES(opengl PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.def")
147 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
148 DEPENDS glxtrace.py trace.py glxapi.py glapi.py glenum.py stdapi.py
151 add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp)
152 set_target_properties (glxtrace PROPERTIES PREFIX "")
153 target_link_libraries (glxtrace dl)
156 add_executable (dump dump.cpp trace_model.cpp)
159 set (os os_win32.cpp)
161 set (os os_posix.cpp)
164 if (GLUT_INCLUDE_DIR)
166 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
167 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
168 DEPENDS glproc.py wglapi.py glxapi.py glapi.py glenum.py stdapi.py
173 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
174 DEPENDS glretrace.py retrace.py codegen.py glapi.py glenum.py stdapi.py
177 include_directories (
178 ${CMAKE_CURRENT_BINARY_DIR}
179 ${OPENGL_INCLUDE_PATH}
183 add_executable (glretrace glretrace.cpp trace_model.cpp ${os} ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
185 target_link_libraries (glretrace
187 ${OPENGL_glu_LIBRARY}
190 endif (GLUT_INCLUDE_DIR)