我有一个带有 automake 构建系统的项目,那里有 flex/bison 文件。现在我不明白如何将它们包含到 cmake 构建系统中。我正在尝试手动执行此操作。这是项目树:
+ROOT
|---CMakeLists.txt
|---Sources/
| |---Flex
| |---Main
| |---CMakeLists.txt
|---Includes/
文件夹中Flex
有 2 个文件:player_command_parser.ypp; player_command_tok.lpp
. 这些文件来自RoboCup 足球服务器。
我真的不知道如何在新的构建系统中使用它们,所以我决定手动生成所有文件:
flex --c++ player_command_tok.lpp
此命令生成lex.RCSSPCom.cc
以以下代码开头:
#line 3 "lex.RCSSPCom.cc"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* The c++ scanner is a mess. The FlexLexer.h header file relies on the
* following macro. This is required in order to pass the c++-multiple-scanners
* test in the regression suite. We get reports that it breaks inheritance.
* We will address this in a future release of flex, or omit the C++ scanner
* altogether.
*/
#define yyFlexLexer RCSSPComFlexLexer
下一步是:bison -d player_command_parser.ypp
。
我有:player_command_parser.tab.cpp; player_command_parser.tab.hpp
现在我正在尝试将所有生成的文件复制到相关文件夹:*.tab.hpp -> 包含,并将 cc&cpp 文件添加到Sources/CMakeLists.txt
:
set (FlexSources
Server/Flex/lex.RCSSPCom.cc
Server/Flex/player_command_parser.tab.cpp
)
和编译输出:
[ 1%] Building CXX object Sources/Flex/lex.RCSSPCom.cc.o
In file included from /Includes/player_command_tok.h:31:0,
from player_command_tok.lpp:28:
/usr/include/FlexLexer.h:112:7: error: redefinition of ‘class RCSSPComFlexLexer’
/usr/include/FlexLexer.h:112:7: error: previous definition of ‘class RCSSPComFlexLexer’
有什么问题?