CMake Error: “add_subdirectory not given a binary directory”

前端 未结 1 542
星月不相逢
星月不相逢 2020-12-17 16:36

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.

I have two constraints:

相关标签:
1条回答
  • 2020-12-17 17:29

    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)
    

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

    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 explicitely:

    See also documentation for add_subdirectory command.

    0 讨论(0)
提交回复
热议问题