Ninja equivalent of Make's “build from this directory down” feature (with CMake)?

前端 未结 3 2352
小蘑菇
小蘑菇 2021-02-15 14:12

When building a project using CMake and Make, you can execute make from a subdirectory of your build tree (i.e. from a directory below whatever directory contains y

3条回答
  •  半阙折子戏
    2021-02-15 14:47

    This worked for me:

    cd 
    DIRECTORY=
    ninja -t targets all | egrep "^${DIRECTORY}/" | egrep CXX_EXECUTABLE_LINKER | \
        sed -e 's/:.*//g' | xargs ninja
    

    ninja -t targets all - lists all targets (including target type)

    egrep "^${DIRECTORY}/" - filters list of targets to only include those in desired directory

    egrep CXX_EXECUTABLE_LINKER - limits the targets to just C++ executables. You can remove or tweak this to get the set of targets you're interested in.

    sed -e 's/:.*//g' - removes the target type e.g. ": CXX_EXECUTABLE_LINKER"

    xargs ninja - invokes ninja to build the targets

提交回复
热议问题