Unable to associate MacOS infrastructure with CMake

I am trying to create a subproject with cmake (this is not an xcode project or even an application for iphone, the result is a cross-platform console executable program that # includes some inherited from C ++ abstract classes written in objective-c ++)

I use this guide to reference the mac os framework: http://www.vtk.org/Wiki/CMake:HowToUseExistingOSXFrameworks

and this macro:

macro(ADD_FRAMEWORK fwname appname) find_library(FRAMEWORK_${fwname} NAMES ${fwname} PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH) if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) MESSAGE(ERROR ": Framework ${fwname} not found") else() TARGET_LINK_LIBRARIES(${appname} ${FRAMEWORK_${fwname}}) MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}") endif() endmacro(ADD_FRAMEWORK) 

This is an important part in CMakeLists.txt

 project(myprojectname) ........ add_executable(mytarget src/mytarget.cpp) add_framework(CoreMedia mytarget) add_framework(CoreVideo mytarget) add_framework(AVFoundation mytarget) add_framework(Foundation mytarget) ........ 

And what I have when trying to build:

 WARNING: Target "mytarget" requests linking to directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CoreMedia.framework". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "mytarget" requests linking to directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/CoreVideo.framework". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "mytarget" requests linking to directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/AVFoundation.framework". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "mytarget" requests linking to directory "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/Foundation.framework". Targets may link only to libraries. CMake is dropping the item. 

It actually finds all these frameworks, but cannot communicate, which creates many linker errors. I am sure the reason is that I did testproj using Xcode and it has the same errors until I bundle all the necessary frameworks.

When i just use

 FIND_LIBRARY(COREMEDIA_LIB CoreMedia) ... 

then COREMEDIA_LIB set to NOTFOUND - what happens?: /

I walked a lot, but nothing :( Feeling pretty much lost there.

+6
source share
1 answer

Which is sad that no one answered :( This process is strengthened and got the following: you need to bind NOT the frameworkname.framework folder in TARGET_LINK_LIBRARIES , but the file fwname.framework/fwname ! Now it works just like that.

Modified Macro:

 macro(ADD_FRAMEWORK fwname appname) find_library(FRAMEWORK_${fwname} NAMES ${fwname} PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH) if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) MESSAGE(ERROR ": Framework ${fwname} not found") else() TARGET_LINK_LIBRARIES(${appname} "${FRAMEWORK_${fwname}}/${fwname}") MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}") endif() endmacro(ADD_FRAMEWORK) 

Hope this will be helpful for someone ...

+16
source

Source: https://habr.com/ru/post/926016/


All Articles