1 cmake_minimum_required (VERSION 2.6)
5 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
7 find_package (PythonInterp REQUIRED)
8 find_package (OpenGL REQUIRED)
11 find_package (DirectX)
15 find_library (GLEW_glew_LIBRARY GLEW
19 find_path (GLEW_INCLUDE_DIR GL/glew.h
23 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
24 # Nobody likes to include windows.h:
25 # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
26 # - GLEW temporarily defines the necessary defines but undefines them later
27 # - certain GLUT distributions don't include it;
28 # - most of our programs are meant to be portable so don't include it.
30 # We could try to replicate the windows.h definitions required by
31 # GL/gl.h, but the build time savings don't compensate the constant
32 # headaches that brings, so instead we force windows.h to be included
35 add_definitions (-FIwindows.h)
37 add_definitions (--include windows.h)
40 # MSVC & MinGW only define & use APIENTRY
41 add_definitions (-DGLAPIENTRY=__stdcall)
43 link_libraries (winmm)
44 endif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
47 # Enable math constants defines
48 add_definitions (-D_USE_MATH_DEFINES)
51 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
52 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
54 add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
55 add_definitions (-wd4505) # unreferenced local function has been removed
56 add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
58 add_definitions (-Wall)
61 # Use bundled ZLIB if system one can't be found
63 add_library (zlib STATIC
78 include_directories (zlib)
81 include_directories (${ZLIB_INCLUDE_DIRS})
82 link_libraries (${ZLIB_LIBRARIES})
83 endif (NOT ZLIB_FOUND)
85 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
87 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
90 include_directories (${D3D8_INCLUDE_DIR})
93 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp
94 DEPENDS d3d8.py d3d8types.py d3d8caps.py windows.py base.py
96 add_library (d3d8 SHARED d3d8.def d3d8.cpp log.cpp os_win32.cpp)
97 set_target_properties (d3d8 PROPERTIES PREFIX "")
102 include_directories (${D3DX9_INCLUDE_DIR})
105 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp
106 DEPENDS d3d9.py d3d9types.py d3d9caps.py d3dshader.py windows.py base.py
108 add_library (d3d9 SHARED d3d9.def d3d9.cpp log.cpp os_win32.cpp)
109 set_target_properties (d3d9 PROPERTIES PREFIX "")
114 include_directories (${D3D10_INCLUDE_DIR})
117 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp
118 DEPENDS d3d10misc.py windows.py base.py
120 add_library (d3d10 SHARED d3d10.def d3d10.cpp log.cpp os_win32.cpp)
121 set_target_properties (d3d10 PROPERTIES PREFIX "")
127 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.py > ${CMAKE_CURRENT_BINARY_DIR}/opengl32.cpp
128 DEPENDS opengl32.py gl.py windows.py base.py
130 add_library (opengl32 SHARED opengl32.def opengl32.cpp log.cpp os_win32.cpp)
131 set_target_properties (opengl32 PROPERTIES PREFIX "")
138 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glx.py > ${CMAKE_CURRENT_BINARY_DIR}/glx.cpp
139 DEPENDS glx.py gl.py dl.py base.py
141 add_library (glxtrace SHARED glx.cpp log.cpp os_posix.cpp)
142 set_target_properties (glxtrace PROPERTIES PREFIX "")
143 target_link_libraries (glxtrace dl)
146 add_executable (dump dump.cpp trace_model.cpp)
149 if (GLEW_INCLUDE_DIR)
152 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
153 DEPENDS glretrace.py glx.py gl.py dl.py base.py
156 include_directories (
157 ${OPENGL_INCLUDE_PATH}
162 add_executable (glretrace glretrace.cpp trace_model.cpp)
164 target_link_libraries (glretrace
166 ${OPENGL_glu_LIBRARY}
170 endif (GLEW_INCLUDE_DIR)