Configuration time "custom command"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Configuration time "custom command"

Israel Israeli
Hello,
We are using a large project that comes with it's own build and configuration system.
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).

All the problems are related to the `build` step and we want to replace it with a simple `add_library` with all sources.
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.

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.

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.
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:
There are multiple cmake variables that come from this configuration system - from the language standard version to the list of target sources.
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.

Basically, what I'm asking is - Is there a way to describe "custom commands", with proper dependency management that run at configure time?

Example (pseudo cmake):

add_custom_configure_command(GetLinkerScript COMMAND some_external_program1.exe OUTPUT_VARIABLE LINKER_SCRIPT DEPENDS version_file.json)
add_custom_configure_command(GetSourcesList COMMAND some_external_program2.exe OUTPUT_VARIABLE SOURCES DEPENDS config_file.json)

add_library(MyLib)
target_sources(MyLib PUBLIC ${SOURCES})
#Add custom target for the linker script that if it changes the lib needs to be re-linked
add_custom_target(LinkerScript ...)

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)?
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.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake