ios - 查找 Mac OS X 框架时,CMake FIND_LIBRARY 变量设置为 -NOTFOUND
<p><p>我正在尝试将 Mac OS X 框架使用添加到我的程序中,其中包括一些带有 Objective-c++ 代码的文件。</p>
<p>它确实可以与 <code>SET (CMAKE_EXE_LINKER_FLAGS "-framework CoreMedia -framework ... ")</code> 一起使用,但我不太喜欢这种方式,而且似乎是错误的。</p>
<p>这是实际添加的 CMake 部分,但它不起作用,我真的不知道我缺少什么 :( 我尝试使用 </p>
<pre><code>link_directories("${CMAKE_OSX_SYSROOT}/System/Library/Frameworks")
include_directories("${CMAKE_OSX_SYSROOT}/System/Library/Frameworks")
</code></pre>
<p>但它根本没有帮助。代码如下:</p>
<pre><code>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})
</code></pre>
<p>它会产生 cmake 错误:</p>
<pre><code>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 ...>
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>好的,知道了。我需要为 <code>${CMAKE_OSX_SYSROOT}/System/Library</code> 指定 PATHS 变量。我不知道为什么,但它无法自动在这个文件夹中找到它,虽然认为它是一个标准文件夹......</p>
<p>这样调用:</p>
<p>例如,当我链接 <code>AVFoundation</code> 框架时:</p>
<pre><code>add_executable(myprogram)
find_library(SOME_VAR
NAMES AVFoundation
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
PATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
</code></pre>
<p>然后</p>
<pre><code>target_link_libraries(myprogram "${SOME_VAR}/AVFoundation")
</code></pre>
<p>希望对某人有所帮助。</p></p>
<p style="font-size: 20px;">关于ios - 查找 Mac OS X 框架时,CMake FIND_LIBRARY 变量设置为 -NOTFOUND,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/12555804/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/12555804/
</a>
</p>
页:
[1]