使用CMake + Ninja使用GIT下载依赖项

时间:2014-10-29 03:37:01

标签: c++ cmake ninja

我有一个在构建过程中克隆(使用git)的ExternalProject依赖项。这一切都适用于CMake + Make。

mkdir build && cd build; 
cmake ..
make

当我输入make时,它正确克隆并使用git构建库。

然而,当我使用Ninja Generator时:

mkdir build && cd build; 
cmake -GNinja ..
ninja

我收到以下错误:

$ cmake -GNinja ..                                                                                                                                                                                                                                                   -- The C compiler identification is AppleClang 6.0.0.6000054
-- The CXX compiler identification is AppleClang 6.0.0.6000054
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.56.0
-- Found the following Boost libraries:
--   unit_test_framework
-- Found Git: /usr/local/bin/git (found version "2.1.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/carneiro/src/gamgee/build

$ ninja ninja: error: 'contrib/htslib-prefix/src/htslib/libhts.a', needed by 'test/gamgee_test', missing and no known rule to make it

cmake + ninja combo不支持外部项目的git下载吗?

1 个答案:

答案 0 :(得分:2)

如果你在构建之前做了一个干净,那么一切正常,忍者会正确地下载我的依赖项。

因此工作流程如下所示:

mkdir build && cd build
cmake -G Ninja ..
ninja clean  # if you don't do this, it will not download Externalproject dependencies
ninja

Ninja生成器中必定存在某种错误,但我现在对此工作流程感到满意。