I have a plugin that has white space in its name. This causes issue on Windows:
The function smtg_target_add_plugin_resource
in SMTG_AddSMTGLibrary.cmake
is not properly using quotes and as a result the wrong code gets generated:
add_custom_command(
OUTPUT ${absolute_output_file_path}
MAIN_DEPENDENCY ${absolute_input_file_path}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
${absolute_input_file_path}
${absolute_output_file_path}
COMMAND ${CMAKE_COMMAND}
-E echo
"[SMTG] Copied ${absolute_input_file_path} to ${absolute_output_file_path}"
)
results in the following Windows build code
<CustomBuild Include="D:\src\local\pongasoft\vst-sam-spl-64\resource\SampleSplitter.uidesc">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generating VST3/Debug/$(TargetFileName)/Contents/Resources/SampleSplitter.uidesc</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">setlocal
"C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different D:/src/local/pongasoft/vst-sam-spl-64/resource/SampleSplitter.uidesc D:/Work/vst-sam-spl-64/build/VST3/Debug/$(TargetFileName)/Contents/Resources/SampleSplitter.uidesc
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E echo "[SMTG] Copied D:/src/local/pongasoft/vst-sam-spl-64/resource/SampleSplitter.uidesc to D:/Work/vst-sam-spl-64/build/VST3/Debug/$(TargetFileName)/Contents/Resources/SampleSplitter.uidesc"
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
The issue is that if $(TargetFileName)
contains any space, then the command is invalid. Putting quotes around the paths should fix the issue like this:
add_custom_command(
OUTPUT "${absolute_output_file_path}"
MAIN_DEPENDENCY ${absolute_input_file_path}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
"${absolute_input_file_path}"
"${absolute_output_file_path}"
COMMAND ${CMAKE_COMMAND}
-E echo
"[SMTG] Copied ${absolute_input_file_path} to ${absolute_output_file_path}"
)```