Implement a few missing enums in fgPlatformGlutDeviceGet/fgPlatformGlutGet
[freeglut] / CMakeLists.txt
index e27463d..3068986 100644 (file)
@@ -46,10 +46,12 @@ SET(FREEGLUT_SRCS
     src/fg_gl2.c
     src/fg_gl2.h
     src/fg_init.c
+    src/fg_init.h
     src/fg_internal.h
     src/fg_input_devices.c
     src/fg_joystick.c
     src/fg_main.c
+    src/fg_main.h
     src/fg_misc.c
     src/fg_overlay.c
     src/fg_spaceball.c
@@ -103,15 +105,6 @@ IF(WIN32)
 
 ELSEIF(ANDROID)
     LIST(APPEND FREEGLUT_SRCS
-        src/egl/fg_internal_egl.h
-        src/egl/fg_display_egl.c
-        src/egl/fg_ext_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_internal_android.h
@@ -122,6 +115,7 @@ ELSEIF(ANDROID)
         src/android/fg_input_devices_android.c
         src/android/fg_joystick_android.c
         src/android/fg_main_android.c
+        src/android/fg_main_android.h
         src/android/fg_runtime_android.c
         src/android/fg_spaceball_android.c
         src/android/fg_state_android.c
@@ -146,26 +140,32 @@ ELSE()
         src/x11/fg_window_x11.c
         src/x11/fg_xinput_x11.c
     )
-    IF(FREEGLUT_GLES2 OR FREEGLUT_GLES1)
-        LIST(APPEND FREEGLUT_SRCS
-            src/egl/fg_internal_egl.h
-            src/egl/fg_display_egl.c
-            src/egl/fg_ext_egl.c
-            src/egl/fg_init_egl.c
-            src/egl/fg_state_egl.c
-            src/egl/fg_structure_egl.c
-            src/egl/fg_window_egl.c
-        )
-    ELSE()
+    IF(NOT(FREEGLUT_GLES2 OR FREEGLUT_GLES1))
         LIST(APPEND FREEGLUT_SRCS
             src/x11/fg_internal_x11_glx.h
             src/x11/fg_display_x11_glx.c
             src/x11/fg_state_x11_glx.c
+            src/x11/fg_state_x11_glx.h
             src/x11/fg_window_x11_glx.c
             src/x11/fg_window_x11_glx.h
         )
     ENDIF()
 ENDIF()
+IF(FREEGLUT_GLES2 OR FREEGLUT_GLES1)
+    LIST(APPEND FREEGLUT_SRCS
+        src/egl/fg_internal_egl.h
+        src/egl/fg_display_egl.c
+        src/egl/fg_ext_egl.c
+        src/egl/fg_init_egl.c
+        src/egl/fg_init_egl.h
+        src/egl/fg_state_egl.c
+        src/egl/fg_state_egl.h
+        src/egl/fg_structure_egl.c
+        src/egl/fg_structure_egl.h
+        src/egl/fg_window_egl.c
+        src/egl/fg_window_egl.h
+    )
+ENDIF()
 
 # For OpenGL ES (GLES):
 # - compile with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2 to cleanly
@@ -187,7 +187,10 @@ ENDIF()
 
 # lib m for math, not needed on windows
 IF (NOT WIN32)
+    # For compilation:
     LIST(APPEND LIBS m)
+    # For CHECK_FUNCTION_EXISTS:
+    LIST(APPEND CMAKE_REQUIRED_LIBRARIES m)
 ENDIF()
 
 IF(WIN32)
@@ -195,7 +198,15 @@ IF(WIN32)
     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
 ENDIF()
 
-if(UNIX AND NOT ANDROID)
+IF(CMAKE_COMPILER_IS_GNUCC)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+  IF(!ANDROID)
+    # not setting -ansi as EGL/KHR headers doesn't support it
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi")
+  ENDIF()
+ENDIF(CMAKE_COMPILER_IS_GNUCC)
+
+IF(UNIX AND NOT ANDROID)
     FIND_PACKAGE(X11 REQUIRED)
     LIST(APPEND LIBS ${X11_LIBRARIES})
     IF(X11_Xrandr_FOUND)
@@ -211,6 +222,11 @@ if(UNIX AND NOT ANDROID)
         LIST(APPEND LIBS ${X11_Xxf86vm_LIB})
     ENDIF()
 ENDIF()
+IF(ANDROID)
+    # -landroid for ANativeWindow
+    # -llog for native Android logging
+    LIST(APPEND LIBS android log)
+ENDIF()
 
 INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckFunctionExists)
