Dear all,

I thought I would post this here before filing a bug, to see if anyone else has 
encountered this problem.

The 'BUILD_ALWAYS 1' option for 'ExternalProject_Add' does not run the install 
command when used with Ninja. This behaviour can be demonstrated with the 
following project:

  CMakeLists.txt (1)
  foo/
    CMakeLists.txt (2)

Where CMakeLists.txt (1) contains:

  cmake_minimum_required(VERSION 3.2)
  include(ExternalProject)
  ExternalProject_Add(foo
    SOURCE_DIR foo
    CONFIGURE_COMMAND ""
    BUILD_COMMAND echo "building foo"
    INSTALL_COMMAND "installing foo"
    BUILD_ALWAYS 1)

And CMakeLists.txt (2) is empty.

In the top level directory, initialising CMake, then running 'ninja':

  $ cmake . -DCMAKE_GENERATOR=Ninja
  ...
  $ ninja
  [6/8] Performing build step for 'foo'
  building foo
  [7/8] Performing install step for 'foo'
  installing foo
  [8/8] Completed 'foo'
  $ ninja
  [1/3] Performing build step for 'foo'
  building foo
  $ ninja
  [1/3] Performing build step for 'foo'
  building foo
  $ ninja
  [1/3] Performing build step for 'foo'
  building foo

Causes the build and install step to run the first time, but only the build 
step to run after.

With Make, the build and install steps are always run, as I would expect:

  $ cmake . -DCMAKE_GENERATOR='Unix Makefiles'
  ...
  $ make
  Scanning dependencies of target foo
  [ 12%] Creating directories for 'foo'
  [ 25%] No download step for 'foo'
  [ 37%] No patch step for 'foo'
  [ 50%] No update step for 'foo'
  [ 62%] No configure step for 'foo'
  [ 75%] Performing build step for 'foo'
  building foo
  [ 87%] Performing install step for 'foo'
  installing foo
  [100%] Completed 'foo'
  [100%] Built target foo
  $ make
  [ 12%] Performing build step for 'foo'
  building foo
  [ 25%] Performing install step for 'foo'
  installing foo
  [ 37%] Completed 'foo'
  [100%] Built target foo
  $ make
  [ 12%] Performing build step for 'foo'
  building foo
  [ 25%] Performing install step for 'foo'
  installing foo
  [ 37%] Completed 'foo'
  [100%] Built target foo

Similarly, with CMakeLists.txt (1) this time containing an 
'ExternalProject_Add_Step' and 'ALWAYS 1':

  cmake_minimum_required(VERSION 3.2)
  include(ExternalProject)
  ExternalProject_Add(foo
    SOURCE_DIR foo
    CONFIGURE_COMMAND ""
    BUILD_COMMAND echo "building foo"
    INSTALL_COMMAND echo "installing foo"
    )
  ExternalProject_Add_Step(foo force_rebuild DEPENDERS build ALWAYS 1)

Make works as above, but this time, Ninja does not run the build or install 
steps after the first run:

$ cmake . -DCMAKE_GENERATOR=Ninja
...
$ ninja
[7/9] Performing build step for 'foo'
building foo
[8/9] Performing install step for 'foo'
installing foo
[9/9] Completed 'foo'
$ ninja
[1/4] No force_rebuild step for 'foo'
$ ninja
[1/4] No force_rebuild step for 'foo'

In these examples, I'm using CMake 3.3.1, Ninja 1.3.4 and Make 3.81.

Cheers,
Jamie
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to