Using CMake + Ninja to Download Dependencies with GIT
I have an ExternalProject dependency that is cloned (using git) during the build process. This all works great with CMake + Make.
mkdir build && cd build;
cmake ..
make
It clones and builds the library correctly with git when I type make.
However, when I use the ninja generator:
mkdir build && cd build;
cmake -GNinja ..
ninja
I am getting the following error:
$ 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
Is git loading external projects not supported by cmake + ninja command?
source to share
It turns out if you do a clean in front of the building everything works and the ninja loads my dependencies correctly.
So the workflow looks like this:
mkdir build && cd build
cmake -G Ninja ..
ninja clean # if you don't do this, it will not download Externalproject dependencies
ninja
There must be some bug in the ninja generator, but I am happy with this workflow.
source to share