voddan
voddan

Reputation: 33769

Use path to an executable as an argument for a runner in CLion

I have a CMake project in CLion. I am able to build my executable hello.

Now I want to run it inside CLion with a custom runner mpirun (it is an MPI project).

Bash command should look like: mpirun -n 5 path_to_hello_executabe/hello

How can I obtain this path_to_hello_executabe inside CLion configuration?

In CMake it looks like add_custom_target(run $ENV{MPIRUN} -n 5 $<TARGET_FILE:hello>), so what I need is an equivalent for $<TARGET_FILE:hello>.

Upvotes: 0

Views: 376

Answers (2)

nastasiak2512
nastasiak2512

Reputation: 1937

  1. Configure build output path in Build, Execution, Deployment | CMake settings. So you know the path_to_hello_executabe now.
  2. Add custom command in your CMake that will be executed during build. Then build the corresponding configuration in CLion. Your command will be called then.

Upvotes: 1

nastasiak2512
nastasiak2512

Reputation: 1937

That's not possible for now in CLion, since CLion's configurations can't run a command from add_custom_target cmake command. However this looks like an interesting use case and a nice feature to have: https://youtrack.jetbrains.com/issue/CPP-5831

Upvotes: 0

Related Questions