<div dir="ltr">Hello,<div>We are using a large project that comes with it's own build and configuration system.</div><div>We have multiple issues with this external build system and we want to move the building of this project to cmake (as well as our code that depends on it).</div><div><br></div><div>All the problems are related to the `build` step and we want to replace it with a simple `add_library` with all sources.</div><div>The problem starts due to the fact that the project's configuration process is complicated and ever-changing, and we do not want to maintain a copy of it inside cmake.</div><div><br></div><div>Instead, we want to call `execute_process` to get cmake variables needed from the external configuration system and have a simple cmake build steps on top of it.</div><div><br></div><div>The thing is we want proper detection of when to rerun the configure step and we want something similar to `add-custom_target`'s DEPENDS variable, only at configure time.</div><div>Is this possible by any means? I know of `CMAKE_CONFIGURE_DEPENDS`, but the fact that it is global is problematic and here's why:</div><div>There are multiple cmake variables that come from this configuration system - from the language standard version to the list of target sources.</div><div>Change in what creates one of them should NOT trigger the configuration system for another variable as this could cause a full rebuild of the project which is undesirable due to long compilation times.</div><div><br></div><div>Basically, what I'm asking is<b> - Is there a way to describe "custom commands", with proper dependency management that run at configure time?</b></div><div><br></div><div>Example (pseudo cmake):</div><div><br></div><div>add_custom_configure_command(GetLinkerScript COMMAND some_external_program1.exe OUTPUT_VARIABLE LINKER_SCRIPT DEPENDS version_file.json)</div><div><div>add_custom_configure_command(GetSourcesList COMMAND some_external_program2.exe OUTPUT_VARIABLE SOURCES DEPENDS config_file.json)</div><div><br></div><div>add_library(MyLib)</div><div>target_sources(MyLib PUBLIC ${SOURCES})</div><div>#Add custom target for the linker script that if it changes the lib needs to be re-linked</div></div><div>add_custom_target(LinkerScript ...)</div><div><br></div><div>Is there a way to achieve this behavior (namely if I change the linker script, then generating the list of sources won't happen - and not a rebuild)?</div><div>Note this is just an example, in reality I have 10 different cmake variables with different purposes that are outputted from the external configuration system - but the dependencies are quite clear.</div></div>