Build iOS static library using OpenGL ES 2.0 with cmake
I am writing a constructive binding for multi-platform rendering (at least iOS / Mac for now). The project has a core library (one that will be used by all target platforms), which must be compiled as a static library (.a) in order to be used in another platform dependent project (for example, an xcode project or eclipse for further Android development).
This static library has dependencies on OpenGL ES 2.0 (iOS) or OpenGL for Mac. So to include the correct headers, I have the following file:
#ifdef PLATFORM_IOS
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#endif
#ifdef PLATFORM_OSX
#include <OpenGL/gl.h>
#include <GLFW/glfw3.h>
#endif
The thing is, it works fine for the Mac platform, the OpenGL headers are correctly found by cmake, but for iOS it doesn't find OpenGLES; even when using the FindOpenGLES.cmake module that I wrote, I can't find these headers, which seems logical, since I don't even find them in / usr / include.
source to share
You may need to set the CMAKE_SYSTEM_FRAMEWORK_PATH following from my iOS program chains file
set (IOS_SDK_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk")
# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
# set the architecture for iOS - this env var sets armv6,armv7 and appears to be XCode standard. The other found is ARCHS_UNIVERSAL_IPHONE_OS but that is armv7 only
set (CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE string "Build architecture for iOS")
# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH ${IOS_SDK_ROOT}/Developer/Library/Frameworks)
source to share