CMake: option to build with OpenGL ES
authorSylvain Beucler <beuc@beuc.net>
Sun, 11 Mar 2012 09:18:15 +0000 (09:18 +0000)
committerSylvain Beucler <beuc@beuc.net>
Sun, 11 Mar 2012 09:18:15 +0000 (09:18 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1102 7f0cb862-5218-0410-a997-914c9d46530a

CMakeLists.txt

index c39f2be..ef47269 100644 (file)
@@ -86,9 +86,21 @@ 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})
+# 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)
@@ -100,7 +112,7 @@ IF(WIN32)
        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)