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

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

        <tfoot id='LKLAg'></tfoot>
          <bdo id='LKLAg'></bdo><ul id='LKLAg'></ul>
      2. CMake 在不同的构建目录中构建多个目标

        CMake build multiple targets in different build directories(CMake 在不同的构建目录中构建多个目标)
            <tfoot id='elq6o'></tfoot>
          • <legend id='elq6o'><style id='elq6o'><dir id='elq6o'><q id='elq6o'></q></dir></style></legend>
                <bdo id='elq6o'></bdo><ul id='elq6o'></ul>

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

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

                    <tbody id='elq6o'></tbody>

                  本文介绍了CMake 在不同的构建目录中构建多个目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下 CMake 结构:

                  I have the following CMake structure:

                  CMakelists.txt
                  toolchain.cmake
                  folder1
                     ----CMakelists.txt
                  folder2
                     ----CMakelists.txt
                  etc..
                  

                  我的一级 CMakelists.txt 文件包括其他子目录.现在我想为不同的目标构建我的代码.

                  My first-level CMakelists.txt file includes the other subdirectories. Now I want to build my code for a different target.

                  手动方式是:

                  1.
                      mkdir hostBuild
                      cd hostBuild
                      cmake ..
                      make
                  
                  2.
                      mkdir crossBuild
                      cd crossBuild
                      cmake .. --DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
                      make
                  

                  这个进程有可能自动运行吗?

                  Is it possible that this process can run automatically?

                  例如,我只需要在我的第一级运行 cmake ..

                  For example, I just have to run cmake . at my first level.

                  这样的事情有可能吗?

                  推荐答案

                  没有.建议是将您的手动步骤放入 shell 脚本中.

                  No. The recommendation would be to just put your manual steps into a shell script.

                  CMake 一次只能处理一个编译器/make 环境(如果你切换编译器你需要一个不同的二进制输出目录).

                  CMake can only handle one compiler/make environment at a time (if you switch the compiler you need a different binary output directory).

                  特别是包含 SET(CMAKE_SYSTEM_NAME ...) 的工具链文件确实改变了配置/生成过程的整个结果.

                  Especially a toolchain file that does contain SET(CMAKE_SYSTEM_NAME ...) does change the whole outcome of the configuration/generation process.

                  有关 CMake 所见的详细信息:CMake:在解析文件的顺序是什么(缓存、工具链……)?

                  For details on what CMake does see: CMake: In which Order are Files parsed (Cache, Toolchain, …)?

                  你可以在你的 shell 脚本中使用一些 CMake 命令行选项:

                  And you could make use of some CMake command line options in your shell script:

                  if [ ! -d hostBuild ]; then
                      cmake -E make_directory hostBuild
                      cmake -E chdir hostBuild cmake ..
                  fi
                  cmake --build hostBuild
                  ...
                  

                  这篇关于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='nHzR5'><tr id='nHzR5'><dt id='nHzR5'><q id='nHzR5'><span id='nHzR5'><b id='nHzR5'><form id='nHzR5'><ins id='nHzR5'></ins><ul id='nHzR5'></ul><sub id='nHzR5'></sub></form><legend id='nHzR5'></legend><bdo id='nHzR5'><pre id='nHzR5'><center id='nHzR5'></center></pre></bdo></b><th id='nHzR5'></th></span></q></dt></tr></i><div id='nHzR5'><tfoot id='nHzR5'></tfoot><dl id='nHzR5'><fieldset id='nHzR5'></fieldset></dl></div>

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

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

                          • <small id='nHzR5'></small><noframes id='nHzR5'>