1 cmake_minimum_required (VERSION 2.6)
5 find_package (PythonInterp REQUIRED)
6 find_package (OpenGL REQUIRED)
11 find_library (GLEW_glew_LIBRARY GLEW
15 find_path (GLEW_INCLUDE_DIR GL/glew.h
19 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
20 # Nobody likes to include windows.h:
21 # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
22 # - GLEW temporarily defines the necessary defines but undefines them later
23 # - certain GLUT distributions don't include it;
24 # - most of our programs are meant to be portable so don't include it.
26 # We could try to replicate the windows.h definitions required by
27 # GL/gl.h, but the build time savings don't compensate the constant
28 # headaches that brings, so instead we force windows.h to be included
31 add_definitions (-FIwindows.h)
33 add_definitions (--include windows.h)
36 # MSVC & MinGW only define & use APIENTRY
37 add_definitions (-DGLAPIENTRY=__stdcall)
39 link_libraries (winmm)
40 endif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
43 # Enable math constants defines
44 add_definitions (-D_USE_MATH_DEFINES)
46 # Silence several MSVC pedantic warnings
47 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
48 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
52 add_definitions (-Wall)
55 # Use bundled ZLIB if system one can't be found
57 add_library (zlib STATIC
72 include_directories (zlib)
75 include_directories (${ZLIB_INCLUDE_DIRS})
76 link_libraries (${ZLIB_LIBRARIES})
77 endif (NOT ZLIB_FOUND)
79 include_directories (${CMAKE_CURRENT_SOURCE_DIR})
81 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
86 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/opengl32.py > ${CMAKE_CURRENT_BINARY_DIR}/opengl32.cpp
87 DEPENDS opengl32.py gl.py windows.py base.py
89 add_library (opengl32 SHARED opengl32.def opengl32.cpp log.cpp os_win32.cpp)
90 set_target_properties (opengl32 PROPERTIES PREFIX "")
97 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glx.py > ${CMAKE_CURRENT_BINARY_DIR}/glx.cpp
98 DEPENDS glx.py gl.py dl.py base.py
100 add_library (glxtrace SHARED glx.cpp log.cpp os_posix.cpp)
101 set_target_properties (glxtrace PROPERTIES PREFIX "")
102 target_link_libraries (glxtrace dl)
105 add_executable (dump dump.cpp trace_model.cpp)
108 if (GLEW_INCLUDE_DIR)
111 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace.cpp
112 DEPENDS glretrace.py glx.py gl.py dl.py base.py
115 include_directories (
116 ${OPENGL_INCLUDE_PATH}
121 add_executable (glretrace glretrace.cpp trace_model.cpp)
123 target_link_libraries (glretrace
125 ${OPENGL_glu_LIBRARY}
129 endif (GLEW_INCLUDE_DIR)