检查结构有成员¶
检查给定的结构或类是否具有指定的成员变量
- CHECK_STRUCT_HAS_MEMBER¶
CHECK_STRUCT_HAS_MEMBER(<struct> <member> <header> <variable> [LANGUAGE <language>])
<struct> - the name of the struct or class you are interested in <member> - the member which existence you want to check <header> - the header(s) where the prototype should be declared <variable> - variable to store the result <language> - the compiler to use (C or CXX)
在调用此宏以修改检查运行方式之前,可以设置以下变量:
CMAKE_REQUIRED_FLAGS编译命令行标志的字符串。
CMAKE_REQUIRED_DEFINITIONS要定义的宏列表 (-DFOO=bar)。
CMAKE_REQUIRED_INCLUDES包含目录列表。
CMAKE_REQUIRED_LINK_OPTIONS在 3.14 版本加入: 传递给链接命令的选项列表。
CMAKE_REQUIRED_LIBRARIES要链接的库列表。
CMAKE_REQUIRED_QUIET在 3.1 版本加入: 在没有消息的情况下安静地执行。
例子:
CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h
HAVE_TIMEVAL_TV_SEC LANGUAGE C)