我有一個automake構建系統的項目,那裏有flex/bison文件。現在我無法理解如何將它們包含到cmake構建系統中。我正在嘗試手動執行此操作。下面是該項目的樹:爲cmake生成文件
+ROOT
|---CMakeLists.txt
|---Sources/
| |---Flex
| |---Main
| |---CMakeLists.txt
|---Includes/
在Flex
文件夾下有2個文件:player_command_parser.ypp; player_command_tok.lpp
。這些文件是從RoboCup soccer server。
我真的不知道如何將它們與新的構建系統中使用,所以我決定用手手動生成的所有文件:
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’
什麼可能是錯的?
愚蠢的事情來檢查:標題衛兵。 –