Hey folks,
After a bit of searching, I see that this question has been asked in a few different ways before, but none which seem to include discussion of the new JUCE6 CMake features, so please excuse my potential duplicate
I’m working on a little tool that I’ll generally be using from the command line. I started out my app structure using CMake with the juce helper juce_add_console_app(${TargetName} PRODUCT_NAME "MyHelperTool")
. That all worked great and I’ve been able to get quite far with that, but now I want to introduce an optional window to display some values that can be opened by passing some flag to the CLI when invoking the program.
So I followed along this tutorial: https://docs.juce.com/master/tutorial_main_window.html and I’m able to create and open a DocumentWindow without problem. The strange thing is that when I do this from my CLI app, the window refuses to take the foreground. I’m on MacOS, and I can see the window pops open but if I try to focus on the window it immediately snaps to behind any other application window I have open. When I press cmd+Tab, I don’t see the application window open as something I can cmd+Tab to.
Eventually I took a wild guess and changed my CMake config to the following: juce_add_gui_app(${TargetName} PRODUCT_NAME "MyHelperTool")
, and now my window behavior all works as expected. The unfortunate part is that now my project has the full MacOS application structure with the resources folder and everything, and when I invoke just the CLI behavior I still get the full application window treatment. Really the only build product I want out of this is a single little CLI binary that generally operates as a command line tool but can pop up a window and behave as expected by the OS if given the right flag.
Is there a way to do that? Maybe there’s some hybrid CMake flags I can set? Thanks.