<tfoot id='XXYbc'></tfoot>

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

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

        CMake 安装(子目录中的 TARGETS)

        CMake install (TARGETS in subdirectories)(CMake 安装(子目录中的 TARGETS))

          <tfoot id='NLxdR'></tfoot>

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

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

                  <bdo id='NLxdR'></bdo><ul id='NLxdR'></ul>

                  本文介绍了CMake 安装(子目录中的 TARGETS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  考虑以下 CMakeLists.txt 文件:

                  add_subdirectory(execA)
                  add_subdirectory(libB)
                  
                  install(TARGETS execA libB
                          RUNTIME DESTINATION bin
                          LIBRARY DESTINATION lib
                          ARCHIVE DESTINATION lib)
                  

                  我收到以下错误:

                  install TARGETS given target "execA" which does not exist in this
                    directory
                  

                  execAlibB 有自己的 CMakeList.txt 文件,也位于 project 目录下作为我运行的构建目录 cmake (cmake ..):

                  execA and libB have their own CMakeList.txt files and are located under project directory, as well as the build directory I'm running cmake (cmake ..):

                  project
                    |------ CMakeList.txt (the one with the code)
                    |----execA
                    |      - .cpp, .hpp and CMakelist.txt
                    |----libB
                    |      - .cpp, .hpp and CMakelist.txt
                    |---- lib
                    |---- bin
                    ---- build (where Im commanding: $ cmake ..
                  

                  我该如何解决这个错误?

                  How do I fix this error?

                  推荐答案

                  根据 this bugreport、install(TARGETS) 命令流只接受在同一目录中创建的目标.

                  According to this bugreport, install(TARGETS) command flow accepts only targets created within the same directory.

                  因此您需要将 add_library() 调用移动到顶级目录,或者将 install(TARGETS) 调用拆分为每个目标的调用,然后将每个调用将它们放到相应的子目录中.

                  So you need either move the add_library() call into the top-level directory, or split install(TARGETS) call into per-target ones, and move each of them into the corresponding subdirectory.

                  自 CMake 3.13 install(TARGETS) 即使使用在其他目录中创建的目标也可以工作.

                  Since CMake 3.13 install(TARGETS) can work even with targets created in other directories.

                  install(TARGETS) 可以安装在其他目录中创建的目标.当使用这样的跨目录安装规则时,从子目录运行 make install(或类似的)不能保证来自其他目录的目标是最新的.

                  install(TARGETS) can install targets that were created in other directories. When using such cross-directory install rules, running make install (or similar) from a subdirectory will not guarantee that targets from other directories are up-to-date.

                  这篇关于CMake 安装(子目录中的 TARGETS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)

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

                      <bdo id='kXKUU'></bdo><ul id='kXKUU'></ul>
                            <tbody id='kXKUU'></tbody>

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

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