[Question] Accessing executable build location outside of `ecbuild`
I am working on updating a legacy project that will use ecbuild to build multiple executables in the following way:
ecbuild_add_executable( TARGET app
SOURCES ${app_src_files}
LIBS crtm )
In the past this was done with local makefiles that built the executables in their source directory. I would like to be able to create a (likely Python) script that links all the generated executables into a case directory, together with some case-specific input data.
To this end, the Python script would need to know the path of the executables built with ecbuild.
Is there an elegant way to do this?
This is really independent of ecbuild, but rather a general CMake question.
The older CMake way was to get the LOCATION property from a target via
get_target_property(<var> <target> LOCATION)
but that has been deprecated for non-imported targets, see Policy 0026. The recommendation is to use the $<TARGET_FILE:executable> generator expression in combination with file(generate).
This is really independent of ecbuild, but rather a general CMake question.
Yes, indeed.
Thank you, I will have a closer look at the documentation. Something like this will probably work:
file(GENERATE OUTPUT location_file CONTENT "$<TARGET_FILE:executable>")