CMake questions

ok, that seems reasonable - thx

Yep, that’s right. Updating the Projucer to use the new bundle structure is on my backlog, but there are higher priority issues that I need to look at first!

2 Likes

thx @reuk - is this maybe what’s caused the issue with vst3 and mingw on Windows?

Regarding the CMAKE_BUILD_TYPE: which CMake generator are you using?
If you don’t specify the -G flag when you’re exporting, then the default will be msbuild on windows, which indeed does not use the CMAKE_BUILD_TYPE variable, since it is a multi config exporter.
With these you specify the build type at built time, not at configuration time, e.g. when you choose the desired build type in the drop-down in Visual Studio, or by using cmake --build . --config Debug for example.
The variable will only have an effect for single-config exporters, on windows this would probably be either nmake or ninja.

Regarding your VST3+MinGW issue, as @yfede already mentioned, I think that Windows ARM is simply not supported yet.

1 Like

thanks for the info - I’m using homebrew cmake - are you saying i could just install nmake or ninja? do they use the CMakeLists.txt file as their input?

It’s the other way round, when invoking the cmake command you generate a project for some kind of build system from the CMakeLists. You can instruct CMake which kind of build system you are using with the -G flag – this is called the generator in the CMake world. If you don’t do that, CMake will chose whatever generator it think is appropriate. When you execute the cmake command on unix systems without specifying a generator, it will generate a unix makefile by default, on Windows it will try to figure out if you have installed visual studio and create a visual studio project or will switch to nmake otherwise.

Now if you want CMake to output a ninja project, call cmake -G Ninja. Then you can install ninja via homebrew on your Mac and e.g. via choco on your Windows machine and use Ninja to build your project. If you want to create an Xcode project on Mac, run cmake -G Xcode on macOS, if you want to create a visual studio 2022 project, run cmake -G "Visual Studio 17 2022" and so on. Here is a full list of all generators cmake-generators(7) — CMake 3.28.0-rc5 Documentation

I’d recommend to specify the generator manually by default. I personally like Ninja as a build system as it is fast, easy to use since it is a single config system and integrates well with CLion, which is my cross-platform C++ IDE of choice – but there is no right or wrong here.

Just one last note, this might be obvious to you anyway, but keep in mind that you should always run the cmake configure command on your target system where you want the build to happen, don’t generate e.g. some ninja project or makefile on Mac and then copy it to your windows machine, this won’t work.

2 Likes

great - I’ll look into this. thanks!

@PluginPenguin - so have moved to Ninja - works fine on Mac but doesn’t appear to pickup the VS toolchain automatically on windows and so can’t find any compilers - is there an easy way to configure this? thx

You need to be in the “Visual Studio shell” before calling CMake.

I do it with:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
1 Like

@eyalamir - hi, I’ve run the script but doens’t make any difference when run in a git-bash shell. looks like might have to set all the variables manually.

Yes, I think it’s meant for the Windows CMD or powershell…

The script will only work in cmd, not in a normal powershell because of the way the variables are set :roll_eyes:
In case you want to use a powershell, you should probably use the Developer-Powershell that is installed alongside Visual Studio.
Alternatively, as PluginPenguin pointed out, CLion from Jetbrains supports Ninja out of the box!

hi, so i’m running in powershell and things are looking better, but I’m only getting a 32-bit exe/dlls produced, even when running the vcvars64.bat before configuring cmake. I’ve tried speciying x64 to Ninja, but it says that it’s not supported.

Are you using VS 2022? I just noticed it seems to be missing a developer powershell that is initialized for x64- the one that is shipped only works for compiling x86 :thinking:

However there is a x64-initialized command prompt- can you try using the x64 Native Tools Command Prompt for VS 2022, there you should be able to build x64 executables by default.

For reference, here is more information about these terminals.

yes, using vs2022. I’m running the powershell and then the commands to set up for 64-bit, but it’s still building 32-bit.
I can’t use the normal shells as they don’t work properly when then running bash shells which is what the build system uses.
I guess I can rewrite all by .sh scripts for Mac as .bat for windows, but was really hoping to avoid that.

As i mentioned before, the vcvars64.bat won’t work in powershell, so running vcvars64.bat && cmake .. won’t have any effect, the environment variables are not propagated correctly to the second command.
What you can do however is to start a cmd and then call vcvars64.bat && powershell, and continue from there.

I’ve set up a custom profile for the windows terminal. There you can specify the command line that should be used to start the terminal, where i put cmd /k "vcvars64.bat && pwsh.exe"- this works fine for me!

Or, you can simply ditch ninja and use msbuild, then you don’t need to fiddle around with these things :slight_smile:

2 Likes

Yeah, seems like you have to be in the CMD shell. Sorry for misleading you…

1 Like

I forgot to mention, I played around with environment variables last year, and if you set them correctly you can even skip calling vcvarsall.bat- depending on your situation, and how often you change your setup this might also work well- obviously you’d have to manually modify the variables if your SDK/MSVC version changes.

I set the following environment variables, for Visual Studio 2022:

INCLUDE

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<MSVC_VERSION>\include
C:\Program Files (x86)\Windows Kits\10\include\<SDK_VERSION>\ucrt
C:\Program Files (x86)\Windows Kits\10\include\<SDK_VERSION>\shared
C:\Program Files (x86)\Windows Kits\10\include\<SDK_VERSION>\um
C:\Program Files (x86)\Windows Kits\10\include\<SDK_VERSION>\winrt
C:\Program Files (x86)\Windows Kits\10\include\<SDK_VERSION>\cppwinrt

LIB

C:\Program Files (x86)\Windows Kits\10\Lib\<SDK_VERSION>\um\x64
C:\Program Files (x86)\Windows Kits\10\lib\<SDK_VERSION>\ucrt\x64
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<MSVC_VERSION>\lib\x64

PATH

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<MSVC_VERSION>\bin\Hostx64\x64
C:\Program Files (x86)\Windows Kits\10\bin\x64
1 Like

Thanks for everyone’s help and input on this - mission accomplished of unified build scripts across mac and windows!

1 Like