Alex Rivera | Logout

Passing a list to a CMake macro

Asked 2011-03-09T16:22:13.017
63

I am trying to write a macro which goes through a given list of libraries. However the message call in the macro prints only the first item of the list. What am I doing wrong here?

Code:

    macro( FindLibs LIBRARY_NAMES_LIST )
        message( "inside ${LIBRARY_NAMES_LIST}" )
    endmacro()

    set( LIBRARY_NAMES_LIST lib1 lib2 lib3)
    message( "outside ${LIBRARY_NAMES_LIST}" )
    FindLibs(${LIBRARY_NAMES_LIST})

Output:

message( "outside lib1 lib2 lib3" )
message( "inside lib1" )
Edit
Report

1 Answer

90

Quote the variable as you pass it to the macro:

FindLibs("${LIBRARY_NAMES_LIST}")
answered 2011-03-09T23:24:20.203

Your Answer