Weird CMake error

I have used the vst3projectgenerator to create a new project that builds and runs just fine. I want to change the name of the cmake target though and have it different compared to the generated binary. So I changed the line

smtg_add_vst3plugin(myPlugin ....)
to
smtg_add_vst3plugin_with_pkgname(myPlugin_vst myPlugin ...)
to have separeted targets for aax and vst but the same binary name.

But when changed to this
smtg_add_vst3plugin_with_pkgname
and also updated all the references to myPlugin to myPlugin_vst in the CMakeLists.txt I get all of this error:

[main] Building folder: myPlugin
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build --config Debug --target myPlugin_vst -j 14 --
[build] MSBuild version 17.4.0+18d5aef85 for .NET Framework
[build]   pluginterfaces.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\pluginterfaces.lib
[build]   base.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\base.lib
[build]   vstgui.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\vstgui.lib
[build]   sdk_common.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\sdk_common.lib
[build]   sdk_hosting.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\sdk_hosting.lib
[build]   sdk.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\sdk.lib
[build]   vstgui_uidescription.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\vstgui_uidescription.lib
[build]   moduleinfotool.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\bin\Debug\moduleinfotool.exe
[build]   vstgui_support.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\lib\Debug\vstgui_support.lib
[build]   [SMTG] Copied resource/myPlugineditor.uidesc to C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build/VST3/Debug/myPlugin.vst3/Contents/Resources
[build]   [SMTG] Copied resource/font/ArtDystopia.ttf to C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build/VST3/Debug/myPlugin.vst3/Contents/Resources/fonts
[build]   myPlugin_vst.vcxproj -> C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\VST3\Debug\myPlugin.vst3\Contents\x86_64-win\myPlugin_vst.vst3
[build]   LoadLibray failed: Access is denied.
[build]   
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: The command "setlocal [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: cd C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\bin [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: C: [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\bin\Debug\moduleinfotool.exe -create -version 1.0.0.0 -path C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build/VST3/Debug/myPlugin.vst3 -output C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build/VST3/Debug/myPlugin.vst3/Contents/moduleinfo.json [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :cmEnd [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :cmErrorLevel [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: exit /b %1 [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :cmDone [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[build] C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(159,5): error MSB3073: :VCEnd" exited with code 1. [C:\Users\wjwvcx\Desktop\Deveplopment\plugins\myPlugin\build\myPlugin_vst.vcxproj]
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build C:/Users/wjwvcx/Desktop/Deveplopment/plugins/myPlugin/build --config Debug --target myPlugin_vst -j 14 -- exited with code: 1
[driver] Build completed: 00:00:06.185
[build] Build finished with exit code 1

Am I doing something wrong or is the smtg_add_vst3plugin_with_pkgname cmake-function broken?

Can also mention that I tried to use

smtg_add_vst3plugin(myPlugin
    PACKAGE_NAME myPlugin_vst
    SOURCES_LIST
    source/version.h
    ...

But that also gives the same error. If I remove the line PACKAGE_NAME myPlugin_vst
it builds fine

If you are not familiar with CMake, it can be a bit hard to use sometimes, as when you changes certain things, you have to completely wipe the build folder and regenerate it due to caching issues.

Note that if you used the project generator, it simply runs cmake for you after generating the project. Now you have to do it by hand… something like:

rm -fo build
mkdir build
cd build
cmake .. -G "whatever generator you used previously"

I’m quite familiar with CMake and have of course tried what you suggest :slight_smile:

Are you able to use the smtg_add_vst3plugin function with a specified PACKAGE_NAME without any permission issues?
I have tried on two different computers with the same problem. Both running Windows though, haven’t tried it on a Mac

After some debugging I have found the issue.

It seems the moduleinfotool is coded to have the vst file filename the same as the package name (at least for windows). Which is not true when you use PACKAGE_NAME in the smtg_add_vst3plugin function. The moduleinfotool are not able to find the plugin since it uses
build/VST3/Debug/myPlugin_vst.vst3/Contents\x86_64-win\myPlugin_vst.vst3
To load the plugin, but the actually path/plugin looks like this;
build/VST3/Debug/myPlugin_vst.vst3/Contents\x86_64-win\myPlugin.vst3

The name of the plugin file is the same name as the cmake target but moduleinfotool expect it to have the same name as PACKAGE_NAME

@Arne_Scheffler or @Yvan Is this a bug that I should file an issue on github for?

I don’t know where the error is coming from, but the name of the plug-in executable must be the same as the name of the package folder. So in your case the name must be
myPlugin_vst.vst3\Contents\x86_64-win\myPlugin_vst.vst3.

Yes I know, but if you are using the

 smtg_add_vst3plugin(myPlugin_vst PACKAGE_NAME myPlugin SOURCES_LIST ...)

To have the target name of the project different from the output “binary” the moduleinfotool fails during build. I used the project generator to generate my project and just change the CMake function to have another package name compared to target name.

I wanted to do this because I want to have both vst, aax and au target in the same CMakeLists.txt file but output the plugin with the same target name

To reiterate:
myPlugin_vst.vst3\Contents\x86_64-win\myPlugin.vst3
is not a valid vst3 plug-in as the name of the package is different to the name of the dll.
The correct name is either:
myPlugin_vst.vst3\Contents\x86_64-win\myPlugin_vst.vst3
or
myPlugin.vst3\Contents\x86_64-win\myPlugin.vst3

I understand you, but then I think it’s weird that the documentation and available functionality of the cmake function states this:

# @param target The target to which a VST3 Plug-in will be added. 
# @param PACKAGE_NAME <Name> The name of the package [optional] if not present
# @param MODULEINFO_COMPATIBILITY <path> The path to the compatibility json file [optional]
# @param SOURCES_LIST <sources> List of sources to add to target project [mandatory when PACKAGE_NAME is used]
# for example: 
# smtg_add_vst3plugin(${target} PACKAGE_NAME "A Gain" SOURCES_LIST ${again_sources})
# smtg_add_vst3plugin(${target} PACKAGE_NAME "A Gain" MODULEINFO_COMPATIBILITY compat.json SOURCES_LIST ${again_sources})
# or
# smtg_add_vst3plugin(${target} ${again_sources})

I also stated that I don’t know where the error comes from. Maybe it’s a bug in that cmake function. I will create a bug report, but due to the holiday time it can take a few weeks until someone looks at it.

I can add that I solved my problem by using a combination with

smtg_add_vst3plugin(myPlugin-vst3
    PACKAGE_NAME myPlugin
    SOURCES_LIST
    ...)

and
set_target_properties(myPlugin-vst3 PROPERTIES OUTPUT_NAME "myPlugin")

That made the moduleinfotool happy and both my plugin package folder and plugin executable/binary got the same name (myPlugin.vst3) instead of the target name of myPlugin-vst3.vst3

That made it also possible for me to add aaxwrapper as well in a convenient way

smtg_add_aaxplugin(myPlugin-aax
    PACKAGE_NAME myPlugin
    SOURCES_LIST
    ...)
set_target_properties(myPlugin-aax PROPERTIES OUTPUT_NAME "myPlugin")

That made it possible to have both the vst3 and aax target in the same CMakeLists.txt file with their respective target myPlugin-vst3 and myPlugin-aax but both targets outputing my plugin with the same name (myPlugin.vst3 and myPlugin.aaxplugin)