【问题标题】:How to avoid polluting directory with CMake target logs如何避免使用 CMake 目标日志污染目录
【发布时间】:2017-05-12 16:23:37
【问题描述】:

我有一个简单的项目,其中有一个名为 A 的共享库和一个名为 B 的可执行文件链接 A。我在我的源代码之外进行了 Visual Studio 2017 构建,以便构建目录和源目录具有相同的父目录。这很好。

但是当我构建我的 Visual Studio 2017 解决方案时,许多不需要的目录也会出现在父目录下;每个运行的目标(A、B、INSTALL 等)包含该目标的构建日志。我不想要那些污染日志目录,或者如果它们无法避免的话,如果它们会出现在我的构建目录下,与 Visual Studio 2017 的东西一起出现,那就没问题了。有人知道如何处理吗?

CMake 版本:3.8.1

编辑

最后 3 个目录是不需要的目录:

Parent directory
|-- build-vc15-x64 directory
    |-- VS 2017 related stuff
|-- sources directory
    |-- CMakeLists.txt
    |-- libA sources directory
        |-- stuff for libA
    |-- execB sources directory
        |-- stuff for execB
|-- unexpected directory here when building libA in solution in build-vc15-x64 (contains build log file of libA)
|-- unexpected directory here when building execB in solution in build-vc-15-x64 (contains build log file of execB)
|-- x64 (contains build log file of target INSTALL)

【问题讨论】:

    标签: cmake


    【解决方案1】:

    使用源外构建,换句话说,您的构建和源目录应该是不同的目录。此外,您必须在构建目录中调用 CMake 并构建,而不是在父目录中。 CMake 在它被调用的地方创建了一堆辅助文件和目录。

    在 source 和 build dir 的公共父目录中调用 CMake 是没有意义的。

    【讨论】:

    • 它们在不同的目录中。
    • 我已经用架构编辑了我的问题。你会更好地理解发生了什么。
    猜你喜欢
    • 2010-10-25
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 2014-11-16
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多