我正在尝试将 Mac OS X 框架使用添加到我的程序中,其中包括一些带有 Objective-c++ 代码的文件。
它确实可以与 SET (CMAKE_EXE_LINKER_FLAGS "-framework CoreMedia -framework ... ") 一起使用,但我不太喜欢这种方式,而且似乎是错误的。
这是实际添加的 CMake 部分,但它不起作用,我真的不知道我缺少什么 我尝试使用
link_directories("${CMAKE_OSX_SYSROOT}/System/Library/Frameworks")
include_directories("${CMAKE_OSX_SYSROOT}/System/Library/Frameworks")
但它根本没有帮助。代码如下:
add_executable(myprogram src/myprogram.cpp)
FIND_LIBRARY(COREMEDIA_LIB NAMES CoreMedia)
FIND_LIBRARY(COREVIDEO_LIB NAMES CoreVideo)
FIND_LIBRARY(FOUNDATION_LIB NAMES Foundation)
FIND_LIBRARY(AVFOUNDATION_LIB NAMES AVFoundation)
target_link_libraries(myprogram ${COREMEDIA_LIB})
target_link_libraries(myprogram ${COREVIDEO_LIB})
target_link_libraries(myprogram ${FOUNDATION_LIB})
target_link_libraries(myprogram ${AVFOUNDATION_LIB})
它会产生 cmake 错误:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
AVFOUNDATION_LIB
linked by target "myprogram" in directory <some directory containing app>
<... other 3 are here aswell ...>
Best Answer-推荐答案 strong>
好的,知道了。我需要为 ${CMAKE_OSX_SYSROOT}/System/Library 指定 PATHS 变量。我不知道为什么,但它无法自动在这个文件夹中找到它,虽然认为它是一个标准文件夹......
这样调用:
例如,当我链接 AVFoundation 框架时:
add_executable(myprogram)
find_library(SOME_VAR
NAMES AVFoundation
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
PATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
然后
target_link_libraries(myprogram "${SOME_VAR}/AVFoundation")
希望对某人有所帮助。
关于ios - 查找 Mac OS X 框架时,CMake FIND_LIBRARY 变量设置为 -NOTFOUND,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/12555804/
|