diff options
Diffstat (limited to 'src/generate_wkt_parser.cmake')
| -rw-r--r-- | src/generate_wkt_parser.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/generate_wkt_parser.cmake b/src/generate_wkt_parser.cmake new file mode 100644 index 00000000..bcfc09be --- /dev/null +++ b/src/generate_wkt_parser.cmake @@ -0,0 +1,18 @@ +message("Generating ${OUT_FILE}") + +execute_process(COMMAND "bison" "--no-lines" "-d" "-p" "${PREFIX}" "-o${OUT_FILE}" "${IN_FILE}" + RESULT_VARIABLE STATUS) + +if(STATUS AND NOT STATUS EQUAL 0) + message(FATAL_ERROR "bison failed") +endif() + +# Post processing of the generated file +# All those replacements are to please MSVC +file(READ ${OUT_FILE} CONTENTS) +string(REPLACE "yyerrorlab:" "#if 0\nyyerrorlab:" CONTENTS "${CONTENTS}") +string(REPLACE "yyerrlab1:" "#endif\nyyerrlab1:" CONTENTS "${CONTENTS}") +string(REPLACE "for (yylen = 0; yystr[yylen]; yylen++)" "for (yylen = 0; yystr && yystr[yylen]; yylen++)" CONTENTS "${CONTENTS}") +string(REPLACE "return yystpcpy (yyres, yystr) - yyres;" "return (YYPTRDIFF_T)(yystpcpy (yyres, yystr) - yyres);" CONTENTS "${CONTENTS}") +string(REPLACE "YYPTRDIFF_T yysize = yyssp - yyss + 1;" "YYPTRDIFF_T yysize = (YYPTRDIFF_T)(yyssp - yyss + 1);" CONTENTS "${CONTENTS}") +file(WRITE "${OUT_FILE}" "${CONTENTS}") |
