jucipp icon indicating copy to clipboard operation
jucipp copied to clipboard

How to select which executable to run

Open underdoeg opened this issue 8 years ago • 12 comments

I have the following CMakeLists.txt:

FILE(GLOB_RECURSE SOURCES "src/*")
add_executable(server ${SOURCES})

## SAMPLE APP
FILE(GLOB_RECURSE SOURCES_SAMPLE "sample/*")
add_executable(sample ${SOURCES_SAMPLE})

Compile and Run opens the server executable. Is there a way to select which one is executed?

underdoeg avatar Jun 20 '17 12:06 underdoeg

It should depend on which buffer is active, but if a file is used in two executables, the first executable is selected. You can however use Set Run Arguments in the Build/Debug menu.

eidheim avatar Jun 20 '17 12:06 eidheim

Thanks. Set run argument worked for me. The active buffer did always open the first project. Even when only having the main.cpp of the second executable open.

underdoeg avatar Jun 20 '17 13:06 underdoeg

Thank you, I think I got this fixed in https://github.com/eidheim/jucipp/commit/99cb3f6843d9705325f3abc003f1979d8a682cff. Pushing this commit to master in a few days, but feel free to try it out.

eidheim avatar Jun 20 '17 17:06 eidheim

Yes that almost works for me. It does detect the right executable now but tries to run it in a subfolder. So samples tries to open an executable at build/sample/sample instead of build/sample and server is trying to execute build/src/server. selection_238

underdoeg avatar Jun 21 '17 08:06 underdoeg

Thank you, I'll have a look at this and figure out where I messed up. build/src/server is correct I take it or?

eidheim avatar Jun 21 '17 09:06 eidheim

Oh never mind, both sample and server executables lies within the build folder. I'll fix this in a day or so.

edit: typo

eidheim avatar Jun 21 '17 09:06 eidheim

I think the issue is fixed in https://github.com/eidheim/jucipp/commit/786b6b8eddcf7cbc174cfa43d5f361fa29735f9e.

eidheim avatar Jun 21 '17 14:06 eidheim

yes that works! thanks. Only "issue" now is that I have another directory with code that is compiled to a static lib which is shared between sample and server. When I have one of those files open, then nothing is executed. (Propably because it is a static lib?) Would be nice if the IDE remembered my last exec and then run this instead?

underdoeg avatar Jun 21 '17 14:06 underdoeg

Commits fixing the original issue above is pushed to master, but leaving this issue open a bit further for discussion on how to chose executable when for instance working on an library.

eidheim avatar Jun 22 '17 10:06 eidheim

I feel like having some sort of drop down selector that lists all available executables would be the most intuitive? first option could be auto which behaves the way it does now.

underdoeg avatar Jan 24 '18 15:01 underdoeg

For the time being you can use Set Run Arguments in the Project menu to set project wide executable that will be run no matter which file you have open.

Regarding providing alternatives, I would have to add this to my TODO list. If it was only for Meson project, it would be easy, but the issue is within CMake projects since it is harder to identify executables here. The reason behind the CMake difficulties is that one would have to parse all CMakeLists.txt files in the project, not only the ones in the source folder and its parents. On the other hand, with Meson, one could merely look into the build/compile_commands.json file.

eidheim avatar Jan 25 '18 09:01 eidheim

The Run Arguments settings are now also stored between sessions: https://github.com/cppit/jucipp/commit/8a4cab04152ab2b45348715bcb3021aba0cedf02

eidheim avatar Feb 05 '18 06:02 eidheim