http://www.cmake.org/Wiki/CMake/Language_Syntax does explain
about semicolons, strings, and lists, but the consequences are
still kind of surprising.  Newbies like me have to write little programs
to feel our way towards an understanding of what works.

For example, I wanted to pass a space-separated list of things
as a single argument to an external program, and I didn't
get what was going on until I wrote a tiny program to explore
the problem in isolation.  Here it is, on the off chance some
other newbie will dredge it up in a search and find it useful.

cmake_minimum_required(VERSION 2.8.11)
project(blah)

# foo.pl is the single line
# print STDERR "args are: ".join(',',@ARGV)."\n";

function(foo)
    execute_process(COMMAND perl foo.pl ${ARGN})
endfunction()

# Works; passes two arguments
foo(
   --libs "foo.a bar.a"
)

set(LIBS foo.a)
list(APPEND LIBS bar.a)
# Fails; passes three arguments, despite the quotes
foo(
   --libs "${LIBS}"
)

STRING(REGEX REPLACE ";" " " XLIBS "${LIBS}" )
# Works; passes two arguments
foo(
   --libs "${XLIBS}"
)
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to