CMake: Move -DANDROID in the toolchain script, to ease reuse of this file
authorSylvain Beucler <beuc@beuc.net>
Thu, 15 Mar 2012 20:48:32 +0000 (20:48 +0000)
committerSylvain Beucler <beuc@beuc.net>
Thu, 15 Mar 2012 20:48:32 +0000 (20:48 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1141 7f0cb862-5218-0410-a997-914c9d46530a

CMakeLists.txt
README.android
android_toolchain.cmake

index 7c4f202..b1f8216 100644 (file)
@@ -263,15 +263,13 @@ ELSE()
     IF(ANDROID)
         # Not in CMake toolchain file, because the toolchain
         # file is called several times and generally doesn't
-        # seem to be meant for it:
+        # seem to be meant for modifying CFLAGS:
         # '-mandroid' is not mandatory but doesn't hurt
         # '-O0 -gstabs+' helps the currently buggy GDB port
-        # '-DANDROID' is the Android build system convention
         # Too late to manipulate ENV: SET(ENV{CFLAGS} "$ENV{CFLAGS} -mandroid")
         # Not using _INIT variables, they seem to be used internally only
         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mandroid")
         SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -gstabs+")
-        ADD_DEFINITIONS(-DANDROID)
     ENDIF()
 ENDIF()
 IF(BUILD_SHARED_LIBS)
@@ -346,3 +344,15 @@ IF(FREEGLUT_BUILD_DEMOS)
         ${DEMO_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
     )
 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")
+ELSE()
+  SET(LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL")
+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)
index ecdfa41..d3770bb 100644 (file)
@@ -83,9 +83,23 @@ Compile FreeGLUT for a traditional cross-compiler environment
   make -j4
   make install
 
-- Compile your own project, for instance if you use the autotools:
+- Compile your own project.
+
+For instance if you use the autotools:
 
   PATH=/usr/src/ndk-standalone-9/bin:$PATH
   ./configure --host=arm-linux-androideabi --prefix=/somewhere
   make
   make install
+
+If you use CMake, you may want to copy our Android toolchain
+'android_toolchain.cmake':
+
+  cp .../android_toolchain.cmake .
+  cmake \
+    -D CMAKE_TOOLCHAIN_FILE=android_toolchain.cmake
+    -D CMAKE_INSTALL_PREFIX=/somewhere \
+    -D MY_PROG_OPTION=something ... \
+    .
+  make -j4
+  make install
index ef3bb61..93498c6 100644 (file)
@@ -3,4 +3,6 @@ SET(CMAKE_SYSTEM_NAME Linux)  # Tell CMake we're cross-compiling
 include(CMakeForceCompiler)
 # Prefix detection only works with compiler id "GNU"
 CMAKE_FORCE_C_COMPILER(arm-linux-androideabi-gcc GNU)
+# '-DANDROID' is the Android build system convention
+ADD_DEFINITIONS(-DANDROID)
 SET(ANDROID TRUE)