Robert Goulet
2016-08-26 16:43:38 UTC
Hello,
I am trying to use a custom command to generate test certificate for a Universal Windows Platform app, and I can't find how to properly quote the executable paths from CMake. Here is how we add the custom command:
set(WIN64UWP_CERT_NAME "${PROJECT_NAME}_TemporaryKey")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${WIN64UWP_CERT_NAME}.pfx"
COMMAND "$(WindowsSdkDir)/bin/x64/makecert.exe" -cy end -eku 1.3.6.1.5.5.7.3.3 -r -n "CN=${PRODUCT_COMPANY}" -sv ${RESOURCES_DIR}/${WIN64UWP_CERT_NAME}.pvk ${WIN64UWP_CERT_NAME}.cer
COMMAND "$(WindowsSdkDir)/bin/x64/PVK2PFX.exe" -pvk ${RESOURCES_DIR}/${WIN64UWP_CERT_NAME}.pvk -spc ${WIN64UWP_CERT_NAME}.cer -pfx ${WIN64UWP_CERT_NAME}.pfx -f
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating Test Certificate..."
)
Because $(WindowsSdkDir) points within C:\Program Files\... Visual Studio is unable to execute these commands since the .vcxproj does not contain quotes around the executable paths.
First I tried using \" around the command, but CMake refuses to escape quotes on the command with error "COMMAND may not contain literal quotes".
Then I tried XML escaped character " but then CMake translate the ; as it if was a different element of an array surrounding both sides with quotes.
Then I tried %22 but CMake outputs % as %% in the vcxproj file.
So how do we setup a custom command that uses a Visual Studio variable that requires to be quoted to preserve spaces?
Thanks!
I am trying to use a custom command to generate test certificate for a Universal Windows Platform app, and I can't find how to properly quote the executable paths from CMake. Here is how we add the custom command:
set(WIN64UWP_CERT_NAME "${PROJECT_NAME}_TemporaryKey")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${WIN64UWP_CERT_NAME}.pfx"
COMMAND "$(WindowsSdkDir)/bin/x64/makecert.exe" -cy end -eku 1.3.6.1.5.5.7.3.3 -r -n "CN=${PRODUCT_COMPANY}" -sv ${RESOURCES_DIR}/${WIN64UWP_CERT_NAME}.pvk ${WIN64UWP_CERT_NAME}.cer
COMMAND "$(WindowsSdkDir)/bin/x64/PVK2PFX.exe" -pvk ${RESOURCES_DIR}/${WIN64UWP_CERT_NAME}.pvk -spc ${WIN64UWP_CERT_NAME}.cer -pfx ${WIN64UWP_CERT_NAME}.pfx -f
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating Test Certificate..."
)
Because $(WindowsSdkDir) points within C:\Program Files\... Visual Studio is unable to execute these commands since the .vcxproj does not contain quotes around the executable paths.
First I tried using \" around the command, but CMake refuses to escape quotes on the command with error "COMMAND may not contain literal quotes".
Then I tried XML escaped character " but then CMake translate the ; as it if was a different element of an array surrounding both sides with quotes.
Then I tried %22 but CMake outputs % as %% in the vcxproj file.
So how do we setup a custom command that uses a Visual Studio variable that requires to be quoted to preserve spaces?
Thanks!