Skip to content

Commit

Permalink
Proper out-of-source-directory builds with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Jun 4, 2017
1 parent 282e6b5 commit 32c181a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ find_package(BISON)
find_package(FLEX)
find_package(GLPK)

BISON_TARGET (citip_parser parser.y parser.cxx)
FLEX_TARGET (citip_scanner scanner.l scanner.cxx)
BISON_TARGET (citip_parser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cxx
COMPILE_FLAGS --defines=${CMAKE_CURRENT_BINARY_DIR}/parser.hxx)
FLEX_TARGET (citip_scanner scanner.l ${CMAKE_CURRENT_BINARY_DIR}/scanner.cxx
COMPILE_FLAGS --header-file=${CMAKE_CURRENT_BINARY_DIR}/scanner.hxx)
ADD_FLEX_BISON_DEPENDENCY(citip_scanner citip_parser)


include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(Citip
main.cpp
citip.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parser.cxx
${CMAKE_CURRENT_SOURCE_DIR}/scanner.cxx
${CMAKE_CURRENT_BINARY_DIR}/parser.cxx
${CMAKE_CURRENT_BINARY_DIR}/scanner.cxx
)
target_link_libraries(Citip glpk)
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Citip: $(OBJS)
g++ $(CFLAGS) -o $@ -c $< -std=c++11

parser.cxx: parser.y
bison $<
bison -o $@ --defines=parser.hxx $<

scanner.cxx: scanner.l
flex $<
flex -o $@ --header-file=scanner.hxx $<

parser.hxx: parser.cxx
scanner.hxx: scanner.cxx
Expand Down
3 changes: 0 additions & 3 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
language easier to extend and the code easier to maintain.
*/

%output "parser.cxx"
%defines "parser.hxx"

/* C++ parser interface */
%skeleton "lalr1.cc"
%require "3.0"
Expand Down
3 changes: 0 additions & 3 deletions scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
yyscan_t yyscanner) // scanner object
*/

%option outfile="scanner.cxx"
%option header-file="scanner.hxx"

/*
c++ generate C++ parser class
8bit don't fail on 8-bit input characters
Expand Down

0 comments on commit 32c181a

Please sign in to comment.