1. <legend id='WpQI0'><style id='WpQI0'><dir id='WpQI0'><q id='WpQI0'></q></dir></style></legend>

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

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

      cmake 简单配置文件示例

      cmake simple config file example(cmake 简单配置文件示例)

              <tbody id='JbfMn'></tbody>
            <tfoot id='JbfMn'></tfoot>
            <i id='JbfMn'><tr id='JbfMn'><dt id='JbfMn'><q id='JbfMn'><span id='JbfMn'><b id='JbfMn'><form id='JbfMn'><ins id='JbfMn'></ins><ul id='JbfMn'></ul><sub id='JbfMn'></sub></form><legend id='JbfMn'></legend><bdo id='JbfMn'><pre id='JbfMn'><center id='JbfMn'></center></pre></bdo></b><th id='JbfMn'></th></span></q></dt></tr></i><div id='JbfMn'><tfoot id='JbfMn'></tfoot><dl id='JbfMn'><fieldset id='JbfMn'></fieldset></dl></div>
          1. <legend id='JbfMn'><style id='JbfMn'><dir id='JbfMn'><q id='JbfMn'></q></dir></style></legend>
              <bdo id='JbfMn'></bdo><ul id='JbfMn'></ul>
              • <small id='JbfMn'></small><noframes id='JbfMn'>

              • 本文介绍了cmake 简单配置文件示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                现在我有一个我自己制作的库,我想在另一个 CMake c++ 项目中使用它.它像这样存在于我的电脑中.

                Now I have a lib I made my self that I want to use in another CMake c++ project. It exists in my computer like this.

                ${MY_LIB_PATH}include
                ${MY_LIB_PATH}libx86debuglib-files
                ${MY_LIB_PATH}libx86
                eleaselib-files
                ${MY_LIB_PATH}libx64debuglib-files
                ${MY_LIB_PATH}libx64
                eleaselib-files
                

                让 CMake find_package 知道这些的基本配置文件是什么样的?我预计它会非常简单,因为它没有提供太多信息.但是这个页面让我头疼.

                What would a basic config file be like which makes CMake find_package know those? I expected it would be very simple because it just doesn't have much information to provide. But this page just make my head hurt.

                抱歉,我决定复制源代码,所以我真的不知道应该接受哪个答案.

                Sorry, I decided to copy the source code around so I don't really know which answer should be accepted.

                推荐答案

                不要自己写配置;使用 CMake 的 export 命令.此处涵盖的范围太广,无法全部涵盖,但这是我的一个项目中的修改示例:

                Don't write a config yourself; use CMake's export command. It's too broad to cover here in its entirety, but here's a modified example from one of my projects:

                install(TARGETS
                        your_target
                    EXPORT YourPackageConfig
                    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
                    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
                    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                )
                export(TARGETS
                        your_target
                    NAMESPACE YourPackage::
                    FILE "${CMAKE_CURRENT_BINARY_DIR}/YourPackageConfig.cmake"
                )
                install(EXPORT
                        YourPackageConfig
                    DESTINATION "${CMAKE_INSTALL_DATADIR}/YourPackage/cmake"
                    NAMESPACE YourPackage::
                )
                

                这将为您创建配置文件,以便其他项目可以通过 find_package 使用它.

                This will create the config file for you, so other projects can use it via find_package.

                find_package(YourPackage REQUIRED)
                target_link_libraries(foo YouprPackage::your_target)
                

                这会自动处理 IMPORTED 目标,还允许您嵌入编译器标志、包含路径、库依赖项,甚至哪些文件是您的界面的一部分(基本上,任何属于 IMPORTED>INTERFACE 属性).

                This handles the IMPORTED targets automatically, and also lets you embed compiler flags, include paths, library dependencies, and even which files are part of your interface (basically, anything that falls under the INTERFACE properties).

                这篇关于cmake 简单配置文件示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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?)

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

                  <tbody id='y8KuE'></tbody>
              • <legend id='y8KuE'><style id='y8KuE'><dir id='y8KuE'><q id='y8KuE'></q></dir></style></legend>

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

                    <tfoot id='y8KuE'></tfoot>
                      • <bdo id='y8KuE'></bdo><ul id='y8KuE'></ul>