Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Accessing executable build location outside of ecbuild #44

Open
StegmannJCSDA opened this issue Sep 16, 2022 · 2 comments
Open

Comments

@StegmannJCSDA
Copy link
Contributor

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?

@wdeconinck
Copy link
Member

wdeconinck commented Sep 19, 2022

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

@StegmannJCSDA
Copy link
Contributor Author

StegmannJCSDA commented Sep 19, 2022

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>")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants