From 691b821c9046eafa73f12335a8c3150fd9db1595 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Fri, 10 May 2019 17:03:20 +0200 Subject: CMake: Support building without re2c --- CMakeLists.txt | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d313342..004d059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,21 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -fdiagnostics-color") endif() -# the depfile parser and ninja lexers are generated using re2c. -function(re2c IN OUT) - add_custom_command(DEPENDS ${IN} OUTPUT ${OUT} - COMMAND re2c -b -i --no-generation-date -o ${OUT} ${IN} - ) -endfunction() -re2c(${CMAKE_SOURCE_DIR}/src/depfile_parser.in.cc ${CMAKE_BINARY_DIR}/depfile_parser.cc) -re2c(${CMAKE_SOURCE_DIR}/src/lexer.in.cc ${CMAKE_BINARY_DIR}/lexer.cc) -add_library(libninja-re2c OBJECT ${CMAKE_BINARY_DIR}/depfile_parser.cc ${CMAKE_BINARY_DIR}/lexer.cc) +find_program(RE2C re2c) +if(RE2C) + # the depfile parser and ninja lexers are generated using re2c. + function(re2c IN OUT) + add_custom_command(DEPENDS ${IN} OUTPUT ${OUT} + COMMAND ${RE2C} -b -i --no-generation-date -o ${OUT} ${IN} + ) + endfunction() + re2c(${CMAKE_SOURCE_DIR}/src/depfile_parser.in.cc ${CMAKE_BINARY_DIR}/depfile_parser.cc) + re2c(${CMAKE_SOURCE_DIR}/src/lexer.in.cc ${CMAKE_BINARY_DIR}/lexer.cc) + add_library(libninja-re2c OBJECT ${CMAKE_BINARY_DIR}/depfile_parser.cc ${CMAKE_BINARY_DIR}/lexer.cc) +else() + message(WARNING "re2c 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) # Core source files all build into ninja library. -- cgit v0.12