我正在尝试使用cmake构建一个子项目(它不是xcode项目,甚至不是iphone的应用程序,结果是跨平台控制台可执行文件,其中#includes一些从C++抽象类继承的,用objective-c++编写的)
我正在使用本指南链接 mac os 框架:http ://www.vtk.org/Wiki/CMake:HowToUseExistingOSXFrameworks
这个宏:
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)
这是 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)
........
这就是我在尝试构建时所拥有的:
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.
它实际上找到了所有这些框架,但无法链接,这会产生很多链接器错误。我很确定这就是原因,因为我使用 XCode 制作了一个 testproj,并且在我链接所有需要的框架之前它具有相同的错误。
当我只是使用
FIND_LIBRARY(COREMEDIA_LIB CoreMedia)
...
然后COREMEDIA_LIB
设置为NOTFOUND
- 发生了什么事?:/
我用谷歌搜索了很多,但什么也没有:(在那里感觉很迷茫。