I am trying to add some custom build commands to my vc2010 project by using ADD_CUSTOM_COMMAND. But:
[1] I just find that CMAKE will automatically insert much more code than I hvae expected.
For example, I want the command exactly to be:
"c:\Some Folder\MyTool.exe" -arg0 -arg1
The corresponding code in CMakeLists.txt is like:
add_custom_command( OUTPUT ${outfile}
COMMAND "c:\Some Folder\MyTool.exe" ARGS "-arg0 -arg1"
# COMMAND "\"c:\Some Folder\MyTool.exe\"" will FAIL to be parsed!
MAIN_DEPENDENCY ${infile}
VERBATIM)
but actually I got:
setlocal
c:\Some Folder\MyTool.exe "-arg0 -arg1"
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
This is not what I want. I have also tried the string: COMMAND "\"${MYTOOL_PATH}\" -arg0 -arg1", but CMake just failed to parse it because there is a quote in front of the string.
So it's bad I can't quote the command string because the path c:\Some Folder\MyTool.exe contains spaces.
[2] I also notice CMake will automatically expand my dependency pathes.
If I add to the command DEPENS "$(PATH_MACRO)", I will eventually get the dependency path automatically expanded by CMake: C:\MySolutionDir\$(PATH_MACRO); But I only want $(PATH_MACRO), because I will make sure visual studio understands what $(PATH_MACRO) refers to.
So here is my question:
How can CMake only accept my raw inputs, without auto expanding the path or inserting code I don't expect? I will make sure my inputs will be valid for visual studio. Thanks!
PS. My CMake version: 2.8.10.2. VS version: visual studio 2010 Ultimate