X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=CMakeLists.txt;h=25aadc0a8edb348a145dedd37607fd754cda20ba;hb=223d39f2318e1724283c50c346843199c81d2e7c;hp=b1e2752000b0038cbb52403afd25dfdc24f20141;hpb=396966637c018be808f25f3305bce36a11101f2c;p=freeglut diff --git a/CMakeLists.txt b/CMakeLists.txt index b1e2752..25aadc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,17 @@ set(VERSION_MINOR 0) set(VERSION_PATCH 0) +# BUILD_SHARED_LIBS is already a standard CMake variable, but we need to +# re-declare it here so it will show up in the GUI. +# by default, we want to build both +OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON) +OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON) + +# 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) + + SET(FREEGLUT_HEADERS include/GL/freeglut.h include/GL/freeglut_ext.h @@ -47,15 +58,18 @@ SET(FREEGLUT_SRCS src/fg_videoresize.c src/fg_window.c ) -# Android port requires adding a version of these compatible with -# OpenGL ES (TODO): -IF(NOT ANDROID) +# TODO: OpenGL ES requires a compatible version of these files: +IF(NOT FREEGLUT_GLES2 AND NOT FREEGLUT_GLES1) LIST(APPEND FREEGLUT_SRCS src/fg_font.c src/fg_geometry.c src/fg_menu.c src/fg_teapot.c ) +ELSE() + LIST(APPEND FREEGLUT_SRCS + src/gles_stubs.c + ) ENDIF() IF(WIN32) @@ -88,19 +102,23 @@ ELSEIF(ANDROID) src/egl/fg_internal_egl.h src/egl/fg_display_egl.c src/egl/fg_init_egl.c + src/egl/fg_state_egl.c src/egl/fg_structure_egl.c + src/egl/fg_structure_egl.h src/egl/fg_window_egl.c + src/egl/fg_window_egl.h src/android/native_app_glue/android_native_app_glue.c src/android/native_app_glue/android_native_app_glue.h src/android/fg_runtime_android.c src/android/fg_gamemode_android.c + src/android/fg_structure_android.c + src/android/fg_init_android.c src/android/fg_input_devices_android.c src/android/fg_joystick_android.c src/android/fg_main_android.c src/android/fg_spaceball_android.c src/android/fg_state_android.c src/android/fg_window_android.c - src/android/opengles_stubs.c src/android/fg_internal_android.h ) ELSE() @@ -124,22 +142,18 @@ ELSE() ) ENDIF() -# BUILD_SHARED_LIBS is already a standard CMake variable, but we need to -# re-declare it here so it will show up in the GUI. -# by default, we want to build both -OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON) -OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON) - -# 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) - +# For OpenGL ES (GLES): +# - compile with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2 to cleanly +# bootstrap headers inclusion in freeglut_std.h; these constants +# also need to be defined in client applications (e.g through +# pkg-config), but use GLES constants directly for all other needs +# - define GLES version-specific library IF(FREEGLUT_GLES2) - ADD_DEFINITIONS(-DGLESv2) + ADD_DEFINITIONS(-DFREEGLUT_GLES2) LIST(APPEND LIBS GLESv2 EGL) ELSEIF(FREEGLUT_GLES1) - ADD_DEFINITIONS(-DGLESv1) - LIST(APPEND LIBS GLESv1 EGL) + ADD_DEFINITIONS(-DFREEGLUT_GLES1) + LIST(APPEND LIBS GLESv1_CM EGL) ELSE() FIND_PACKAGE(OpenGL REQUIRED) LIST(APPEND LIBS ${OPENGL_gl_LIBRARY}) @@ -348,12 +362,30 @@ ENDIF() # pkg-config support, to install at $(libdir)/pkgconfig # Define static build dependencies IF(WIN32) - SET(LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32") -ELSEIF(ANDROID) - SET(LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL") + SET(PC_LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32") +ELSEIF(FREEGLUT_GLES2) + IF(ANDROID) + SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL") + ELSE() + SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL") + ENDIF() +ELSEIF(FREEGLUT_GLES1) + IF(ANDROID) + SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv1_CM -lEGL") + ELSE() + SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv1_CM -lEGL") + ENDIF() ELSE() - SET(LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL") + SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL") +ENDIF() +# Client applications need to define FreeGLUT GLES version to +# bootstrap headers inclusion in freeglut_std.h: +IF(FREEGLUT_GLES2) + SET(PC_CFLAGS "-DFREEGLUT_GLES2") +ELSEIF(FREEGLUT_GLES1) + SET(PC_CFLAGS "-DFREEGLUT_GLES1") ENDIF() CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY) INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig) -# TODO: change the library name when building for GLES, e.g. -lglut-GLES2 +# TODO: change the library and .pc name when building for GLES, +# e.g. -lglut-GLES2