[CMake] keep semicolons alive

Maik Beckmann maikbeckmann at gmx.de
Wed Oct 10 02:29:56 EDT 2007


Am Dienstag, 9. Oktober 2007 15:22:32 schrieb Alexander.Camek at elektrobit.com:
> Hi Maik
>
> > I want to fetch a environment variable which contains
> > semicolon by intention, modify it a little and use it with a
> > custom command:
> >
> > #TEXINPUTS_latex is ":;${workspace_loc}/texmf/texmf/tex//"
> > SET(TEXINPUTS "$ENV{TEXINPUTS_latex};${PROJECT_SOURCE_DIR}")
> > #TEXINPUTS should be
> > ":;${workspace_loc}/texmf/texmf/tex//;/path/to/project"
> >
> > ADD_CUSTOM_COMMAND(
> >     OUTPUT       ${PROJECT_BINARY_DIR}/${LATEX_target}.ps
> >     COMMAND	TEXINPUTS="${TEXINPUTS}"
> >                        ${DVIPS_CONVERTER}
> >                        ${DVI_FILE_WE}.dvi   -o${PS_FILE_WE}.ps
> >    DEPENDS    ${DVI_FILE_WE}.dvi
> >    COMMENT	"dvi -> ps for PDF_${LATEX_target}" )
> >
> > The problem is that the semicolons are replaced by space " ".
> >
> > How can I achieve what I want?
>
> I have got a similar problem.
>
> But I solved it by escaping the semicolon with a backslash, e.g ; -> \;
>
> Hope it will work for you.
>
> Greetings
>
> Alexander
>
>

Hello Alexander,

See the minimal example
<CMakeLists.txt>
#set(myvar $ENV{MYENVAR};${PROJECT_SOURCE_DIR})
set(myvar $ENV{MYENVAR}\;${PROJECT_SOURCE_DIR})

message("myvar==${myvar}")

add_custom_target(bla ALL 
    COMMAND MYNEWENVAR="${myvar}" echo ping )
</CMakeLists.txt>
 which is also attached to this mail. To run it just enter make. 

You'll see that 
    message("myvar==${myvar}") 
results in something like
    myvar==:;/entry/one/;entry/two/;/home/maik/workspace/tester/1
but when
    add_custom_target(bla ALL  COMMAND MYNEWENVAR="${myvar}" echo ping )
gets executed they are gone
    MYNEWENVAR=": /entry/one/ entry/two/ /home/maik/workspace/tester/1" echo 
ping


Regards, Maik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: semicolons.tar.gz
Type: application/x-tgz
Size: 382 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20071010/5625da5c/semicolons.tar-0001.bin


More information about the CMake mailing list