Unify GLES1 and GLES2 (libraries are compatible and can be co-linked)
[freeglut] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
2 PROJECT(freeglut)
3
4 # NOTE: On Windows and Cygwin, the dll's are placed in the
5 # CMAKE_RUNTIME_OUTPUT_DIRECTORY, while their corresponding import
6 # libraries end up in CMAKE_ARCHIVE_OUTPUT_DIRECTORY. On other
7 # platforms, such as Linux, the shared libraries are put in
8 # CMAKE_ARCHIVE_OUTPUT_DIRECTORY instead.
9 # Static libraries end up in CMAKE_ARCHIVE_OUTPUT_DIRECTORY on all
10 # platforms.
11 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
12 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
13 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
14
15 # setup version numbers
16 # TODO: Update these for each release!
17 set(VERSION_MAJOR 3)
18 set(VERSION_MINOR 0)
19 set(VERSION_PATCH 0)
20
21
22 # FREEGLUT_BUILD_SHARED_LIBS is already a standard CMake variable, but we need to
23 # re-declare it here so it will show up in the GUI.
24 # by default, we want to build both
25 OPTION(FREEGLUT_BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
26 OPTION(FREEGLUT_BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
27
28 # option for whether warnings and errors should be printed
29 OPTION(FREEGLUT_PRINT_ERRORS "Lib prints errors to stderr" ON)
30 #MARK_AS_ADVANCED(FREEGLUT_PRINT_ERRORS)
31 OPTION(FREEGLUT_PRINT_WARNINGS "Lib prints warnings to stderr" ON)
32 #MARK_AS_ADVANCED(FREEGLUT_PRINT_WARNINGS)
33
34 # option to also copy .pdb files to install directory when executing
35 # INSTALL target
36 IF(MSVC)
37     OPTION(INSTALL_PDB "Also install .pdb files" ON)
38 ELSE()
39     SET(INSTALL_PDB OFF)
40 ENDIF()
41
42 # OpenGL ES support
43 OPTION(FREEGLUT_GLES "Use OpenGL ES (requires EGL)" OFF)
44
45
46 SET(FREEGLUT_HEADERS
47     include/GL/freeglut.h
48     include/GL/freeglut_ext.h
49     include/GL/freeglut_std.h
50     include/GL/glut.h
51 )
52 SET(FREEGLUT_SRCS
53     ${FREEGLUT_HEADERS}
54     src/fg_callbacks.c
55     src/fg_cursor.c
56     src/fg_display.c
57     src/fg_ext.c
58     src/fg_font_data.c
59     src/fg_gamemode.c
60     src/fg_geometry.c
61     src/fg_gl2.c
62     src/fg_gl2.h
63     src/fg_init.c
64     src/fg_init.h
65     src/fg_internal.h
66     src/fg_input_devices.c
67     src/fg_joystick.c
68     src/fg_main.c
69     src/fg_misc.c
70     src/fg_overlay.c
71     src/fg_spaceball.c
72     src/fg_state.c
73     src/fg_stroke_mono_roman.c
74     src/fg_stroke_roman.c
75     src/fg_structure.c
76     src/fg_teapot.c
77     src/fg_teapot_data.h
78     src/fg_videoresize.c
79     src/fg_window.c
80 )
81 # TODO: OpenGL ES requires a compatible version of these files:
82 IF(NOT FREEGLUT_GLES)
83     LIST(APPEND FREEGLUT_SRCS
84         src/fg_font.c
85         src/fg_menu.c
86     )
87 ELSE()
88     LIST(APPEND FREEGLUT_SRCS
89         src/gles_stubs.c
90     )
91 ENDIF()
92
93 IF(WIN32)
94     LIST(APPEND FREEGLUT_SRCS
95         src/mswin/fg_cursor_mswin.c
96         src/mswin/fg_display_mswin.c
97         src/mswin/fg_ext_mswin.c
98         src/mswin/fg_gamemode_mswin.c
99         src/mswin/fg_init_mswin.c
100         src/mswin/fg_internal_mswin.h
101         src/mswin/fg_input_devices_mswin.c
102         src/mswin/fg_joystick_mswin.c
103         src/mswin/fg_main_mswin.c
104         src/mswin/fg_menu_mswin.c
105         src/mswin/fg_spaceball_mswin.c
106         src/mswin/fg_state_mswin.c
107         src/mswin/fg_structure_mswin.c
108         src/mswin/fg_window_mswin.c
109         ${CMAKE_BINARY_DIR}/freeglut.rc # generated below from freeglut.rc.in
110     )
111     IF (MSVC AND NOT CMAKE_CL_64)
112         # .def file only for 32bit Windows builds (TODO: MSVC only right
113         # now, needed for any other Windows platform?)
114         LIST(APPEND FREEGLUT_SRCS
115             ${CMAKE_BINARY_DIR}/freeglutdll.def # generated below from src/freeglutdll.def.in
116         )
117     ENDIF()
118
119 ELSEIF(ANDROID OR BLACKBERRY)
120     # BlackBerry and Android share some similar design concepts and ideas, as with many mobile devices.
121     # As such, some classes can be shared between the two. XXX: Possibly rename shareable classes to
122     # a more generic name. *_stub? *_mobile?
123     LIST(APPEND FREEGLUT_SRCS
124         src/android/fg_cursor_android.c
125         src/android/fg_ext_android.c
126         src/android/fg_gamemode_android.c
127         src/android/fg_joystick_android.c
128         src/android/fg_spaceball_android.c
129     )
130     IF(ANDROID)
131         LIST(APPEND FREEGLUT_SRCS
132             src/android/native_app_glue/android_native_app_glue.c
133             src/android/native_app_glue/android_native_app_glue.h
134             src/android/fg_internal_android.h
135             src/android/fg_init_android.c
136             src/android/fg_input_devices_android.c
137             src/android/fg_main_android.c
138             src/android/fg_main_android.h
139             src/android/fg_runtime_android.c
140             src/android/fg_state_android.c
141             src/android/fg_structure_android.c
142             src/android/fg_window_android.c
143         )
144     ELSE()
145         LIST(APPEND FREEGLUT_SRCS
146             src/blackberry/fg_internal_blackberry.h
147             src/blackberry/fg_init_blackberry.c
148             src/x11/fg_input_devices_x11.c
149             src/blackberry/fg_main_blackberry.c
150             src/blackberry/fg_state_blackberry.c
151             src/blackberry/fg_structure_blackberry.c
152             src/blackberry/fg_window_blackberry.c
153         )
154     ENDIF()
155 ELSE()
156     LIST(APPEND FREEGLUT_SRCS
157         src/x11/fg_cursor_x11.c
158         src/x11/fg_ext_x11.c
159         src/x11/fg_gamemode_x11.c
160         src/x11/fg_glutfont_definitions_x11.c
161         src/x11/fg_init_x11.c
162         src/x11/fg_internal_x11.h
163         src/x11/fg_input_devices_x11.c
164         src/x11/fg_joystick_x11.c
165         src/x11/fg_main_x11.c
166         src/x11/fg_menu_x11.c
167         src/x11/fg_spaceball_x11.c
168         src/x11/fg_state_x11.c
169         src/x11/fg_structure_x11.c
170         src/x11/fg_window_x11.c
171         src/x11/fg_xinput_x11.c
172     )
173     IF(NOT(FREEGLUT_GLES))
174         LIST(APPEND FREEGLUT_SRCS
175             src/x11/fg_internal_x11_glx.h
176             src/x11/fg_display_x11_glx.c
177             src/x11/fg_state_x11_glx.c
178             src/x11/fg_state_x11_glx.h
179             src/x11/fg_window_x11_glx.c
180             src/x11/fg_window_x11_glx.h
181         )
182     ENDIF()
183 ENDIF()
184 IF(FREEGLUT_GLES)
185     LIST(APPEND FREEGLUT_SRCS
186         src/egl/fg_internal_egl.h
187         src/egl/fg_display_egl.c
188         src/egl/fg_ext_egl.c
189         src/egl/fg_init_egl.c
190         src/egl/fg_init_egl.h
191         src/egl/fg_state_egl.c
192         src/egl/fg_state_egl.h
193         src/egl/fg_structure_egl.c
194         src/egl/fg_structure_egl.h
195         src/egl/fg_window_egl.c
196         src/egl/fg_window_egl.h
197     )
198 ENDIF()
199
200 # For OpenGL ES (GLES): compile with -DFREEGLUT_GLES to cleanly
201 # bootstrap headers inclusion in freeglut_std.h; this constant also
202 # need to be defined in client applications (e.g. through pkg-config),
203 # but do use GLES constants directly for all other needs
204 # GLES1 and GLES2 libraries are compatible and can be co-linked.
205 IF(FREEGLUT_GLES)
206   ADD_DEFINITIONS(-DFREEGLUT_GLES)
207   LIST(APPEND LIBS GLESv2 GLESv1_CM EGL)
208 ELSE()
209   FIND_PACKAGE(OpenGL REQUIRED)
210   LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
211   INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
212 ENDIF()
213
214 # lib m for math, not needed on windows
215 IF (NOT WIN32)
216     # For compilation:
217     LIST(APPEND LIBS m)
218     # For CHECK_FUNCTION_EXISTS:
219     LIST(APPEND CMAKE_REQUIRED_LIBRARIES m)
220 ENDIF()
221
222 IF(WIN32)
223     # hide insecure CRT warnings, common practice
224     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
225     IF(MSVC)
226         SET( CMAKE_DEBUG_POSTFIX "d" )
227     ENDIF(MSVC)
228     
229 ENDIF()
230
231 IF(CMAKE_COMPILER_IS_GNUCC)
232   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
233   IF(NOT(ANDROID OR BLACKBERRY))
234     # not setting -ansi as EGL/KHR headers doesn't support it
235     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
236   ENDIF()
237 ENDIF(CMAKE_COMPILER_IS_GNUCC)
238
239 INCLUDE(CheckIncludeFiles)
240 IF(UNIX AND NOT(ANDROID OR BLACKBERRY))
241     FIND_PACKAGE(X11 REQUIRED)
242     LIST(APPEND LIBS ${X11_LIBRARIES})
243     IF(X11_Xrandr_FOUND)
244         SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE)
245         LIST(APPEND LIBS ${X11_Xrandr_LIB})
246     ENDIF()
247     IF(X11_xf86vmode_FOUND)
248         SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE)
249         # Work-around http://www.cmake.org/Bug/bug_view_page.php?bug_id=6976
250         IF(NOT "${X11_Xxf86vm_LIB}")
251             SET(X11_Xxf86vm_LIB "Xxf86vm")
252         ENDIF()
253         LIST(APPEND LIBS ${X11_Xxf86vm_LIB})
254     ENDIF()
255     IF(X11_Xinput_FOUND)
256         # Needed for multi-touch:
257         CHECK_INCLUDE_FILES("${X11_Xinput_INCLUDE_PATH}/X11/extensions/XInput2.h" HAVE_X11_EXTENSIONS_XINPUT2_H)
258         LIST(APPEND LIBS ${X11_Xinput_LIB})
259     ENDIF()
260 ENDIF()
261 IF(ANDROID)
262     # -landroid for ANativeWindow
263     # -llog for native Android logging
264     LIST(APPEND LIBS android log)
265 ELSEIF(BLACKBERRY)
266     if(PLAYBOOK)
267         # -lbps for event loop
268         # -screen for native screen
269         LIST(APPEND LIBS bps screen)
270     ELSE()
271         # -lbps for event loop
272         # -lslog2 for logging
273         # -screen for native screen
274         LIST(APPEND LIBS bps slog2 screen)
275     ENDIF()
276 ENDIF()
277
278 INCLUDE(CheckFunctionExists)
279 INCLUDE(CheckTypeSize)
280 CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
281 CHECK_INCLUDE_FILES(unistd.h    HAVE_UNISTD_H)
282 CHECK_INCLUDE_FILES(sys/time.h  HAVE_SYS_TIME_H)
283 CHECK_INCLUDE_FILES(stdbool.h   HAVE_STDBOOL_H)
284 CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
285 CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
286 CHECK_INCLUDE_FILES(fcntl.h     HAVE_FCNTL_H)
287 CHECK_INCLUDE_FILES(errno.h     HAVE_ERRNO_H)
288 CHECK_INCLUDE_FILES(usbhid.h    HAVE_USBHID_H)
289 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
290 CHECK_FUNCTION_EXISTS(vfprintf  HAVE_VFPRINTF)
291 CHECK_FUNCTION_EXISTS(_doprnt   HAVE_DOPRNT)
292 CHECK_FUNCTION_EXISTS(XParseGeometry   HAVE_XPARSEGEOMETRY)
293 IF (NOT HAVE_XPARSEGEOMETRY)
294    LIST(APPEND FREEGLUT_SRCS
295         src/util/xparsegeometry_repl.c
296         src/util/xparsegeometry_repl.h)
297    SET(NEED_XPARSEGEOMETRY_IMPL TRUE)
298 ENDIF()
299 # decide on suitable type for internal time keeping, 64-bit if possible
300 CHECK_INCLUDE_FILES(stdint.h    HAVE_STDINT_H)
301 CHECK_INCLUDE_FILES(inttypes.h  HAVE_INTTYPES_H)
302 IF (NOT (HAVE_STDINT_H OR HAVE_INTTYPES_H))
303     IF (MSVC)
304         # Some old Microsoft VC releases don't support unsigned long
305         # long, but all we care about is support for unsigned __int64 on
306         # MSVC, so test for presence of that type
307         CHECK_TYPE_SIZE("unsigned __int64" U__INT64 BUILTIN_TYPES_ONLY)
308     ELSEIF()
309         CHECK_TYPE_SIZE("unsigned long long" ULONG_LONG BUILTIN_TYPES_ONLY)
310     ENDIF()
311 ENDIF()
312
313 # The generated config.h is placed in the project's build directory, just to
314 # ensure that all CMake-generated files are kept away from the main source tree.
315 # As a result, the build directory must to be added to the include path list.
316 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
317 INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
318 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
319 IF(WIN32)
320     # we also have to generate freeglut.rc, which contains the version
321     # number
322     CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.rc.in ${CMAKE_BINARY_DIR}/freeglut.rc)
323     IF (MSVC AND NOT CMAKE_CL_64)
324         # .def file only for 32bit Windows builds with Visual Studio
325         CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/freeglutdll.def.in ${CMAKE_BINARY_DIR}/freeglutdll.def)
326     ENDIF()
327 ENDIF()
328
329 IF(FREEGLUT_BUILD_SHARED_LIBS)
330     ADD_LIBRARY(freeglut SHARED ${FREEGLUT_SRCS})
331 ENDIF()
332 IF(FREEGLUT_BUILD_STATIC_LIBS)
333     ADD_LIBRARY(freeglut_static STATIC ${FREEGLUT_SRCS})
334 ENDIF()
335
336
337 IF(WIN32)
338     LIST(APPEND LIBS winmm)
339     IF(FREEGLUT_BUILD_SHARED_LIBS)
340         SET_TARGET_PROPERTIES(freeglut PROPERTIES COMPILE_FLAGS -DFREEGLUT_EXPORTS)
341     ENDIF()
342     IF(FREEGLUT_BUILD_STATIC_LIBS)
343         SET_TARGET_PROPERTIES(freeglut_static PROPERTIES COMPILE_FLAGS -DFREEGLUT_STATIC)
344         # need to set machine:x64 for linker, at least for VC10, and
345         # doesn't hurt for older compilers:
346         # http://public.kitware.com/Bug/view.php?id=11240#c22768
347         IF (CMAKE_CL_64)
348             SET_TARGET_PROPERTIES(freeglut_static PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
349         ENDIF()
350     ENDIF()
351 ELSE()
352     # on UNIX we need to make sure:
353     # - all shared libraries must have a soname/version, see :
354     #   http://sourceware.org/autobook/autobook/autobook_91.html#SEC91
355     #   http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
356     #   Current: -version-info 12:0:9 -> 3.9.0
357     #   Note: most platforms now prefer the latter major.minor.revision form
358     #   (e.g. FreeBSD, cf. http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8765),
359     #   or special-cased FreeGLUT long ago (e.g. .so.4 on OpenBSD), so
360     #   the lack of support for current:revision:age in CMake should
361     #   not be a problem.
362     # - the output library should be named glut so it'll be linkable with -lglut
363     # - the shared library should link to the dependency libraries so that the user
364     #   won't have to link them explicitly (they shouldn't have to know that we depend
365     #   on Xrandr or Xxf86vm)
366     IF(FREEGLUT_GLES)
367       SET(LIBNAME freeglut-gles)
368     ELSE()
369       SET(LIBNAME glut)
370     ENDIF()
371
372     IF(FREEGLUT_BUILD_SHARED_LIBS)
373       SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME ${LIBNAME})
374     ENDIF()
375     IF(FREEGLUT_BUILD_STATIC_LIBS)
376       SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME ${LIBNAME})
377     ENDIF()
378     IF(ANDROID)
379         # Not in CMake toolchain file, because the toolchain
380         # file is called several times and generally doesn't
381         # seem to be meant for modifying CFLAGS:
382         # '-mandroid' is not mandatory but doesn't hurt
383         # '-O0 -gstabs+' helps the currently buggy GDB port
384         # Too late to manipulate ENV: SET(ENV{CFLAGS} "$ENV{CFLAGS} -mandroid")
385         # Not using _INIT variables, they seem to be used internally only
386         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mandroid")
387         SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -gstabs+")
388     ENDIF()
389 ENDIF()
390 IF(FREEGLUT_BUILD_SHARED_LIBS)
391     TARGET_LINK_LIBRARIES(freeglut ${LIBS})
392 ENDIF()
393 IF(FREEGLUT_BUILD_STATIC_LIBS)
394     TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
395 ENDIF()
396
397 IF(FREEGLUT_BUILD_SHARED_LIBS)
398     INSTALL(TARGETS freeglut
399             RUNTIME DESTINATION bin
400             LIBRARY DESTINATION lib
401             ARCHIVE DESTINATION lib
402     )
403     IF(INSTALL_PDB)
404         INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/freeglut${CMAKE_DEBUG_POSTFIX}.pdb
405             DESTINATION bin
406                         CONFIGURATIONS Debug)
407     ENDIF()
408 ENDIF()
409 IF(FREEGLUT_BUILD_STATIC_LIBS)
410     INSTALL(TARGETS freeglut_static
411             RUNTIME DESTINATION bin
412             LIBRARY DESTINATION lib
413             ARCHIVE DESTINATION lib
414     )
415     IF(INSTALL_PDB)
416         INSTALL(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Debug/freeglut_static${CMAKE_DEBUG_POSTFIX}.pdb
417             DESTINATION lib
418                         CONFIGURATIONS Debug)
419     ENDIF()
420 ENDIF()
421 INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
422
423
424
425 # Optionally build demos, on by default.
426 option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
427
428 SET(DEMO_LIBS ${OPENGL_glu_LIBRARY} ${LIBS})
429 # lib m for math, not needed on windows
430 IF (NOT WIN32)
431     LIST(APPEND DEMO_LIBS m)
432 ENDIF()
433
434 MACRO(ADD_DEMO name)
435     IF( FREEGLUT_BUILD_DEMOS )
436         IF(FREEGLUT_BUILD_SHARED_LIBS)
437             ADD_EXECUTABLE(${name} ${ARGN})
438             TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
439             IF(WIN32 AND MSVC)
440                 SET_TARGET_PROPERTIES(${name} PROPERTIES DEBUG_POSTFIX d)
441             ENDIF()
442         ENDIF()
443         IF(FREEGLUT_BUILD_STATIC_LIBS)
444             ADD_EXECUTABLE(${name}_static ${ARGN})
445             TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static)
446             SET_TARGET_PROPERTIES(${name}_static PROPERTIES COMPILE_FLAGS -DFREEGLUT_STATIC)
447             IF(WIN32 AND MSVC)
448                 SET_TARGET_PROPERTIES(${name}_static PROPERTIES DEBUG_POSTFIX d)
449             ENDIF()
450         ENDIF()
451     ENDIF()
452 ENDMACRO()
453
454 ADD_DEMO(CallbackMaker   progs/demos/CallbackMaker/CallbackMaker.c)
455 ADD_DEMO(Fractals        progs/demos/Fractals/fractals.c)
456 ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c)
457 ADD_DEMO(Lorenz          progs/demos/Lorenz/lorenz.c)
458 IF (NOT WIN32)
459     ADD_DEMO(One             progs/demos/One/one.c)
460 ELSE()
461     ADD_DEMO(One             progs/demos/One/one.c
462                              progs/demos/One/one.rc)
463 ENDIF()
464 ADD_DEMO(Resizer         progs/demos/Resizer/Resizer.cpp)
465 ADD_DEMO(multi-touch     progs/demos/multi-touch/multi-touch.c)
466 ADD_DEMO(shapes          progs/demos/shapes/shapes.c
467                          progs/demos/shapes/glmatrix.h
468                          progs/demos/shapes/glmatrix.c)
469 ADD_DEMO(smooth_opengl3  progs/demos/smooth_opengl3/smooth_opengl3.c)
470 IF(UNIX)
471     ADD_DEMO(spaceball       progs/demos/spaceball/spaceball.c
472                              progs/demos/spaceball/vmath.c
473                              progs/demos/spaceball/vmath.h)
474 ENDIF()
475 ADD_DEMO(subwin          progs/demos/subwin/subwin.c)
476 ADD_DEMO(timer           progs/demos/timer/timer.c)
477
478
479
480 # pkg-config support, to install at $(libdir)/pkgconfig
481 # Define static build dependencies
482 IF(WIN32)
483   SET(PC_LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32 -lm")
484 ELSEIF(FREEGLUT_GLES)
485   IF(ANDROID)
486     SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv2 -lGLESv1_CM -lEGL -lm")
487   ELSEIF(BLACKBERRY)
488     IF(PLAYBOOK)
489       SET(PC_LIBS_PRIVATE "-lbps -lscreen -lGLESv2 -lGLESv1_CM -lEGL -lm")
490     ELSE()
491       SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lscreen -lGLESv2 -lGLESv1_CM -lEGL -lm")
492     ENDIF()
493   ELSE()
494     SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lGLESv1_CM -lEGL -lm")
495   ENDIF()
496 ELSE()
497   SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL -lm")
498 ENDIF()
499 # Client applications need to define FreeGLUT GLES version to
500 # bootstrap headers inclusion in freeglut_std.h:
501 SET(PC_LIBNAME "glut")
502 SET(PC_FILENAME "freeglut.pc")
503 IF(FREEGLUT_GLES)
504   SET(PC_CFLAGS "-DFREEGLUT_GLES")
505   SET(PC_LIBNAME "freeglut-gles")
506   SET(PC_FILENAME "freeglut-gles.pc")
507 ENDIF()
508 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY)
509 INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig/ RENAME ${PC_FILENAME})
510 # TODO: change the library and .pc name when building for GLES,
511 # e.g. -lglut-GLES