diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-11 00:36:22 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-10-11 11:47:34 +0200 |
| commit | b68ee957234387f8a5bb0e0a4eac88fc4cf5ed47 (patch) | |
| tree | f5d920a9e6a1b2b35ae90cc9fc1c1d2e1a4bb85c /src/generate_wkt_parser.cmake | |
| parent | 7f0b6bd9c6978ac7639bcaf0de452cb29318e683 (diff) | |
| download | PROJ-b68ee957234387f8a5bb0e0a4eac88fc4cf5ed47.tar.gz PROJ-b68ee957234387f8a5bb0e0a4eac88fc4cf5ed47.zip | |
CMake build: add generate_wkt1_parser and generate_wkt2_parser manual target, and logic to detect when they must be run
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}") |
