steinbergmedia / vst3sdk

VST 3 Plug-In SDK
Other
1.57k stars 162 forks source link

CMake fails with bad $-escape #100

Closed suzumushi0 closed 1 year ago

suzumushi0 commented 1 year ago

Under VST SDK 3.7.7, CMake failed with the following error message.

1> [CMake]    'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug' '-t' 'recompact'
1> [CMake] 
1> [CMake]   failed with:
1> [CMake] 
1> [CMake]    ninja: error: build.ninja:3524: bad $-escape (literal $ must be written as $$)
1> [CMake] 

3524 line of build.ninja is:

COMMAND = cmd.exe /C "cd /D D:\VST\VST_SDK\my_plugins\build\helloworld_with_VSTGUI && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E copy_if_different D:/VST/VST_SDK/my_plugins/helloworld_with_VSTGUI/resource/plug.uidesc D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug/VST3/Debug/$(TargetFileName)/Contents/Resources/plug.uidesc && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E echo "[SMTG] Copied D:/VST/VST_SDK/my_plugins/helloworld_with_VSTGUI/resource/plug.uidesc to D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug/VST3/Debug/$(TargetFileName)/Contents/Resources/plug.uidesc""

The full CMake log is attached.

1> 構成 'x64-Debug' の CMake 生成を開始しました。
1> コマンド ライン: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="D:\VST\VST_SDK\vst3sdk\out\install\x64-Debug" -DSMTG_CREATE_PLUGIN_LINK:BOOL="False" -DSMTG_CXX_STANDARD:STRING="20" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\VST\VST_SDK\vst3sdk" 2>&1"
1> 作業ディレクトリ: D:\VST\VST_SDK\vst3sdk\out\build\x64-Debug
1> [CMake] -- [SMTG] macOS Deployment Target: 10.13
1> [CMake] -- [SMTG] CMAKE_SOURCE_DIR is set to: D:/VST/VST_SDK/vst3sdk
1> [CMake] -- [SMTG] CMAKE_CURRENT_LIST_DIR is set to: D:/VST/VST_SDK/vst3sdk
1> [CMake] -- [SMTG] SMTG_VSTGUI_SOURCE_DIR is set to: D:/VST/VST_SDK/vst3sdk/vstgui4
1> [CMake] -- Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR) 
1> [CMake] -- VSTGUI will use the embedded Expat package!
1> [CMake] -- [SMTG] SMTG_AAX_SDK_PATH is not set. If you need it, please download the AAX SDK!
1> [CMake] -- [SMTG] SMTG_JACK_SDK_PATH is not set. If you need it, please download the JACK SDK!
1> [CMake] -- Could NOT find LIBJACK (missing: LIBJACK_LIBRARY LIBJACK_INCLUDE_DIR) 
1> [CMake] -- [SMTG] LIBJACK_FOUND is not set. If you need it, please install Jack Audio from http://www.jackaudio.org!
1> [CMake] -- [SMTG] SMTG_MYPLUGINS_SRC_PATH is set to: D:/VST/VST_SDK/vst3sdk/../my_plugins
1> [CMake] -- [SMTG] Setup running moduleinfotool for helloworld
1> [CMake] -- [SMTG] Setup running validator for helloworld
1> [CMake] -- [SMTG] Setup running moduleinfotool for helloworldWithVSTGUI
1> [CMake] -- [SMTG] Setup running validator for helloworldWithVSTGUI
1> [CMake] -- [SMTG] Setup running moduleinfotool for adelay
1> [CMake] -- [SMTG] Setup running validator for adelay
1> [CMake] -- [SMTG] Setup running moduleinfotool for again
1> [CMake] -- [SMTG] Setup running validator for again
1> [CMake] -- [SMTG] Setup running moduleinfotool for againsimple
1> [CMake] -- [SMTG] Setup running validator for againsimple
1> [CMake] -- [SMTG] Setup running moduleinfotool for again-sampleaccurate
1> [CMake] -- [SMTG] Setup running validator for again-sampleaccurate
1> [CMake] -- [SMTG] Setup running moduleinfotool for channelcontext
1> [CMake] -- [SMTG] Setup running validator for channelcontext
1> [CMake] -- [SMTG] Setup running moduleinfotool for hostchecker
1> [CMake] -- [SMTG] Setup running validator for hostchecker
1> [CMake] -- [SMTG] Setup running moduleinfotool for legacymidiccout
1> [CMake] -- [SMTG] Setup running validator for legacymidiccout
1> [CMake] -- [SMTG] Setup running moduleinfotool for mda-vst3
1> [CMake] -- [SMTG] Setup running validator for mda-vst3
1> [CMake] -- [SMTG] Setup running moduleinfotool for multiple-program-changes
1> [CMake] -- [SMTG] Setup running validator for multiple-program-changes
1> [CMake] -- [SMTG] Setup running moduleinfotool for noteexpressionsynth
1> [CMake] -- [SMTG] Setup running validator for noteexpressionsynth
1> [CMake] -- [SMTG] Setup running moduleinfotool for noteexpressiontext
1> [CMake] -- [SMTG] Setup running validator for noteexpressiontext
1> [CMake] -- [SMTG] Setup running moduleinfotool for panner
1> [CMake] -- [SMTG] Setup running validator for panner
1> [CMake] -- [SMTG] Setup running moduleinfotool for pitchnames
1> [CMake] -- [SMTG] Setup running validator for pitchnames
1> [CMake] -- [SMTG] Setup running moduleinfotool for prefetchable
1> [CMake] -- [SMTG] Setup running validator for prefetchable
1> [CMake] -- [SMTG] Setup running moduleinfotool for programchange
1> [CMake] -- [SMTG] Setup running validator for programchange
1> [CMake] -- [SMTG] Setup running moduleinfotool for syncdelay
1> [CMake] -- [SMTG] Setup running validator for syncdelay
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] CMake Error:
1> [CMake]   Running
1> [CMake] 
1> [CMake]    'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug' '-t' 'recompact'
1> [CMake] 
1> [CMake]   failed with:
1> [CMake] 
1> [CMake]    ninja: error: build.ninja:3524: bad $-escape (literal $ must be written as $$)
1> [CMake] 
1> [CMake]   
1> [CMake] 
1> [CMake] 
1> [CMake] 
1> [CMake] CMake Generate step failed.  Build files cannot be regenerated correctly.
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="D:\VST\VST_SDK\vst3sdk\out\install\x64-Debug" -DSMTG_CREATE_PLUGIN_LINK:BOOL="False" -DSMTG_CXX_STANDARD:STRING="20" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\VST\VST_SDK\vst3sdk" 2>&1"' の実行が失敗しました。エラー: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="D:\VST\VST_SDK\vst3sdk\out\install\x64-Debug" -DSMTG_CREATE_PLUGIN_LINK:BOOL="False" -DSMTG_CXX_STANDARD:STRING="20" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\VST\VST_SDK\vst3sdk" 2>&1"' によって終了コードが返されました: 1'。
jjYBdx4IL commented 1 year ago

