2014-09-22 165 views
3

我正在为多平台渲染器编写构建工具链(至少现在是iOS/Mac)。该项目有一个核心库(将被每个平台目标使用的库),它应该被编译为一个静态库(.a),以便在其他依赖于平台的项目中使用(如在xcode项目或eclipse中为进一步的android开发)。使用OpenGL ES 2.0与cmake生成iOS静态库

这个静态库依赖于OpenGL ES 2.0(iOS)或OpenGL for Mac。所以,我有以下文件,以包括正确的头:

#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 

的事实是,它是为Mac平台正常使用,OpenGL的头被正确地cmake的发现,但是对于iOS的,它不找到OpenGLES;即使使用我编写的FindOpenGLES.cmake模块,我也无法找到这些标头,这似乎是合乎逻辑的,因为我甚至没有在/ usr/include中找到它们。

+1

尝试定位OpenGLES和ES2目录。如果它们存在,则可以使用include_directories()作为确切位置。 – user2618142 2014-09-23 03:40:51

+0

是的,那正是我想要做的,但我不知道它们位于何处,我运行了'find/usr -name“* GLES *”',似乎没有任何东西在这里。 – cewxel 2014-09-23 13:34:33

+0

1.运行locate命令。 2.或者试试find/-name'“* GLES *”'-type f -print它们必须在某处 – user2618142 2014-09-24 04:41:25

回答

0

您可能需要设置CMAKE_SYSTEM_FRAMEWORK_PATH,以下是从我的iOS传来工具链文件

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's 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)