<tfoot id='IYn4d'></tfoot>

  1. <small id='IYn4d'></small><noframes id='IYn4d'>

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

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

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

      对同一语言的多个编译器使用 CMake

      Using CMake with multiple compilers for the same language(对同一语言的多个编译器使用 CMake)

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

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

            <bdo id='Surk2'></bdo><ul id='Surk2'></ul>
            1. <tfoot id='Surk2'></tfoot>

                  <tbody id='Surk2'></tbody>
                本文介绍了对同一语言的多个编译器使用 CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                似乎 CMake 认为所有 C++ 源文件都应该有一个,而且只有一个 CMAKE_CXX_COMPILER.我找不到在每个目标的基础上覆盖它的方法.这使得使用内置 CMake 工具在单个 CMakeLists.txt 中混合主机和交叉编译变得非常困难.

                It seems like CMake is fairly entrenched in its view that there should be one, and only one, CMAKE_CXX_COMPILER for all C++ source files. I can't find a way to override this on a per-target basis. This makes a mix of host-and-cross compiling in a single CMakeLists.txt very difficult with the built-in CMake facilities.

                所以,我的问题是:为同一语言(即 C++)使用多个编译器的最佳方法是什么?

                So, my question is: what's the best way to use multiple compilers for the same language (i.e. C++)?

                推荐答案

                CMake 无法做到这一点.

                It's impossible to do this with CMake.

                CMake 只保留一组编译器属性,这些属性由 CMakeLists.txt 文件中的所有目标共享.如果要使用两个编译器,则需要运行 CMake 两次.这甚至适用于例如从同一个编译器工具链构建 32 位和 64 位二进制文件.

                CMake only keeps one set of compiler properties which is shared by all targets in a CMakeLists.txt file. If you want to use two compilers, you need to run CMake twice. This is even true for e.g. building 32bit and 64bit binaries from the same compiler toolchain.

                解决这个问题的快速而肮脏的方法是使用自定义命令.但是你最终会得到基本上美化的 shell 脚本,这可能不是你想要的.

                The quick-and-dirty way around this is using custom commands. But then you end up with what are basically glorified shell-scripts, which is probably not what you want.

                干净的解决方案是:不要将它们放在同一个 CMakeLists.txt 中!无论如何,您无法在不同架构之间进行链接,因此无需将它们放在同一个文件中.您可以通过将 CMake 脚本的公共部分重构为单独的文件并include() 它们来减少冗余.

                The clean solution is: Don't put them in the same CMakeLists.txt! You can't link between different architectures anyway, so there is no need for them to be in the same file. You may reduce redundancies by refactoring common parts of the CMake scripts into separate files and include() them.

                这里的主要缺点是您无法使用单个命令进行构建,但是您可以通过使用您最喜欢的脚本语言编写一个包装器来解决这个问题,它负责调用不同的 CMake-makefile.

                The main disadvantage here is that you lose the ability to build with a single command, but you can solve that by writing a wrapper in your favorite scripting language that takes care of calling the different CMake-makefiles.

                这篇关于对同一语言的多个编译器使用 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?)
              1. <tfoot id='n16eY'></tfoot>

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

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

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

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