CMake设置默认搜索路径? [英] CMake Set Default Search Path?

查看:1162
本文介绍了CMake设置默认搜索路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是不想每次都需要一个库时都设置一个环境变量,让所有搜索的路径都没有完全标准化(至少在Windows上)是孤独的。通常,Find * .cmake不会在Windows上指定任何与关联的位置。

I simply don't want to set an environment variable every time i need a library, let a lone the paths searched are not standardized at all (at least on windows). Generally the Find*.cmake doesn't specify any locations with association on windows.

是否可以通过某种方式使CMake搜索指定目录(强制配置错误的Find *。 cmake搜索原本不会在系统级别设置的路径)?说我要它在Windows上的 C:\上搜索还是在 /上搜索?这样,我可以将所有库都放在 C:\中。

Is there some way to make CMake search a specified directory (forcing bad configured Find*.cmake to search paths they otherwise wouldn't set at the system level)? Say i want it to search on "C:\" or just "/" on windows? That way i can just put all my libraries in "C:\".

推荐答案

您可以尝试将路径附加到<项目CMakeLists.txt中的href = http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_PREFIX_PATH.html rel = noreferrer> CMAKE_PREFIX_PATH ,如下所示:

You can try to append paths to CMAKE_PREFIX_PATH in your project CMakeLists.txt, something like this:

list(APPEND CMAKE_PREFIX_PATH "/tmp/test" "/another/library/path")

根据文档,它将在列表中每个路径的末尾附加 / lib并在其中搜索库,但是通过一些快速测试,如果cmake直接位于您指定的路径中,则看起来应该没问题。例如,如果我有 /tmp/test/libtest.so 并添加上面的行,则可以这样找到它:

According to the documentation, it will append "/lib" to the end of each path in the list and search for libraries there, but with some quick testing, it seems like cmake should find things alright if it's directly in a path you specify. For example, if I have /tmp/test/libtest.so and add the line above, I can find it like so:

find_library(libtest_LIBRARY test)

运行cmake应该使用正确的路径设置缓存变量 libtest_LIBRARY

Running cmake should set the cache variable libtest_LIBRARY with the right path.

这篇关于CMake设置默认搜索路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