将列表传递给 CMake 宏 [英] Passing a list to a CMake macro

查看:33
本文介绍了将列表传递给 CMake 宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个通过给定库列表的宏.然而,宏中的消息调用仅打印列表的第一项.我在这里做错了什么?

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?

代码:

    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})

输出:

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

推荐答案

在将变量传递给宏时引用它:

Quote the variable as you pass it to the macro:

FindLibs("${LIBRARY_NAMES_LIST}")

这篇关于将列表传递给 CMake 宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