CLion Environment with CMake on Windows

I’m pretty new to building on windows and have just spent my first day banging my head around trying to get CMake/CLion working…so bear with me. Thanks.

I’m trying to use the CMake support to build the example GuiAppExample from the documentation for setting up CMake to create JUCE projects. I copied the example directory out of the JUCE examples folder into a new location, and then copied JUCE folder into the project folder. I’m using the command add_subdirectory(JUCE) to load the library.

My first question is: Is copy/pasting the entire JUCE folder a sensible way to continue to do this? This seems to be the suggestion on the easiest way to get a CMake build setup running, but it seems counterintuitive to me to copy the whole JUCE folder every time.

Then, once I (seemingly) successfully created the project, I tried to run a debug build and got an error:

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

Anyone with any ideas on what is happening here? Good instructions for getting this environment working? All help greatly appreciated.

This is a fine way to start out. Once you’re familiar with version control systems such as ‘git’, it might make more sense to include JUCE as a subproject of some sort (e.g. a git submodule) so that you can more easily keep JUCE up to date, and keep track of which JUCE version your project is using.

It’s not really clear what’s gone wrong there. Is there any more output?

How did you install Visual Studio? Do you definitely have all of the C++ desktop development components installed?

Ah ok I am familiar with git but haven’t used submodules. Will look into that. That’s a good question I’m not certain exactly how I installed Visual Studio to begin with. I have however used it (clunkily) to work on and build JUCE projects in the past. From looking at which of the C++ desktop components I have installed, it looks like maybe I have some, but not all of them. (pictured). Any chance one of these is the missing piece?

The full output from that error has a few more similar lines:

====================[ Build | GuiAppExample | Debug ]===========================
"C:\Program Files\JetBrains\CLion 2021.2.2\bin\cmake\win\bin\cmake.exe" --build "C:\Users\Marc Langer\Documents\AIX\GuiApp\cmake-build-debug" --target GuiAppExample
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/personal/Documents/company/GuiApp/cmake-build-debug
[  9%] Generating GuiAppExample_artefacts/JuceLibraryCode/resources.rc
NMAKE : fatal error U1045: spawn failed : Invalid argument
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

oops forgot the actual picture

Perhaps CMake is failing to locate the resource compiler.

This setting can be overridden so you could try passing -D CMAKE_RC_COMPILER=/path/to/rc.exe in your CMake configuration options. For me, rc.exe is located at C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe.

This would be something that is done via the CMake command line interface, yes?

You can set it in CLion by going to Settings → Build, Execution, Deployment → CMake. In this pane, there’s a text box to enter “CMake options”, where you can supply the option I mentioned earlier.