1 cmake_minimum_required (VERSION 2.6)
5 find_package (PythonInterp REQUIRED)
6 find_package (OpenGL REQUIRED)
10 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
11 # Nobody likes to include windows.h:
12 # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
13 # - GLEW temporarily defines the necessary defines but undefines them later
14 # - certain GLUT distributions don't include it;
15 # - most of our programs are meant to be portable so don't include it.
17 # We could try to replicate the windows.h definitions required by
18 # GL/gl.h, but the build time savings don't compensate the constant
19 # headaches that brings, so instead we force windows.h to be included
22 add_definitions (-FIwindows.h)
24 add_definitions (--include windows.h)
27 # MSVC & MinGW only define & use APIENTRY
28 add_definitions (-DGLAPIENTRY=__stdcall)
30 link_libraries (winmm)
31 endif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
34 # Enable math constants defines
35 add_definitions (-D_USE_MATH_DEFINES)
37 # Silence several MSVC pedantic warnings
38 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
39 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
42 # Use bundled ZLIB if system one can't be found
44 add_library (zlib STATIC
59 include_directories (zlib)
62 include_directories (${ZLIB_INCLUDE_DIRS})
63 link_libraries (${ZLIB_LIBRARIES})
64 endif (NOT ZLIB_FOUND)
66 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
68 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
73 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.py > ${CMAKE_CURRENT_BINARY_DIR}/opengl32.cpp
74 DEPENDS opengl32.py gl.py windows.py base.py
76 add_library (opengl32 SHARED opengl32.def opengl32.cpp log.cpp)
77 set_target_properties (opengl32 PROPERTIES PREFIX "")
84 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glx.py > ${CMAKE_CURRENT_BINARY_DIR}/glx.cpp
85 DEPENDS glx.py gl.py dl.py base.py
87 add_library (glxtrace SHARED glx.cpp log.cpp)
88 set_target_properties (glxtrace PROPERTIES PREFIX "")
89 target_link_libraries (glxtrace dl)