diff --git a/.gitignore b/.gitignore index 60f8a3b..96f85de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /Monicelli.output /mcc +/build diff --git a/Makefile b/CMakeLists.txt similarity index 58% rename from Makefile rename to CMakeLists.txt index 5b5fc51..18fd92e 100644 --- a/Makefile +++ b/CMakeLists.txt @@ -17,29 +17,24 @@ # along with this program. If not, see . # -default: compile cleanautogen +project(Monicelli) +cmake_minimum_required(VERSION 2.8) -bison2: patch2 default unpatch2 +find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) -compile: - bison Monicelli.ypp - flex Monicelli.lpp - g++ \ - -Wall -Wno-deprecated-register -std=c++11 -DYYDEBUG=0 -O2 \ - Parser.cpp lex.yy.cc Nodes.cpp main.cpp -o mcc +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) -patch2: - # Bison 2 compatibility patch - patch -r - -p 1 -N < bison2.patch || true +add_definitions(-Wall -Wno-deprecated-register -std=c++0x -DYYDEBUG=0 -O2) -unpatch2: - patch -p 1 -R < bison2.patch +bison_target(Parser Monicelli.ypp ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp) +flex_target(Scanner Monicelli.lpp ${CMAKE_CURRENT_BINARY_DIR}/Lexer.cpp) -graph: - bison --graph Monicelli.y +add_executable( + mcc + main.cpp Nodes.cpp ${BISON_Parser_OUTPUTS} ${FLEX_Scanner_OUTPUTS} +) -cleanautogen: - rm -f Parser.?pp lex.* location.hh position.hh stack.hh - -clean: cleanautogen - rm -f Parser.output Parser.dot diff --git a/Monicelli.ypp b/Monicelli.ypp index 4fa0e33..993b05c 100644 --- a/Monicelli.ypp +++ b/Monicelli.ypp @@ -27,7 +27,6 @@ %language "c++" %defines -%output "Parser.cpp" %locations %token-table