How to add a dependency on a file for the configure step of ExternalProject_Add in cmake

点点圈 提交于 2021-01-05 09:12:19

问题


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?

来源:https://stackoverflow.com/questions/59341301/how-to-add-a-dependency-on-a-file-for-the-configure-step-of-externalproject-add

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!