<i id='AcOHR'><tr id='AcOHR'><dt id='AcOHR'><q id='AcOHR'><span id='AcOHR'><b id='AcOHR'><form id='AcOHR'><ins id='AcOHR'></ins><ul id='AcOHR'></ul><sub id='AcOHR'></sub></form><legend id='AcOHR'></legend><bdo id='AcOHR'><pre id='AcOHR'><center id='AcOHR'></center></pre></bdo></b><th id='AcOHR'></th></span></q></dt></tr></i><div id='AcOHR'><tfoot id='AcOHR'></tfoot><dl id='AcOHR'><fieldset id='AcOHR'></fieldset></dl></div>

      1. <tfoot id='AcOHR'></tfoot>

        <small id='AcOHR'></small><noframes id='AcOHR'>

        <legend id='AcOHR'><style id='AcOHR'><dir id='AcOHR'><q id='AcOHR'></q></dir></style></legend>

        • <bdo id='AcOHR'></bdo><ul id='AcOHR'></ul>

        cmake - find_library - 自定义库位置

        cmake - find_library - custom library location(cmake - find_library - 自定义库位置)
          <bdo id='nXLMT'></bdo><ul id='nXLMT'></ul>

            <i id='nXLMT'><tr id='nXLMT'><dt id='nXLMT'><q id='nXLMT'><span id='nXLMT'><b id='nXLMT'><form id='nXLMT'><ins id='nXLMT'></ins><ul id='nXLMT'></ul><sub id='nXLMT'></sub></form><legend id='nXLMT'></legend><bdo id='nXLMT'><pre id='nXLMT'><center id='nXLMT'></center></pre></bdo></b><th id='nXLMT'></th></span></q></dt></tr></i><div id='nXLMT'><tfoot id='nXLMT'></tfoot><dl id='nXLMT'><fieldset id='nXLMT'></fieldset></dl></div>
                  <tbody id='nXLMT'></tbody>

                <legend id='nXLMT'><style id='nXLMT'><dir id='nXLMT'><q id='nXLMT'></q></dir></style></legend>

              • <small id='nXLMT'></small><noframes id='nXLMT'>

                <tfoot id='nXLMT'></tfoot>
                  本文介绍了cmake - find_library - 自定义库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在尝试为我的项目运行 CMake(在 Windows 上).我想使用安装所有库的自定义位置.为了告知 CMake 我尝试这样做的路径:

                  I'm currently trying to get CMake running for my project (on windows). I want to use a custom location where all libraries are installed. To inform CMake about that path I tried to do that:

                  set(CMAKE_PREFIX_PATH D:/develop/cmake/libs)
                  

                  但是当我尝试使用

                  find_library(CURL_LIBRARY NAMES curl curllib libcurl_imp curllib_static)
                  

                  CMake 找不到.当我将前缀路径设置为

                  CMake can't find it. When I set my prefix path to

                  set(CMAKE_PREFIX_PATH D:/develop/cmake/libs/curl)
                  

                  ...图书馆位于.

                  所以我的问题是:如何正确配置 CMake 以在自定义位置使用目录结构,如下所示:

                  So my question is: How can I configure CMake properly to work with a directory structore at a custom location which looks like that:

                  D:/develop/cmake/libs/
                  -> libA
                     -> include
                     -> lib
                  -> libB
                     -> include
                     -> lib
                  -> ...
                     -> include
                     -> lib
                  

                  在include"中是公共头文件,在lib"中是编译后的库.

                  In "include" lie the public headers and in "lib" are the compiled libraries.

                  希望有人能帮助我 - 提前致谢

                  Hope someone can help me - Thanks in advance

                  我目前的解决方法是,在我搜索库之前执行此操作:

                  edit: The current workaround for me is, to do this before i search for libraries:

                  set(CUSTOM_LIBRARY_PATH D:/develop/cmake/libs)
                  file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*)
                  foreach(dir ${sub-dir})
                      if(IS_DIRECTORY ${dir})
                          set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${dir})
                      endif()
                  endforeach()
                  

                  但是那样boost的默认模块直到它才会找到它,因为boost的目录结构有点不同.

                  But that way the default module for boost wont find it until it because the directory structore of boost is a bit different.

                  boost -> include -> boost-1_50 -> *.hpp
                  

                  当我移动内容时,如果boost-1_50"到include",可以找到库,但这样就不可能处理多个版本,对吗?

                  When I move the content if "boost-1_50" to "include" the library can be found but that way it's not possible to handle multiple versions right?

                  推荐答案

                  我看到有两个人把这个问题放到了他们的收藏夹中,所以我会尝试回答对我有用的解决方案:我没有使用查找模块,而是为所有已安装的库编写配置文件.这些文件非常简单,也可以用来设置非标准变量.CMake 将(至少在 Windows 上)在

                  I saw that two people put that question to their favorites so I will try to answer the solution which works for me: Instead of using find modules I'm writing configuration files for all libraries which are installed. Those files are extremly simple and can also be used to set non-standard variables. CMake will (at least on windows) search for those configuration files in

                  CMAKE_PREFIX_PATH/<<package_name>>-<<version>>/<<package_name>>-config.cmake
                  

                  (可以通过环境变量设置).所以例如boost配置在路径中

                  (which can be set through an environment variable). So for example the boost configuration is in the path

                  CMAKE_PREFIX_PATH/boost-1_50/boost-config.cmake
                  

                  在该配置中,您可以设置变量.我的 boost 配置文件如下所示:

                  In that configuration you can set variables. My config file for boost looks like that:

                  set(boost_INCLUDE_DIRS ${boost_DIR}/include)
                  set(boost_LIBRARY_DIR ${boost_DIR}/lib)
                  foreach(component ${boost_FIND_COMPONENTS}) 
                      set(boost_LIBRARIES ${boost_LIBRARIES} debug ${boost_LIBRARY_DIR}/libboost_${component}-vc110-mt-gd-1_50.lib)
                      set(boost_LIBRARIES ${boost_LIBRARIES} optimized ${boost_LIBRARY_DIR}/libboost_${component}-vc110-mt-1_50.lib)
                  endforeach()
                  add_definitions( -D_WIN32_WINNT=0x0501 )
                  

                  非常简单+当您编写一些辅助函数时,可以进一步缩小配置文件的大小.我在这个设置中遇到的唯一问题是我没有找到一种方法来让配置文件优先于查找模块 - 所以你需要删除查找模块.

                  Pretty straight forward + it's possible to shrink the size of the config files even more when you write some helper functions. The only issue I have with this setup is that I havn't found a way to give config files a priority over find modules - so you need to remove the find modules.

                  希望这对其他人有帮助.

                  Hope this this is helpful for other people.

                  这篇关于cmake - find_library - 自定义库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                  <tfoot id='JLXWi'></tfoot>
                      <tbody id='JLXWi'></tbody>

                        <legend id='JLXWi'><style id='JLXWi'><dir id='JLXWi'><q id='JLXWi'></q></dir></style></legend>

                        <small id='JLXWi'></small><noframes id='JLXWi'>

                          • <bdo id='JLXWi'></bdo><ul id='JLXWi'></ul>

                            <i id='JLXWi'><tr id='JLXWi'><dt id='JLXWi'><q id='JLXWi'><span id='JLXWi'><b id='JLXWi'><form id='JLXWi'><ins id='JLXWi'></ins><ul id='JLXWi'></ul><sub id='JLXWi'></sub></form><legend id='JLXWi'></legend><bdo id='JLXWi'><pre id='JLXWi'><center id='JLXWi'></center></pre></bdo></b><th id='JLXWi'></th></span></q></dt></tr></i><div id='JLXWi'><tfoot id='JLXWi'></tfoot><dl id='JLXWi'><fieldset id='JLXWi'></fieldset></dl></div>