1 cmake_minimum_required (VERSION 2.8)
5 include (FindPkgConfig)
6 include (CheckCCompilerFlag)
8 find_package (OpenGL REQUIRED)
9 find_package (GLUT REQUIRED)
12 find_library (GLEW_glew_LIBRARY GLEW
16 find_path (GLEW_INCLUDE_DIR GL/glew.h
20 if (PKG_CONFIG_FOUND AND NOT WIN32)
21 pkg_check_modules (GLEW REQUIRED glew>=1.5.4)
22 pkg_check_modules (EGL egl)
23 pkg_check_modules (GLESV1 glesv1_cm)
24 pkg_check_modules (GLESV2 glesv2)
25 pkg_check_modules (VG vg)
32 # On Mac OS X, GLX is provided as a separate OpenGL implementation, different
33 # from the standard OpenGL framework which provides support for GLUT and native
34 # Mac OS X applications.
37 find_path (X11_GL_INCLUDE_PATH GL/glx.h ${X11_INC_SEARCH_PATH})
38 if (NOT X11_GL_INCLUDE_PATH)
39 message (WARNING "Could not find GL/glx.h")
41 endif (NOT X11_GL_INCLUDE_PATH)
42 set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_GL_INCLUDE_PATH})
44 find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
46 message (WARNING "Could not find libGL.dylib")
48 endif (NOT X11_GL_LIB)
50 find_library (X11_GLU_LIB GLU ${X11_LIB_SEARCH_PATH})
52 message (WARNING "Could not find libGLU.dylib")
54 endif (NOT X11_GLU_LIB)
56 set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
57 set (X11_GL_LIB ${OPENGL_gl_LIBRARY})
58 set (X11_GLU_LIB ${OPENGL_glu_LIBRARY})
62 if (CMAKE_COMPILER_IS_GNUCC)
68 -Wmissing-declarations
72 #-Wold-style-definition
73 #-Wdeclaration-after-statement
75 endif (CMAKE_COMPILER_IS_GNUCC)
78 # Nobody likes to include windows.h:
79 # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
80 # - GLEW temporarily defines the necessary defines but undefines them later
81 # - certain GLUT distributions don't include it;
82 # - most of our programs are meant to be portable so don't include it.
84 # We could try to replicate the windows.h definitions required by
85 # GL/gl.h, but the build time savings don't compensate the constant
86 # headaches that brings, so instead we force windows.h to be included
89 add_definitions (-FIwindows.h)
91 add_definitions (--include windows.h)
94 # Don't define min/max macros
95 add_definitions (-DNOMINMAX)
97 # MSVC & MinGW only define & use APIENTRY
98 add_definitions (-DGLAPIENTRY=__stdcall)
100 link_libraries (winmm)
104 # Enable math constants defines
105 add_definitions (-D_USE_MATH_DEFINES)
107 # Silence several MSVC pedantic warnings
108 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
109 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
110 add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
114 # Avoid depending on MinGW runtime DLLs
115 check_c_compiler_flag (-static-libgcc HAVE_STATIC_LIBGCC_FLAG)
116 if (HAVE_STATIC_LIBGCC_FLAG)
117 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
118 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
119 set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc")
121 check_c_compiler_flag (-static-libstdc++ HAVE_STATIC_LIBSTDCXX_FLAG)
122 if (HAVE_STATIC_LIBSTDCXX_FLAG)
123 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
124 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
125 set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libstdc++")
129 add_definitions(-DDEMOS_DATA_DIR=\"../data/\")
131 if (BUILD_SHARED_LIBS AND NOT DEFINED LIBDIR)
133 endif (BUILD_SHARED_LIBS AND NOT DEFINED LIBDIR)
135 add_subdirectory (src)
138 install (FILES index.html DESTINATION doc)
140 set (CPACK_PACKAGE_NAME "mesa-demos")
141 set (CPACK_PACKAGE_VERSION_MAJOR "8")
142 set (CPACK_PACKAGE_VERSION_MINOR "0")
143 set (CPACK_PACKAGE_VERSION_PATCH "1")
146 set (CPACK_GENERATOR "ZIP")
148 set (CPACK_GENERATOR "DragNDrop")
149 set (CPACK_DMG_FORMAT "UDBZ")
151 set (CPACK_GENERATOR "TBZ2")