Moving some Windows-specific code out of "freeglut_main.c" into the Windows-specific...
[freeglut] / CMakeLists.txt
1 PROJECT(freeglut)\r
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)\r
3 \r
4 SET(FREEGLUT_HEADERS\r
5         include/GL/freeglut.h\r
6         include/GL/freeglut_ext.h\r
7         include/GL/freeglut_std.h\r
8         include/GL/glut.h\r
9 )\r
10 SET(FREEGLUT_SRCS\r
11         ${FREEGLUT_HEADERS}\r
12         src/Common/freeglut_callbacks.c\r
13         src/Common/freeglut_cursor.c\r
14         src/Common/freeglut_display.c\r
15         src/Common/freeglut_ext.c\r
16         src/Common/freeglut_font.c\r
17         src/Common/freeglut_font_data.c\r
18         src/Common/freeglut_gamemode.c\r
19         src/Common/freeglut_geometry.c\r
20         src/Common/freeglut_glutfont_definitions.c\r
21         src/Common/freeglut_init.c\r
22         src/Common/freeglut_internal.h\r
23         src/Common/freeglut_input_devices.c\r
24         src/Common/freeglut_joystick.c\r
25         src/Common/freeglut_main.c\r
26         src/Common/freeglut_menu.c\r
27         src/Common/freeglut_misc.c\r
28         src/Common/freeglut_overlay.c\r
29         src/Common/freeglut_spaceball.c\r
30         src/Common/freeglut_state.c\r
31         src/Common/freeglut_stroke_mono_roman.c\r
32         src/Common/freeglut_stroke_roman.c\r
33         src/Common/freeglut_structure.c\r
34         src/Common/freeglut_teapot.c\r
35         src/Common/freeglut_videoresize.c\r
36         src/Common/freeglut_window.c\r
37         src/Common/freeglut_xinput.c\r
38 )\r
39 \r
40 IF(WIN32)\r
41         LIST(APPEND FREEGLUT_SRCS\r
42                 src/mswin/freeglut_cursor_mswin.c\r
43                 src/mswin/freeglut_display_mswin.c\r
44                 src/mswin/freeglut_ext_mswin.c\r
45                 src/mswin/freeglut_gamemode_mswin.c\r
46                 src/mswin/freeglut_init_mswin.c\r
47                 src/mswin/freeglut_internal_mswin.h\r
48                 src/mswin/freeglut_input_devices_mswin.c\r
49                 src/mswin/freeglut_joystick_mswin.c\r
50                 src/mswin/freeglut_main_mswin.c\r
51                 src/mswin/freeglut_menu_mswin.c\r
52                 src/mswin/freeglut_spaceball_mswin.c\r
53                 src/mswin/freeglut_state_mswin.c\r
54                 src/mswin/freeglut_structure_mswin.c\r
55                 src/mswin/freeglut_window_mswin.c\r
56 )\r
57 ELSE()\r
58         LIST(APPEND FREEGLUT_SRCS\r
59                 src/x11/freeglut_cursor_x11.c\r
60                 src/x11/freeglut_display_x11.c\r
61                 src/x11/freeglut_ext_x11.c\r
62                 src/x11/freeglut_gamemode_x11.c\r
63                 src/x11/freeglut_glutfont_definitions_x11.c\r
64                 src/x11/freeglut_init_x11.c\r
65                 src/x11/freeglut_internal_x11.h\r
66                 src/x11/freeglut_input_devices_x11.c\r
67                 src/x11/freeglut_joystick_x11.c\r
68                 src/x11/freeglut_main_x11.c\r
69                 src/x11/freeglut_menu_x11.c\r
70                 src/x11/freeglut_spaceball_x11.c\r
71                 src/x11/freeglut_state_x11.c\r
72                 src/x11/freeglut_structure_x11.c\r
73                 src/x11/freeglut_window_x11.c\r
74 )\r
75 \r
76 \r
77 ENDIF()\r
78 \r
79 # Neatly organize all of the output files in the build directory\r
80 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)\r
81 SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)\r
82 \r
83 # BUILD_SHARED_LIBS is already a standard CMake variable, but we need to\r
84 # re-declare it here so it will show up in the GUI.\r
85 OPTION(BUILD_SHARED_LIBS "Build FreeGLUT as a shared library." ON)\r
86 \r
87 FIND_PACKAGE(OpenGL REQUIRED)\r
88 \r
89 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${OPENGL_INCLUDE_DIR})\r
90 \r
91 IF(WIN32)\r
92         MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")\r
93         ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)\r
94 ENDIF()\r
95 \r
96 INCLUDE(CheckIncludeFiles)\r
97 \r
98 CHECK_INCLUDE_FILES(X11/extensions/xf86vmode.h  HAVE_X11_EXTENSIONS_XF86VMODE_H)\r
99 CHECK_INCLUDE_FILES(X11/extensions/Xrandr.h     HAVE_X11_EXTENSIONS_XRANDR_H)\r
100 CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)\r
101 CHECK_INCLUDE_FILES(unistd.h    HAVE_UNISTD_H)\r
102 CHECK_INCLUDE_FILES(sys/time.h  HAVE_SYS_TIME_H)\r
103 CHECK_INCLUDE_FILES(stdbool.h   HAVE_STDBOOL_H)\r
104 CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)\r
105 CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)\r
106 CHECK_INCLUDE_FILES(fcntl.h     HAVE_FCNTL_H)\r
107 CHECK_INCLUDE_FILES(errno.h     HAVE_ERRNO_H)\r
108 CHECK_INCLUDE_FILES(usbhid.h    HAVE_USBHID_H)\r
109 \r
110 # The generated config.h is placed in the project's build directory, just to\r
111 # ensure that all CMake-generated files are kept away from the main source tree.\r
112 # As a result, the build directory must to be added to the include path list.\r
113 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)\r
114 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})\r
115 ADD_DEFINITIONS(-DHAVE_CONFIG_H)\r
116 \r
117 IF(BUILD_SHARED_LIBS)\r
118         IF(WIN32)\r
119                 LIST(APPEND FREEGLUT_SRCS src/Common/freeglutdll.def freeglut.rc)\r
120         ENDIF()\r
121         ADD_DEFINITIONS(-DFREEGLUT_EXPORTS)\r
122 ELSE()\r
123         ADD_DEFINITIONS(-DFREEGLUT_STATIC)\r
124 ENDIF()\r
125 \r
126 # The default library type is determined by BUILD_SHARED_LIBS\r
127 ADD_LIBRARY(freeglut ${FREEGLUT_SRCS})\r
128 \r
129 IF(NOT BUILD_SHARED_LIBS)\r
130         SET_TARGET_PROPERTIES(freeglut PROPERTIES OUTPUT_NAME freeglut_static)\r
131 ENDIF()\r
132 \r
133 INSTALL(TARGETS freeglut DESTINATION lib)\r
134 INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)\r
135 \r
136 # Optionally build demos, on by default.\r
137 option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )\r
138 \r
139 MACRO(ADD_DEMO name)\r
140         if( FREEGLUT_BUILD_DEMOS )\r
141                 ADD_EXECUTABLE(${name} ${ARGN})\r
142                 TARGET_LINK_LIBRARIES(${name} freeglut)\r
143                 INSTALL(TARGETS ${name} DESTINATION bin)\r
144         endif()\r
145 ENDMACRO()\r
146 \r
147 ADD_DEMO(CallbackMaker   progs/demos/CallbackMaker/CallbackMaker.c)\r
148 ADD_DEMO(Fractals        progs/demos/Fractals/fractals.c)\r
149 ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c)\r
150 ADD_DEMO(Lorenz          progs/demos/Lorenz/lorenz.c)\r
151 ADD_DEMO(One             progs/demos/One/one.c)\r
152 ADD_DEMO(Resizer         progs/demos/Resizer/Resizer.cpp)\r
153 ADD_DEMO(shapes          progs/demos/shapes/shapes.c)\r
154 ADD_DEMO(smooth_opengl3  progs/demos/smooth_opengl3/smooth_opengl3.c)\r
155 ADD_DEMO(spaceball       progs/demos/spaceball/spaceball.c\r
156                          progs/demos/spaceball/vmath.c\r
157                          progs/demos/spaceball/vmath.h)\r
158 ADD_DEMO(subwin          progs/demos/subwin/subwin.c)\r
159 \r
160 \r