1. <tfoot id='68duU'></tfoot>

      <small id='68duU'></small><noframes id='68duU'>

      <legend id='68duU'><style id='68duU'><dir id='68duU'><q id='68duU'></q></dir></style></legend>
        <bdo id='68duU'></bdo><ul id='68duU'></ul>
    1. <i id='68duU'><tr id='68duU'><dt id='68duU'><q id='68duU'><span id='68duU'><b id='68duU'><form id='68duU'><ins id='68duU'></ins><ul id='68duU'></ul><sub id='68duU'></sub></form><legend id='68duU'></legend><bdo id='68duU'><pre id='68duU'><center id='68duU'></center></pre></bdo></b><th id='68duU'></th></span></q></dt></tr></i><div id='68duU'><tfoot id='68duU'></tfoot><dl id='68duU'><fieldset id='68duU'></fieldset></dl></div>
    2. CMake 错误:“add_subdirectory 未给出二进制目录"

      CMake Error: quot;add_subdirectory not given a binary directoryquot;(CMake 错误:“add_subdirectory 未给出二进制目录)
      <tfoot id='yTFqL'></tfoot>
        <tbody id='yTFqL'></tbody>

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

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

              • 本文介绍了CMake 错误:“add_subdirectory 未给出二进制目录"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试将 Google Test 集成到更大项目的子项目中,但找不到令我满意的解决方案.

                I am trying to integrate Google Test into the subproject of bigger project and I cannot find the solution that would be satisfying for me.

                我有两个限制:

                • Google Test 的源代码已经存在于项目结构中(因此不能使用 URL 从 git 存储库下载它)
                • Google Test 的源代码不是我的子项目的子目录(并且永远不会)

                所以当我尝试做这样的事情时:

                So when I tried to do something like this:

                add_subdirectory( ${GOOGLETEST_PROJECT_LOCATION})
                

                我收到了:

                CMake Error at unit_tests/CMakeLists.txt:10 (add_subdirectory):
                  add_subdirectory not given a binary directory but the given source
                  directory "${GOOGLETEST_PROJECT_LOCATION}" is not a subdirectory of
                  "${UNIT_TEST_DIRECTORY}".  When
                  specifying an out-of-tree source a binary directory must be explicitly
                  specified.
                

                另一方面,ExternalProject_Add 可能是一个解决方案,但当我根本不想下载源代码并使用项目中特定位置的源代码时,我不知道该如何使用它.

                On the other hand maybe ExternalProject_Add could be a solution but I do not know how shall I use it when I do not want to download sources at all and use sources from specific location in the project.

                项目结构看起来更像这样:

                Project structure looks more or like like this:

                3rdparty 
                    |--googletest 
                ...
                subproject
                   |--module1
                      |--file1.cpp
                      |--CMakeLists.txt
                   |--module2
                      |--file2.cpp
                      |--CMakeLists.txt
                   |--include
                      |--module1
                          |--file1.h
                      |--module2
                          |--file2.h
                   |--unit_test
                       |--module1
                           |--file1test.cpp
                       |--module2
                           |--file2test.cpp
                       |--CMakeLists.txt
                   |--CMakeLists.txt
                CMakeLists.txt
                

                推荐答案

                错误信息很明确 - 您还应该为 googletest 指定构建目录.

                The error message is clear - you should also specify build directory for googletest.

                # This will build googletest under build/ subdirectory in the project's build tree
                add_subdirectory( ${GOOGLETEST_PROJECT_LOCATION} build)
                

                当您将 relative 路径(作为 source 目录)提供给 add_subdirectory 调用时,CMake 会自动为 使用相同的相对路径>build 目录.

                When you give relative path (as a source directory) to add_subdirectory call, CMake automatically uses the same relative path for the build directory.

                但是在绝对源路径的情况下(当这个路径不在你的源代码树中时),CMake无法猜测build目录,你需要提供它明确:

                But in case of absolute source path (and when this path isn't in your source tree), CMake cannot guess build directory, and you need to provide it explicitly:

                另见文档,了解add_subdirectory 命令.

                这篇关于CMake 错误:“add_subdirectory 未给出二进制目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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='9Sd2J'><tr id='9Sd2J'><dt id='9Sd2J'><q id='9Sd2J'><span id='9Sd2J'><b id='9Sd2J'><form id='9Sd2J'><ins id='9Sd2J'></ins><ul id='9Sd2J'></ul><sub id='9Sd2J'></sub></form><legend id='9Sd2J'></legend><bdo id='9Sd2J'><pre id='9Sd2J'><center id='9Sd2J'></center></pre></bdo></b><th id='9Sd2J'></th></span></q></dt></tr></i><div id='9Sd2J'><tfoot id='9Sd2J'></tfoot><dl id='9Sd2J'><fieldset id='9Sd2J'></fieldset></dl></div>
                • <bdo id='9Sd2J'></bdo><ul id='9Sd2J'></ul>
                  <legend id='9Sd2J'><style id='9Sd2J'><dir id='9Sd2J'><q id='9Sd2J'></q></dir></style></legend>
                  • <tfoot id='9Sd2J'></tfoot>

                    <small id='9Sd2J'></small><noframes id='9Sd2J'>

                        <tbody id='9Sd2J'></tbody>