How do you pass SOME_LIB = "- lmylib -lmylib2" to BUILD_COMMAND for ExternalProject_Add ()?

I am trying to pass a quoted string through BUILD_COMMAND to ExternalProject_Add () and am trying to use it in every way. The code looks like this:

set (mylibs "-lmylib -lmylib2") ExternalProject_Add(Foo URL http://foo BUILD_COMMAND make SOME_LIB=${mylibs} BUILD_IN_SOURCE 1 ...) 

I tried using backslash quotes, double quotes, pasting it all, but every time the whole quote SOME_LIB = ... is quoted, or my typed quotes get an escape code. Can't get quotes on the command line so that they just display options?

Although I cannot force the call to make SOMELIB="-lmylib -lmylib2" , you can force it to call make "SOMELIB=-lmylib -lmylib2" , which seems to do the same.

+4
source share
1 answer

Have you tried to quote like this?

 ExternalProject_Add( ... BUILD_COMMAND make "SOME_LIB=\"${mylibs}\"" ... ) 

The outer pair of double quotes says, "This is all one argument here," and the inner pair of escaped double quotes says "they are embedded in the argument."

Additional shielding may be required. I have not tried this, and I am not sure if this will work. But there must be a way to add escape characters until it works ... Or, in the worst case, you can write a script file (bash.sh or batch .bat) that has the correct shell syntax for calling make like you want, and then invoke the execution of the script file as BUILD_COMMAND.

0
source

Source: https://habr.com/ru/post/1445889/


All Articles