<bdo id='5AMcw'></bdo><ul id='5AMcw'></ul>

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

    <small id='5AMcw'></small><noframes id='5AMcw'>

      <legend id='5AMcw'><style id='5AMcw'><dir id='5AMcw'><q id='5AMcw'></q></dir></style></legend>
    1. 从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值

      Overriding a default option(...) value in CMake from a parent CMakeLists.txt(从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值)

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

        <tfoot id='IpQeN'></tfoot>
              <tbody id='IpQeN'></tbody>
            • <bdo id='IpQeN'></bdo><ul id='IpQeN'></ul>

                本文介绍了从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图在我的源代码树中包含几个第三方库,并对其构建系统进行最少的更改,以便于升级.他们和我一样都使用 CMake,所以在我自己的 CMakeLists.txt 中,我可以将 add_subdirectory(extern/foo) 用于 libfoo.

                I am trying to include several third-party libraries in my source tree with minimal changes to their build system for ease of upgrading. They all use CMake, as do I, so in my own CMakeLists.txt I can use add_subdirectory(extern/foo) for libfoo.

                但是 foo CMakeLists.txt 编译测试工具、构建文档、我不需要的共享库,等等.libfoo 作者有先见之明通过选项控制这些 - option(FOO_BUILD_SHARED "Build libfoo shared library" ON) 例如 - 这意味着我可以通过 CMake 命令行设置它们.但我想默认关闭它并且可以通过命令行覆盖.

                But the foo CMakeLists.txt compiles a test harness, builds documentation, a shared library which I don't need, and so on. The libfoo authors had the foresight to control these via options - option(FOO_BUILD_SHARED "Build libfoo shared library" ON) for example - which means I can set them via the CMake command line. But I would like to make that off by default and overridable via the command line.

                我试过在 add_subdirectory(extern/foo) 之前做 set(FOO_BUILD_SHARED OFF).这具有在第二次和后续构建尝试期间不尝试构建共享库的效果,但在第一次尝试构建共享库时不会尝试,这是我真正需要加速的一次.

                I have tried doing set(FOO_BUILD_SHARED OFF) before add_subdirectory(extern/foo). That has the effect of not trying to build the shared library during the second and subsequent build attempts, but not during the first one, which is the one I really need to speed up.

                这是可能的,还是我需要为这些项目维护分叉的 CMakeLists.txt?

                Is this possible, or do I need to maintain forked CMakeLists.txt for these projects?

                推荐答案

                尝试设置 CACHE 中的变量

                Try setting the variable in the CACHE

                SET(FOO_BUILD_SHARED OFF CACHE BOOL "Build libfoo shared library")
                

                注意:您需要指定变量类型和描述,以便 CMake 知道如何在 GUI 中显示此条目.

                Note: You need to specify the variable type and a description so CMake knows how to display this entry in the GUI.

                这篇关于从父 CMakeLists.txt 覆盖 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?)
                <i id='TIF7r'><tr id='TIF7r'><dt id='TIF7r'><q id='TIF7r'><span id='TIF7r'><b id='TIF7r'><form id='TIF7r'><ins id='TIF7r'></ins><ul id='TIF7r'></ul><sub id='TIF7r'></sub></form><legend id='TIF7r'></legend><bdo id='TIF7r'><pre id='TIF7r'><center id='TIF7r'></center></pre></bdo></b><th id='TIF7r'></th></span></q></dt></tr></i><div id='TIF7r'><tfoot id='TIF7r'></tfoot><dl id='TIF7r'><fieldset id='TIF7r'></fieldset></dl></div>
                  <tbody id='TIF7r'></tbody>
                  <tfoot id='TIF7r'></tfoot>
                    <bdo id='TIF7r'></bdo><ul id='TIF7r'></ul>

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

                        • <legend id='TIF7r'><style id='TIF7r'><dir id='TIF7r'><q id='TIF7r'></q></dir></style></legend>