Android documentation
[freeglut] / CMakeLists.txt
index e17cd60..ef47269 100644 (file)
@@ -86,17 +86,33 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
 OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
 OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
 
-FIND_PACKAGE(OpenGL REQUIRED)
-INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
-LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
-LIST(APPEND LIBS m)
+# OpenGL ES support
+OPTION(FREEGLUT_GLES1 "Use OpenGL ES 1.x (requires EGL)" OFF)
+OPTION(FREEGLUT_GLES2 "Use OpenGL ES 2.x (requires EGL) (overrides BUILD_GLES1)" OFF)
+
+IF(FREEGLUT_GLES2)
+  ADD_DEFINITIONS(-DGLESv2)
+  LIST(APPEND LIBS GLESv2 EGL)
+ELSEIF(FREEGLUT_GLES1)
+  ADD_DEFINITIONS(-DGLESv1)
+  LIST(APPEND LIBS GLESv1 EGL)
+ELSE()
+  FIND_PACKAGE(OpenGL REQUIRED)
+  LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
+  INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
+ENDIF()
+
+# lib m for math, not needed on windows
+IF (NOT WIN32)
+    LIST(APPEND LIBS m)
+ENDIF()
 
 IF(WIN32)
        MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")
        ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
 ENDIF()
 
-if(UNIX)
+if(UNIX AND NOT ANDROID)
        FIND_PACKAGE(X11 REQUIRED)
        LIST(APPEND LIBS ${X11_LIBRARIES})
        IF(X11_Xrandr_FOUND)
@@ -155,7 +171,8 @@ IF(WIN32)
        ENDIF()
 ELSE()
        # on UNIX we need to make sure:
-       # - all shared libraries must have a soname/version
+       # - all shared libraries must have a soname/version (see
+    #   http://sourceware.org/autobook/autobook/autobook_91.html#SEC91)
        # - the output library should be named glut so it'll be linkable with -lglut
        # - the shared library should link to the dependency libraries so that the user
        #   won't have to link them explicitly (they shouldn't have to know that we depend
@@ -163,8 +180,12 @@ ELSE()
        SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
        SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
 ENDIF()
-TARGET_LINK_LIBRARIES(freeglut ${LIBS})
-TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
+IF(BUILD_SHARED_LIBS)
+    TARGET_LINK_LIBRARIES(freeglut ${LIBS})
+ENDIF()
+IF(BUILD_STATIC_LIBS)
+    TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
+ENDIF()
 
 IF(BUILD_SHARED_LIBS)
        INSTALL(TARGETS freeglut DESTINATION lib)
@@ -180,17 +201,22 @@ INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
 option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
 
 SET(DEMO_LIBS ${OPENGL_glu_LIBRARY} ${LIBS})
-LIST(APPEND DEMO_LIBS m)
+# lib m for math, not needed on windows
+IF (NOT WIN32)
+    LIST(APPEND DEMO_LIBS m)
+ENDIF()
 
 MACRO(ADD_DEMO name)
-       if( FREEGLUT_BUILD_DEMOS )
-               ADD_EXECUTABLE(${name} ${ARGN})
-               IF(BUILD_SHARED_LIBS)
-                       TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
-               ELSE()
-                       TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static)
-               ENDIF()
-       endif()
+    IF( FREEGLUT_BUILD_DEMOS )
+        IF(BUILD_SHARED_LIBS)
+            ADD_EXECUTABLE(${name} ${ARGN})
+            TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
+        ENDIF()
+        IF(BUILD_STATIC_LIBS)
+            ADD_EXECUTABLE(${name}_static ${ARGN})
+            TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static)
+        ENDIF()
+    ENDIF()
 ENDMACRO()
 
 ADD_DEMO(CallbackMaker   progs/demos/CallbackMaker/CallbackMaker.c)
@@ -205,5 +231,4 @@ ADD_DEMO(spaceball       progs/demos/spaceball/spaceball.c
                          progs/demos/spaceball/vmath.c
                          progs/demos/spaceball/vmath.h)
 ADD_DEMO(subwin          progs/demos/subwin/subwin.c)
-
-
+ADD_DEMO(timer           progs/demos/timer/timer.c)