2

I use cmake to generate a VS 2017 solution. I use "add_custom_command" to add a post build event.

The problem is that it add some quotes around my command code, and this make my script failing !

Do you know why ? And how to get rid of it ?

Here is my command :

add_custom_command(TARGET "MyProject"
                   VERBATIM
                   POST_BUILD
                   COMMAND LIB.EXE -OUT:$(OutDir)MyProject_static.lib c:/libs/liba.lib c:/libs/libb.lib
                   COMMENT "Merging into a static library")

Here is what I find in VS :

setlocal
LIB.EXE "-OUT:$(OutDir)MyProject_static.lib c:/libs/liba.lib c:/libs/libb.lib"
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd

The problem is that cmake add quotes around "-OUT..." , how can I remove them ?

Any idea ?

Thanks

einpoklum
  • 118,144
  • 57
  • 340
  • 684
CDZ
  • 813
  • 1
  • 11
  • 27
  • "this make my script failing" - Why your script fails in that environment? Does it see 'OutDir' variable correctly? I am not sure, but reffering to internal variables of the build system from CMake *COMMAND*'s is not an expected usecase - you should use CMake variables and properties instead. – Tsyvarev Jan 24 '18 at 16:04
  • Thanks. It is not a problem, in the output I see the "whole" path, it mean that $(OutDir) is correctly replaced ! – CDZ Jan 24 '18 at 16:16
  • It seems it is because the "LIB.EXE..." is putted inside double quotes ! It should be put at a next line, without double quotes !!!! But I don't know how to force this ? Any idea ? – CDZ Jan 24 '18 at 16:19

0 Answers0