0

Whatever generator you use, if you modify one of your CMakeLists.txt files, launching a build will trigger cmake and update your project. Let's take the case now of a different file, not in cmake language. How can one get the build process to trigger cmake automatically if this file is modified?

Getting to a concrete example, a project with

CMakeLists.txt:

cmake_minimum_required(VERSION 3.9.2)
project(dummy)

add_executable(dummy dummy.cpp)

dummy.py:

# Some python code
print("This line will be printed.")

dummy.cpp:

int main() 
{
    return 0;
}

How can I get cmake to re-run automatically when I build when dummy.py gets modified?

Antonio
  • 19,451
  • 13
  • 99
  • 197
  • But, why? The whole point is that CMake configures, so you will only want to run the build step. This is designed like this. What do you actually want to achieve that you need this rerun? – Bernhard Dec 05 '18 at 07:26
  • There it is, thanks @Tsyvarev! https://stackoverflow.com/a/32464853/2436175 – Antonio Dec 05 '18 at 07:47
  • @Bernhard, in my case, I have a function which retrieves the version of my project from the `debian/changelog` file. If I update the changelog to add a new version, the project is out of date until cmake re-generates the Makefile. In my case, it's not a target. It's a set of variables which need to be set and that only happens at generation time. – Alexis Wilke Jan 01 '22 at 19:45

0 Answers0