I have a specific file that should be rebuilt on each compilation regardless if it has been modified or not. The reason is that it is depending on system macros whose values change. How could I force rebuild with CMake? I'd like to not bind it to specific target: the file should be "touched" before any of the targets specified in CMakeLists.txt begins the actual build process.
Asked
Active
Viewed 2,228 times
1 Answers
1
CMake has a add_custom_target
command:
Adds a target with the given name that executes the given commands. The target has no output file and is always considered out of date even if the commands try to create a file with the name of the target. [...] By default nothing depends on the custom target. Use the
add_dependencies()
command to add dependencies to or from other targets.

pynexj
- 19,215
- 5
- 38
- 56
-
Is it possible to set some "execute before other targets" flag to target, or does it have to be added manually as a dependency to all other targets? The build system in our project is quite complicated and I'm trying to keep things simple to maintain. – eko Nov 23 '18 at 06:11