@@ -248,6 +264,10 @@ IF (NOT (HAVE_STDINT_H OR HAVE_INTTYPES_H))
     ENDIF()
 ENDIF()
 
+# Check for sinf/cosf/sqrtf
+CHECK_FUNCTION_EXISTS(sinf      HAVE_SINF)
+CHECK_FUNCTION_EXISTS(cosf      HAVE_COSF)
+CHECK_FUNCTION_EXISTS(sqrtf     HAVE_SQRTF)
 
 # The generated config.h is placed in the project's build directory, just to
 # ensure that all CMake-generated files are kept away from the main source tree.
@@ -297,8 +317,16 @@ ELSE()
     # - 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
     #   on Xrandr or Xxf86vm)
-    SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
-    SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
+    IF(FREEGLUT_GLES2)
+      SET(LIBNAME freeglut-gles2)
+    ELSEIF(FREEGLUT_GLES1)
+      SET(LIBNAME freeglut-gles1)
+    ELSE()
+      SET(LIBNAME glut)
+    ENDIF()
+
+    SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME ${LIBNAME})
+    SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME ${LIBNAME})
     IF(ANDROID)
         # Not in CMake toolchain file, because the toolchain
         # file is called several times and generally doesn't
@@ -365,25 +393,6 @@ ADD_DEMO(spaceball       progs/demos/spaceball/spaceball.c
 ADD_DEMO(subwin          progs/demos/subwin/subwin.c)
 ADD_DEMO(timer           progs/demos/timer/timer.c)
 
-# finally, if any demos are built, copy needed files to output directory
-# (currently, thats just the input file for the Fractals demo)
-IF(FREEGLUT_BUILD_DEMOS)
-    # 1) copy fractals.dat from freeglut/progs/demos/Fractals
-    IF(BUILD_SHARED_LIBS)
-        SET(Frac_target Fractals)
-    ELSE()
-        SET(Frac_target Fractals_static)
-    ENDIF()
-    GET_TARGET_PROPERTY(DEMO_OUTPUT_DIRECTORY ${Frac_target} RUNTIME_OUTPUT_DIRECTORY)
-    ADD_CUSTOM_COMMAND(
-        TARGET ${Frac_target}
-        POST_BUILD
-        COMMAND ${CMAKE_COMMAND} -E copy
-        ${PROJECT_SOURCE_DIR}/progs/demos/Fractals/fractals.dat
-        ${DEMO_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
-    )
-ENDIF()
-
 # pkg-config support, to install at $(libdir)/pkgconfig
 # Define static build dependencies
 IF(WIN32)
@@ -405,12 +414,18 @@ ELSE()
 ENDIF()
 # Client applications need to define FreeGLUT GLES version to
 # bootstrap headers inclusion in freeglut_std.h:
+SET(PC_LIBNAME "glut")
+SET(PC_FILENAME "freeglut.pc")
 IF(FREEGLUT_GLES2)
   SET(PC_CFLAGS "-DFREEGLUT_GLES2")
+  SET(PC_LIBNAME "freeglut-gles2")
+  SET(PC_FILENAME "freeglut-gles2.pc")
 ELSEIF(FREEGLUT_GLES1)
   SET(PC_CFLAGS "-DFREEGLUT_GLES1")
+  SET(PC_LIBNAME "freeglut-gles1")
+  SET(PC_FILENAME "freeglut-gles1.pc")
 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)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig/ RENAME ${PC_FILENAME})
 # TODO: change the library and .pc name when building for GLES,
 # e.g. -lglut-GLES2