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

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

问题描述

我想写一个宏,它通过一个给定的libs列表。但是,宏中的消息调用仅打印列表的第一项。我在这里做错了什么?



代码:

 宏FindLibs LIBRARY_NAMES_LIST)
消息(outside $ {LIBRARY_NAMES_LIST})
endmacro()

set(LIBRARY_NAMES_LIST lib1 lib2 lib3)
消息(outside $ {LIBRARY_NAMES_LIST })
FindLibs($ {LIBRARY_NAMES_LIST})

输出:

 消息(外部lib1 lib2 lib3)
消息(lib1内部)

解决方案

主要的问题是你使用CMake; - )。



  FindLibs($ {LIBRARY_NAMES_LIST})


I am trying to write a macro which goes through a given list of libs. 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" )

解决方案

The main problem is that you're using CMake ;-).

Seriously, though: quote the variable as you pass it to the macro:

FindLibs("${LIBRARY_NAMES_LIST}")

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

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