Build examples along with main program

This commit is contained in:
Robin Jadoul 2016-05-29 20:21:31 +02:00
parent 6dbb31179a
commit 8328fee2e4
5 changed files with 36 additions and 27 deletions

View File

@ -54,3 +54,5 @@ add_dependencies(Lexesis ext-optparse)
install(DIRECTORY templates
DESTINATION share/Lexesis
)
add_subdirectory(examples)

2
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(keywords)
add_subdirectory(SyntaxHighlighter)

View File

@ -1,11 +1,22 @@
cmake_minimum_required(VERSION 2.6)
find_program(LEXESIS_EXE Lexesis PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../build/bin")
project(SyntaxHighlighter)
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/xmllexer.lxs"
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" -n XMLLexer "${CMAKE_CURRENT_SOURCE_DIR}/src/xmllexer.lxs"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.h" "${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.cpp"
)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED 11)
set(CMAKE_CXX_FLAGS "-Wall -g3 -ggdb")
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/attributelexer.lxs"
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" -n AttributeLexer "${CMAKE_CURRENT_SOURCE_DIR}/src/attributelexer.lxs"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.h" "${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.cpp"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories(include)
add_subdirectory(src)
add_executable(highlighter
src/highlighter.cpp
src/main.cpp
"${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.cpp"
)

View File

@ -1,20 +0,0 @@
find_program(LEXESIS_EXE Lexesis PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../build/bin")
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/xmllexer.lxs"
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" -n XMLLexer "${CMAKE_CURRENT_SOURCE_DIR}/xmllexer.lxs"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.h" "${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.cpp"
)
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/attributelexer.lxs"
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" -n AttributeLexer "${CMAKE_CURRENT_SOURCE_DIR}/attributelexer.lxs"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.h" "${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.cpp"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_executable(highlighter
highlighter.cpp
main.cpp
"${CMAKE_CURRENT_BINARY_DIR}/AttributeLexer.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/XMLLexer.cpp"
)

View File

@ -0,0 +1,14 @@
find_program(LEXESIS_EXE Lexesis PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../build/bin")
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/keywordsLexer.lxs"
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/keywordsLexer.lxs"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/KeywordsLexer.h" "${CMAKE_CURRENT_BINARY_DIR}/KeywordsLexer.cpp"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_executable(keywords
main.cpp
"${CMAKE_CURRENT_BINARY_DIR}/KeywordsLexer.cpp"
)