summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShao-Ce SUN <sunshaoce@gmail.com>2023-10-23 02:23:56 (GMT)
committerShao-Ce SUN <sunshaoce@gmail.com>2023-10-23 02:23:56 (GMT)
commit7ba27a393ae742b6660f075b9ada29ced19cacc0 (patch)
treef2901426a5ec9e4268efb9e08be5a2e5da254243
parent885b4efb41c039789b81f0dc0d67c1ed0faea17c (diff)
downloadNinja-7ba27a393ae742b6660f075b9ada29ced19cacc0.zip
Ninja-7ba27a393ae742b6660f075b9ada29ced19cacc0.tar.gz
Ninja-7ba27a393ae742b6660f075b9ada29ced19cacc0.tar.bz2
Add a check for re2c version
-rw-r--r--CMakeLists.txt7
1 files changed, 5 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0c62f9..b95dacb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,8 +57,11 @@ else()
endif()
# --- optional re2c
+set(RE2C_PROPER FALSE)
find_program(RE2C re2c)
-if(RE2C)
+execute_process(COMMAND "${RE2C}" --vernum OUTPUT_VARIABLE RE2C_RAW_VERSION)
+math(EXPR RE2C_MAJOR_VERSION "${RE2C_RAW_VERSION} / 10000")
+if(RE2C AND ${RE2C_MAJOR_VERSION} GREATER 1)
# the depfile parser and ninja lexers are generated using re2c.
function(re2c IN OUT)
add_custom_command(DEPENDS ${IN} OUTPUT ${OUT}
@@ -69,7 +72,7 @@ if(RE2C)
re2c(${PROJECT_SOURCE_DIR}/src/lexer.in.cc ${PROJECT_BINARY_DIR}/lexer.cc)
add_library(libninja-re2c OBJECT ${PROJECT_BINARY_DIR}/depfile_parser.cc ${PROJECT_BINARY_DIR}/lexer.cc)
else()
- message(WARNING "re2c was not found; changes to src/*.in.cc will not affect your build.")
+ message(WARNING "re2c ${RE2C_MAJOR_VERSION} or later was not found; changes to src/*.in.cc will not affect your build.")
add_library(libninja-re2c OBJECT src/depfile_parser.cc src/lexer.cc)
endif()
target_include_directories(libninja-re2c PRIVATE src)