summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: dbb335925c54fcbbd355ba10b8b0e4de43ff7994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
cmake_minimum_required (VERSION 2.8)

project (mesademos)

find_package (OpenGL REQUIRED)
find_package (GLUT REQUIRED)
find_package (X11)

find_library(EGL_egl_LIBRARY EGL /usr/lib)

find_library (GLEW_glew_LIBRARY GLEW
	/usr/lib
)

find_path (GLEW_INCLUDE_DIR GL/glew.h
      /usr/include/GL
)

if (UNIX)
	link_libraries(m)
endif (UNIX)

# On Mac OS X, GLX is provided as a separate OpenGL implementation, different
# from the standard OpenGL framework which provides support for GLUT and native
# Mac OS X applications.
if (X11_FOUND)
	if (APPLE)
		find_path (X11_GL_INCLUDE_PATH GL/glx.h ${X11_INC_SEARCH_PATH})
		if (NOT X11_GL_INCLUDE_PATH)
			message (WARNING "Could not find GL/glx.h")
			set (X11_FOUND FALSE)
		endif (NOT X11_GL_INCLUDE_PATH)
		set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_GL_INCLUDE_PATH})

		find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
		if (NOT X11_GL_LIB)
			message (WARNING "Could not find libGL.dylib")
			set (X11_FOUND FALSE)
		endif (NOT X11_GL_LIB)

		find_library (X11_GLU_LIB GLU ${X11_LIB_SEARCH_PATH})
		if (NOT X11_GLU_LIB)
			message (WARNING "Could not find libGLU.dylib")
			set (X11_FOUND FALSE)
		endif (NOT X11_GLU_LIB)
	else ()
		set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
		set (X11_GL_LIB ${OPENGL_gl_LIBRARY})
		set (X11_GLU_LIB ${OPENGL_glu_LIBRARY})
	endif ()
endif (X11_FOUND)

if (CMAKE_COMPILER_IS_GNUCC)
	add_definitions(
		-Wall
		-Wpointer-arith
		-Wstrict-prototypes
		-Wmissing-prototypes
		-Wmissing-declarations
		-Wnested-externs
		-fno-strict-aliasing
		-Wbad-function-cast
		#-Wold-style-definition
		#-Wdeclaration-after-statement
        )
endif (CMAKE_COMPILER_IS_GNUCC)

if (WIN32)
	# Nobody likes to include windows.h:
	# - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
	# - GLEW temporarily defines the necessary defines but undefines them later
	# - certain GLUT distributions don't include it;
	# - most of our programs are meant to be portable so don't include it.
	#
	# We could try to replicate the windows.h definitions required by
	# GL/gl.h, but the build time savings don't compensate the constant
	# headaches that brings, so instead we force windows.h to be included
	# on every file.
	if (MSVC)
		add_definitions (-FIwindows.h)
	else (MSVC)
		add_definitions (--include windows.h)
	endif (MSVC)

	# Don't define min/max macros
	add_definitions (-DNOMINMAX)

	# MSVC & MinGW only define & use APIENTRY
	add_definitions (-DGLAPIENTRY=__stdcall)

	link_libraries (winmm)
endif (WIN32)

if (MSVC)
	# Enable math constants defines
	add_definitions (-D_USE_MATH_DEFINES)

	# Silence several MSVC pedantic warnings
	add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
	add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
	add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
endif (MSVC)

add_definitions(-DDEMOS_DATA_DIR=\"../data/\")

add_subdirectory (src)


install (FILES index.html DESTINATION doc)

set (CPACK_PACKAGE_NAME "mesa-demos")
set (CPACK_PACKAGE_VERSION_MAJOR "8")
set (CPACK_PACKAGE_VERSION_MINOR "0")
set (CPACK_PACKAGE_VERSION_PATCH "1")

if (WIN32)
    set (CPACK_GENERATOR "ZIP")
elseif (APPLE)
    set (CPACK_GENERATOR "DragNDrop")
    set (CPACK_DMG_FORMAT "UDBZ")
else ()
    set (CPACK_GENERATOR "TBZ2")
endif ()

include(CPack)