Same issue here. Probably related to: cmake/modules/SMTG_AddSMTGLibrary.cmake

-        if(MSVC)
-            # Hacky workaround: replace all SMTG_PLUGIN_PACKAGE_NAME (e.g. again.vst3)
-            # occurences by a MSVS macro $(TargetFileName). Using the cmake only approach does not work.
-            get_target_property(PLUGIN_PACKAGE_NAME ${target} SMTG_PLUGIN_PACKAGE_NAME)
-            string(REPLACE "${PLUGIN_PACKAGE_NAME}" "$(TargetFileName)" absolute_output_file_path ${absolute_output_file_path})
-        endif()

Here, it is assumed that MSVC compiler implies MS build tools, which is not a given.

jjYBdx4IL commented 1 year ago

Removing the string REPLACE command works for me.

Probably better to use CMAKE_MAKE_PROGRAM instead of MSVC here:

https://cmake.org/cmake/help/latest/variable/CMAKE_MAKE_PROGRAM.html

suzumushi0 commented 1 year ago

Comment out ll.459 of cmake/modules/SMTG_AddSMTGLibrary.cmake Then 3524 line of build.ninja is:

COMMAND = cmd.exe /C "cd /D D:\VST\VST_SDK\my_plugins\build\helloworld_with_VSTGUI && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E copy_if_different D:/VST/VST_SDK/my_plugins/helloworld_with_VSTGUI/resource/plug.uidesc D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug/VST3/Debug/helloworldWithVSTGUI.vst3/Contents/Resources/plug.uidesc && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E echo "[SMTG] Copied D:/VST/VST_SDK/my_plugins/helloworld_with_VSTGUI/resource/plug.uidesc to D:/VST/VST_SDK/vst3sdk/out/build/x64-Debug/VST3/Debug/helloworldWithVSTGUI.vst3/Contents/Resources/plug.uidesc""

It works. Thank you so much. This part is new for SDK 3.7.7 and I don't understand the background of this update, so I'm not sure this is the final solution :-)