<tfoot id='1J4zm'></tfoot>
    <legend id='1J4zm'><style id='1J4zm'><dir id='1J4zm'><q id='1J4zm'></q></dir></style></legend>

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

    <small id='1J4zm'></small><noframes id='1J4zm'>

      • <bdo id='1J4zm'></bdo><ul id='1J4zm'></ul>

      1. CPack:从子目录(googletest 目录)中排除 INSTALL 命令

        时间:2023-06-30

              <bdo id='1MMkn'></bdo><ul id='1MMkn'></ul>

                <tfoot id='1MMkn'></tfoot>
                  <tbody id='1MMkn'></tbody>

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

                2. <legend id='1MMkn'><style id='1MMkn'><dir id='1MMkn'><q id='1MMkn'></q></dir></style></legend>
                  本文介绍了CPack:从子目录(googletest 目录)中排除 INSTALL 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在一个项目中使用 CMake,在我的测试用例中使用 googletest.环顾互联网,将 googletest 源代码复制到存储库的子文件夹中并将其包含在add_subdirectory(googletest)"中似乎是常见做法.我就是这么做的.

                  I'm using CMake for a project and googletest for my test cases. Looking around the internet, it seems to be common practise to just copy the googletest source into a subfolder of your repository and include it with "add_subdirectory(googletest)". I did that.

                  现在我使用 CPack 为我的项目生成 debian 包.不幸的是,CPack 生成的包与我的项目一起安装了 googletest.这当然不是我想要的.

                  Now I'm using CPack to generate debian packages for my project. Unfortunately, the packages generated by CPack install googletest alongside with my project. This is of course not what I want.

                  查看 googletest 目录,我在那里发现了一些 INSTALL cmake 命令,所以很清楚,为什么会这样.现在的问题是 - 我怎样才能避免它?我不喜欢从 googletest 修改 CMakeLists.txt 文件,因为我必须记住在更新时重新应用我的修改.还有其他方法可以在 CPack 中禁用这些安装吗?

                  Looking in the googletest directory, I found some INSTALL cmake commands there, so it is clear, why it happens. The question is now - how can I avoid it? I don't like modifying the CMakeLists.txt files from googletest, because I would have to remember re-applying my modifications on an update. Is there another way to disable these installs in CPack?

                  推荐答案

                  更新:如中所述其他答案,似乎EXCLUDE_FROM_ALL选项是在子目录下的子项目中禁用install的最直接和正确的方法:

                  Updated: As noted in the other answer, it seems that EXCLUDE_FROM_ALL option is the most direct and correct way for disable install in the subproject in the subdirectory:

                  add_subdirectory(googletest EXCLUDE_FROM_ALL)
                  


                  以前的解决方案

                  如果您的项目发布中不需要测试(您希望通过 CPack 交付),则有条件地包含 googletest 子目录,并在打包时将条件设置为 false:


                  Previous solutions

                  If you don't need tests in your project's release (which you want to deliver with CPack), then include googletest subdirectory conditionally, and set conditional to false when packaging:

                  ...
                  if(NOT DISABLE_TESTS)
                      add_subdirectory(googletest)
                  endif()
                  

                  包装

                  cmake -DDISABLE_TESTS=ON <source-dir>
                  cpack
                  

                  或者,如果你想要测试,但不想安装测试基础设施,你可以通过定义同名的宏或函数来禁用install命令:

                  Alternatively, if you want tests, but don't want to install testing infrastructure, you may disable install command via defining macro or function with same name:

                  # Replace install() to do-nothing macro.
                  macro(install)
                  endmacro()
                  # Include subproject (or any other CMake code) with "disabled" install().
                  add_subdirectory(googletest)
                  # Restore original install() behavior.
                  macro(install)
                      _install(${ARGN})
                  endmacro()
                  

                  CMake 邮件中也建议了这种方法.

                  根据评论,这种替换 CMake 命令的方式非常棘手,并且在某些情况下可能不起作用:传递给修改后的 install 的参数被错误解析或恢复 install 不起作用,甚至以下 install s 都被禁用.

                  According to the comments, that way with replacing CMake command is very tricky one and may to not work in some cases: either parameters passed to the modified install are parsed incorrectly or restoring install is not work and even following installs are disabled.

                  这篇关于CPack:从子目录(googletest 目录)中排除 INSTALL 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何通过 Windows Defender SmartScreen 保护? 下一篇:如何在 Visual Studio 上为 C++ 安装 MPFR 和 GMP

                  相关文章

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

                      <tfoot id='VgGvO'></tfoot>
                    1. <small id='VgGvO'></small><noframes id='VgGvO'>

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