2

I'm trying to add an external project, that doesn't use cmake, to my project that does use cmake:

include(ExternalProject)

ExternalProject_Add( MatrixSSL
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/matrixssl
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matrixssl
  CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh
  BUILD_COMMAND echo "Built!"
  INSTALL_COMMAND echo "Installing!"
)

Here the script ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh will do whatever is required to configure that external project (aka, generate the Makefile's).

My problem is that when I edit configure_matrixssl.sh and re-run 'make', then the configure step is not repeated. Therefore I want to add a dependency of the 'configure step' on my script; when the modification time of my script is newer than the modification time of the configure timestamp file, it should redo the configuration step.

I tried,

ExternalProject_Add_Step( MatrixSSL configure
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh
)

but this has no effect.

Then I tried,

ExternalProject_Add_Step( MatrixSSL configure
  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh   
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh
)

but that gives me the error

CMake Error: Attempt to add a custom rule to output "/home/carlo/projects/aicxx/ai-evio-testsuite/ai-evio-testsuite-objdir/evio/matrixssl/src/MatrixSSL-stamp/MatrixSSL-configure.rule" which already has a custom rule.

Removing the CONFIGURE_COMMAND from the ExternalProject_Add has no effect.

How can I do this?

Carlo Wood
  • 5,648
  • 2
  • 35
  • 47
  • There is `ExternalProject_Add_StepDependencies` command. While [documentation](https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add_stepdependencies) states that "The dependencies added must be targets", internally this function uses `add_custom_command(APPEND)` which should work with files too. `ExternalProject_Add_StepDependencies( MatrixSSL configure ${CMAKE_CURRENT_SOURCE_DIR}/configure_matrixssl.sh)`. – Tsyvarev Dec 15 '19 at 14:15

0 Answers0