command not found: cmake

benjamin thigpen's icon

Hi,

I'm trying to learn how to make a plugin from a gen~ patcher using the Gen~ Plugin Export package. I'm simply using the GenPluginExport.maxpat and following the instructions. But I'm blocked at the CMake stage. I'm hoping someone can help me.

I'm running a 2019 MacBook Pro with MacOS 11.6 Big Sur and Max 8.2.1.

I have installed CMake (3.22.0) and Xcode (13.1). I can open both programs with no problem.

I export the code in the Max patch and this seems to work.

In the Terminal, I can change to the gen~ Plugin Export/misc/build directory.

But when I enter "cmake .." I always receive this not very encouraging reply:
    zsh: command not found: cmake

I have tried various things (rebooting, moving CMake to different directories, etc.) but to no avail.

I have only limited experience with the Terminal, so perhaps I'm missing something obvious...

Any suggestions?

Ben

Isabel Kaspriskie's icon

Hi Ben!

It sounds like CMake isn't on your system's path. That means you'll have to give the full filepath to CMake when running "cmake .."

So for example, you can run the following from the build directory:
/the/full/path/to/cmake ..

where you substitute in the entire path to CMake.

Hope this helps!

benjamin thigpen's icon

Hi Isabel,

Thanks for your quick and clear reply. I presumed it was something simple and obvious like this.

Unfortunately, however, I must still be doing something wrong. When I type in what I think is the complete path, I get the same result: "no such file or directory." I have tried moving CMake to different directories, pointing the Terminal to the same directory that CMake is in, etc., but nothing works.

What am I missing? Sorry for my ignorance - and thanks for your help!

Ben

Isabel Kaspriskie's icon

Ah, no worries!
In your case, try:

/bthigpen/Alpha1000/Applications/CMake.app/Contents/bin/cmake ..
Rob Ramirez's icon

if you're using the Cmake gui app, you can add it to your path by opening Tools -> How to install for command line use and following the instructions

benjamin thigpen's icon

Hi Isabel, Hi Rob,

Thanks for your replies.

I followed both suggestions. Isabel's, strangely, did not work. But Rob's did! :)

However, I am now blocked at the next step. "cmake --build --config Release ." returns "Unknown argument Release". None of the variations I tried worked either. What am I doing wrong here?

Thanks again for your help and suggestions!
Ben

PS. Looking in my build folder, where the final build will (eventually) be found, I see that it is empty: no folders "C74GenPlugin_artefacts/Release". Is this normal?

This method did not work.

This method worked! But do I now need to specify a source directory?

"Unknown argument Release" :(

Isabel Kaspriskie's icon

Thanks for your patience, Ben!

You can try this instead:
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .

(You might need to delete and recreate your build folder if you get errors from the above.)

Alternatively, you can just build a debug version with
cmake --build .

benjamin thigpen's icon

Hi Isabel,

It worked!!! :))

There were warnings about 2 deprecated commands (getNumInputChannels and getNumOutputChannels), but the build worked, the plugin opens in Reaper and functions correctly.

Thanks!!!!!
Ben

Isabel Kaspriskie's icon

Great news!

Thanks for taking it for a spin, too (it'll help as I'm cleaning up the documentation and some helper patch tools ;D).

Glad it's working for you now.

benjamin thigpen's icon

Hi Isabel,

In that case, it might be useful for you to know that for me (on Macintosh, with the configuration listed above) the change directory command for Macintosh in the GenPluginExport.maxpat did not work. But the command on GitHub, which is the same as the one for Windows in the patch, did.

My students will soon be trying this on Windows machines, so I or they may be back with more questions ;)

Cheers,
Ben

benjamin thigpen's icon

Hi Isabel,

I'm back ;)

Going thru this with a student right now, on a PC running Windows 10.

We have successfully installed the Gen Plugin Export package, CMake and Visual Studio.

In the terminal, we can change directory using the command listed for Macintosh, but not the one for Windows. (This is the one that works:
cd "~/Documents/Max 8/Packages/gen~ Plugin Export/misc/build"
I think they may be reversed in the GenPluginExport.maxpat, since for me, on Macintosh, it was the other one that worked.)

Then, unfortunately, typing "cmake .. " or "cmake -DCMAKE_BUILD_TYPE=Release .." returns

CMake Error at CMakeLists.txt:20 (project):
Running

'nmake' '-?'

failed with:

Le fichier spécifié est introuvable

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/Sim/Documents/Max 8/Packages/gen~ Plugin Export/misc/build/CMakeFiles/CMakeOutput.log".

The key line here "Le fichier spécifié est introuvable" translates : "The specified file is unfindable." However, CMake itself seems to be findable, since typing cmake (with no dots) gives

Usage

cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

Any suggestions for the Windows world?

Cheers,
Ben

Isabel Kaspriskie's icon

Hi Ben!

It looks like the default build system that CMake is configuring is nmake which might be causing some problems. We can try specifying that we want to use Visual Studio instead of nmake.

If you have Visual Studio 2019 installed, you can try this command:
cmake -G "Visual Studio 2019 16" -DCMAKE_BUILD_TYPE=Release ..

In theory, the following should work for Visual Studio 2022, but I have not tested VS 2022 yet and am not sure what might break with the new version. :)
cmake -G "Visual Studio 2022 17" -DCMAKE_BUILD_TYPE=Release ..

benjamin thigpen's icon

Hi Isabel!

Thanks for your super-fast reply!

We have installed Visual Studio 2022, so we tried that command. Here is the result:

PS C:\Users\Sim\Documents\Max 8\Packages\gen~ Plugin Export\misc\build> cmake -G "Visual Studio 2022 17" -DCMAKE_BUILD_TYPE=Release ..
>>
CMake Error: Could not create named generator Visual Studio 2022 17

Generators
Visual Studio 17 2022 = Generates Visual Studio 2022 project files.
Use -A option to specify architecture.
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Deprecated. Generates Visual Studio 2010
project files. Optional [arch] can be
"Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Borland Makefiles = Generates Borland makefiles.
* NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates
build.ninja files.
Ninja Multi-Config = Generates build-<Config>.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles JOM
= Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Kate - MinGW Makefiles = Generates Kate project files.
Kate - NMake Makefiles = Generates Kate project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.

Just in case, we tried "Visual Studio 17 2022" but that didn't work either...

Any ideas?
Thanks!
Ben

Isabel Kaspriskie's icon

Ah yes, you're right it should have been "Visual Studio 17 2022".

Can you try without the release type specification?
cmake -G "Visual Studio 17 2022" ..

benjamin thigpen's icon

We get

"could not find any instance of Visual Studio"

Isabel Kaspriskie's icon

I did some Googling around, and a few things you might try:

- in the Visual Studio installer, make sure the Visual C++ tools for CMake is checked and installed
- reboot the machine

benjamin thigpen's icon

Ok, thanks. We're looking for this now.
(There were dozens of options in the installer and we went for the minimal set.)

benjamin thigpen's icon

Hmm, we installed C++ Tools for CMake end rebooted.
But - "No CMAKE_C_COMPILER could be found."

PS C:\Users\Sim\Documents\Max 8\Packages\gen~ Plugin Export\misc\build> cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release ..
>>
-- Selecting Windows SDK version to target Windows 10.0.19043.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:20 (project):
No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:20 (project):
No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "C:/Users/Sim/Documents/Max 8/Packages/gen~ Plugin Export/misc/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Sim/Documents/Max 8/Packages/gen~ Plugin Export/misc/build/CMakeFiles/CMakeError.log".

Isabel Kaspriskie's icon

Hmmmm that's interesting. I wonder why it's not finding the MS compiler... Just to check, are you able to open Visual Studio?

One shot in the dark is to reinstall CMake so that it's been installed after Visual Studio. Another thing to try is to try the command from the "Visual Studio Developer Command Prompt". Both of these ideas would be to see if it helps CMake find the compiler.

If that fails, can you attach the CMakeError.log as an attachment here as well as the output from PowerShell when running
$env:path -split ";"

benjamin thigpen's icon

Thanks Isabel!

Yes, we can open Visual Studio. Although we didn't try again after installing the Visual C++ Tools.

I'll pass your suggestions on to my student (or he'll read them here). Hopefully, he'll be able to try them and come back with some results. Otherwise... we'll keep working on this in February! We take long vacations here in Belgium ;)

I'm glad this was easier on Macintosh :) I'll see if I can build a few useful plugins now!

Thanks again for your help!

All the best,
Ben