[CMake] list problem....

Nils Gladitz nilsgladitz at gmail.com
Wed Apr 2 12:12:55 EDT 2014


On 02.04.2014 17:36, Luis Felipe Dominguez Vega wrote:
> Hello averyone, i am crash with my brain with this....
> this is a little piece of my code...
>
> set(PROG_SRC main.cpp version.cpp)
> message(STATUS "TO CHECK: " ${PROG_SRC})

message(STATUS "TO CHECK: " ${PROG_SRC})
is equivalent to message(STATUS "TO CHECK: " "main.cpp" "version.cpp")
message() concatenates the parameters so your message is "TO CHECK: 
main.cppversion.cpp".

To prevent the PROG_SRC content from being split when expanding you can 
use quotes around the expansion:
     message(STATUS "TO CHECK: ${PROG_SRC}")

>
> I'm declared a function to check the style...
>
> function(add_style_check_target TARGET_NAME SOURCES_LIST)
>            message(STATUS "TO CHECK2: " ${SOURCES_LIST})
> endfunction(add_style_check_target)
>

When you pass ${PROG_SRC} the expansion will split at semicolon again so 
your two list item become two arguments.
SOURCE_LIST only covers the first. You can either quote the expansion 
again or use e.g. ${ARGN} to access a variable number of arguments past 
the given list.

Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140402/e5d458f4/attachment.html>


More information about the CMake mailing list