<div dir="ltr"><div><div>I've been using the following macro:</div><div><br></div><div>macro(ADD_FRAMEWORK fwname appname)</div><div>  find_library(FRAMEWORK_${fwname}</div><div>    NAMES ${fwname}</div><div>    PATHS ${CMAKE_OSX_SYSROOT}/System/Library </div>
<div>    PATH_SUFFIXES Frameworks</div><div>    NO_DEFAULT_PATH)</div><div>  if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)</div><div>    MESSAGE(ERROR ": Framework ${fwname} not found")</div>
<div>  else()</div><div>    TARGET_LINK_LIBRARIES(${appname} "${FRAMEWORK_${fwname}}/${fwname}")</div><div>    MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")</div><div>  endif()</div>
<div>endmacro(ADD_FRAMEWORK)</div><div><br></div><div>Originally sourced from here:</div><div><a href="http://stackoverflow.com/questions/12547624/cant-link-macos-frameworks-with-cmake">http://stackoverflow.com/questions/12547624/cant-link-macos-frameworks-with-cmake</a></div>
<div><br></div><div>To successfully include standard Apple frameworks in my iOS Xcode projects generated by CMake as shown below:</div><div><br></div><div>ADD_FRAMEWORK( AVFoundation hello_world )</div><div>ADD_FRAMEWORK( OpenGLES hello_world )</div>
<div><br></div><div>When I try this approach to include custom (i.e., non-Apple) frameworks, I can't seem to get it to work.  </div><div>For example, the following macro is modified to accept a custom path location, but results in the NOTFOUND error shown below.</div>
<div><br></div><div># Macro definition for framework at custom path location</div><div>macro(ADD_MYFRAMEWORK fwname appname fwpath)</div><div>  find_library(FRAMEWORK_${fwname}</div><div>    NAMES ${fwname}</div><div>    PATHS ${fwpath}</div>
<div>    NO_DEFAULT_PATH)</div><div>  if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)</div><div>    MESSAGE(ERROR ": Framework ${fwname} not found")</div><div>  else()</div><div>    TARGET_LINK_LIBRARIES(${appname} "${FRAMEWORK_${fwname}}/${fwname}")</div>
<div>    MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")</div><div>  endif()</div><div>endmacro(ADD_MYFRAMEWORK)</div><div><br></div><div># Try to include my builds of opencv2.framework and GPUImage.framework </div>
<div>ADD_MYFRAMEWORK( opencv2 hello_world $ENV{OPENCV_FRAMEWORK} )</div><div>ADD_MYFRAMEWORK( GPUImage hello_world $ENV{GPUIMAGE} )</div><div><br></div><div>The above code produces the following errors when I run cmake:</div>
<div><br></div><div>calling ADD_MYFRAMEWORK with opencv2 hello_world /tmp/frameworks/</div><div>ERROR: Framework opencv2 not found</div><div>calling ADD_MYFRAMEWORK with GPUImage hello_world /tmp/frameworks/</div><div>ERROR: Framework GPUImage not found</div>
<div><br></div><div><div>What would be the best (or any) strategy for adding these frameworks to my XCode generator project?  I'm new to CMake,</div><div>so any pointers (perhaps obvious) that might help me resolve this would be welcome.</div>
</div><div><br></div><div>For comparison, the structure of a standard Apple OpenGLES framework that is detected by the original ADD_FRAMEWORK macro,</div><div>and the "custom" opencv2 framework that isn't detected by the modified ADD_MYFRAMEWORK macro are shown below.  </div>
<div>The opencv2.framework does work when included in a standard XCode project, but I suspect the lack of dylib files and/or the Headers, </div><div>or Versions folders are throwing off the find_library framework support.   I've tried adding a symbolic link to the library with an explicit </div>
<div>dylib extension (i.e., opencv2.dylib -> opencv2), but that didn't help.  </div><div><br></div><div>I've also tried setting the CMAKE_FRAMEWORK_PATH explicitly above the macro without any luck, i.e., </div>
<div><br></div><div>set(CMAKE_FRAMEWORK_PATH $ENV{OPENCV_FRAMEWORK})</div><div><br></div><div>where the variable points to the /tmp/frameworks folder shown below.</div><div><br></div><div># Non-working framework layout:</div>
<div>/tmp/frameworks/opencv2.framework/</div><div>├── Headers -> Versions/Current/Headers</div><div>├── Resources -> Versions/Current/Resources</div><div>├── Versions</div><div>│   ├── A</div><div>│   │   ├── Headers</div>
<div>│   │   │   ├── calib3d</div><div>│   │   │   │   └── calib3d.hpp</div><div><<<<<<< snip >>>>>>>></div><div>│   │   │   └── world</div><div>│   │   │       └── world.hpp</div>
<div>│   │   ├── Resources</div><div>│   │   │   └── Info.plist</div><div>│   │   └── opencv2</div><div>│   └── Current -> A</div><div>└── opencv2 -> Versions/Current/opencv2</div><div><br></div><div>The opencv2.framework/opencv2 links to opencv2.framework/Versions/Current/opencv2, which has the following format:</div>
<div><br></div><div>lipo -info /tmp/frameworks/opencv2.framework/opencv2</div><div>Architectures in the fat file: /tmp/frameworks/opencv2.framework/opencv2 are: (cputype (16777228) cpusubtype (0)) armv7 armv7s i386 x86_64</div>
<div><br></div><div># Working framework layout:</div><div>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/OpenGLES.framework/</div><div>├── GLEngine.bundle</div>
<div>│   └── GLEngine</div><div>├── Headers</div><div>│   ├── EAGL.h</div><div>│   ├── EAGLDrawable.h</div><div>│   ├── ES1</div><div>│   │   ├── gl.h</div><div>│   │   └── glext.h</div><div>│   ├── ES2</div><div>│   │   ├── gl.h</div>
<div>│   │   └── glext.h</div><div>│   └── ES3</div><div>│       ├── gl.h</div><div>│       └── glext.h</div><div>├── OpenGLES</div><div>├── libCLRendererStubs.dylib</div><div>├── libCVMSPluginSupport.dylib</div><div>├── libCoreFSCache.dylib</div>
<div>├── libCoreVMClient.dylib</div><div>├── libGFXShared.dylib</div><div>├── libGLImage.dylib</div><div>├── libGLProgrammability.dylib</div><div>├── libGLVMPlugin.dylib</div><div>├── libLLVMContainer.dylib</div><div>└── module.map</div>
<div><br></div><div>The dylib files have the following format:</div><div>lipo -info /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/OpenGLES.framework/libGLImage.dylib</div>
<div>Architectures in the fat file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/OpenGLES.framework/libGLImage.dylib are: (cputype (16777228) cpusubtype (0)) armv7 armv7s</div>
<div><br></div><div><br></div></div><div><br></div></div>