<div dir="ltr"><div>After some tries I found maybe a solution for you. In my small example, I had these lines, which are working:</div><div><br></div><div><div><br></div><div>> set(HELLO1 "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat")</div><div>> execute_process(COMMAND ${HELLO1} && msbuild /help WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")</div></div><div><br></div><div>So for you, it would look like this (I am not very sure about it):</div><div><br></div><div>==========</div><div><span style="font-family:Calibri,sans-serif;font-size:11pt"> </span><br></div><div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><u></u></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">execute_process( COMMAND <u></u><span style="font-size:14.6667px">$ENV{VS${VS_IDE_VERSION}</span><span style="font-size:14.6667px">0COMNTOOLS}../../VC/vcvarsall.</span><span style="font-size:14.6667px">bat </span><span style="font-size:14.6667px">x86_amd64 &&  </span><span style="font-size:14.6667px">${CUDA_NVCC_EXECUTABLE} </span><span style="font-size:14.6667px">${OpenCV_SOURCE_DIR}/cmake/</span><span style="font-size:14.6667px">checks/OpenCVDetectCudaArch.</span><span style="font-size:14.6667px">cu --run</span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">                 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"<u></u><u></u></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">                 RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out<u></u><u></u></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">                 OUTPUT_STRIP_TRAILING_WHITESPACE)</p></div><div><br></div><div>==========</div><div><br></div><div>Anyhow, when I tried several types of your presentation, I got always some errors. I do not know, if this is a bug or not, but I will write them down here. Maybe some of the others could write something about it.</div><div><br></div><div><br></div><div>*** First try ***<br><div><br></div><div><div>> set(HELLO1 "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat")</div><div>> execute_process(COMMAND cmd /c "call ${HELLO1}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out)</div><div>> message("${_nvcc_out}")</div></div><div><br></div><div>When I call these lines on a windows machine, I am getting the error </div><div><br></div><div><div>> 'C:/Program' is not recognized as an internal or external command, operable program or batch file.</div></div><div><br></div><div>*** Second try ***</div><div><br></div><div>When I change the execute_process to this</div><div><br></div><div><div>> execute_process(COMMAND cmd /c "call \"${HELLO1}\"" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out)</div></div><div><br></div><div>then I am getting this error</div><div><br></div><div><div>> '\"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat\"' is not recognized as an internal or external command, operable program or batch file.</div></div><div><br></div><div>So now, CMake / Batch recognizes the right path, but somehow there are the characters \".</div><div><br></div><div>*** Third try ***</div><div><br></div><div>I changed the definition of the variable HELLO1 into (because of some hints here <a href="https://superuser.com/questions/279008/how-do-i-escape-spaces-in-command-line-in-windows-without-using-quotation-marks">https://superuser.com/questions/279008/how-do-i-escape-spaces-in-command-line-in-windows-without-using-quotation-marks</a>)</div><div><br></div><div>> set(HELLO1 "C:/Program^ Files^ (x86)/Microsoft^ Visual^ Studio^ 14.0/VC/vcvarsall.bat")<br></div><div><br></div></div><div>But here, I am also getting the error</div><div><br></div><div><div>> 'C:/Program' is not recognized as an internal or external command, operable program or batch file.</div></div><div><br></div><div>Even, when I double the carets ^^, then the same error occurs</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-09 22:41 GMT+02:00 Adam Rankin <span dir="ltr"><<a href="mailto:arankin@robarts.ca" target="_blank">arankin@robarts.ca</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal">Hello all,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am trying to develop a execute_process command that will first load the env variables set by the appropriate vcvarsall, and then run a compile command. See here for my progress so far:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">set(cuda_generation_command cmd /c "\"call \"$ENV{VS${VS_IDE_VERSION}0COMNTOOLS}../../VC/vcvarsall.bat\" x86_amd64 && \"${CUDA_NVCC_EXECUTABLE}\" \"${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu\" \"--run\"\"")<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">execute_process( COMMAND ${cuda_generation_command}<u></u><u></u></p>
<p class="MsoNormal">                 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"<u></u><u></u></p>
<p class="MsoNormal">                 RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out<u></u><u></u></p>
<p class="MsoNormal">                 OUTPUT_STRIP_TRAILING_WHITESPACE)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">When run at a command prompt, the command works as expected. When called from CMake, the output is:
<u></u><u></u></p>
<p class="MsoNormal">The filename, directory name, or volume label syntax is incorrect.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Has anyone ever succeeded with something like this?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
<p class="MsoNormal">Adam<u></u><u></u></p>
</div>
</div>

<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>