Detect sinf/cosf/sqrtf presence with CMake (instead of relying on __cpluscplus)
[freeglut] / CMakeLists.txt
index c75e4fe..83e5d31 100644 (file)
@@ -203,7 +203,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
   ENDIF()
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
-if(UNIX AND NOT ANDROID)
+IF(UNIX AND NOT ANDROID)
     FIND_PACKAGE(X11 REQUIRED)
     LIST(APPEND LIBS ${X11_LIBRARIES})
     IF(X11_Xrandr_FOUND)
@@ -219,6 +219,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)
@@ -256,6 +261,27 @@ IF (NOT (HAVE_STDINT_H OR HAVE_INTTYPES_H))
     ENDIF()
 ENDIF()
 
+# Check for sinf/cosf/sqrtf
+# CHECK_FUNCTION_EXISTS doesn't work because check requires <math.h>
+#CHECK_FUNCTION_EXISTS(sinf      HAVE_SINF)
+#CHECK_FUNCTION_EXISTS(cosf      HAVE_COSF)
+#CHECK_FUNCTION_EXISTS(sqrtf     HAVE_SQRTF)
+INCLUDE(CheckCSourceCompiles)
+CHECK_C_SOURCE_COMPILES("
+    #include <math.h>
+    int main(){sinf(0); return 0;}
+    " HAVE_SINF
+)
+CHECK_C_SOURCE_COMPILES("
+    #include <math.h>
+    int main(){cosf(0); return 0;}
+    " HAVE_COSF
+)
+CHECK_C_SOURCE_COMPILES("
+    #include <math.h>
+    int main(){sqrtf(0); return 0;}
+    " 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.