我正在尝试将 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 ...>