From 03a696424621d0e4ca1c00541716331ba8f7485a Mon Sep 17 00:00:00 2001 From: Robin Jadoul Date: Tue, 24 May 2016 11:46:36 +0200 Subject: [PATCH] Update CMakeLists --- CMakeLists.txt | 34 +++++++++++++++++++++++++++++++++- src/CMakeLists.txt | 11 ++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeb7b5b..aab7f20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,38 @@ project(Lexesis VERSION 0.1) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED 11) -include_directories(include) +include(ExternalProject) +find_package(mstch QUIET) + +if (NOT mstch_FOUND) + ExternalProject_Add(ext-mstch + GIT_REPOSITORY https://github.com/no1msd/mstch + GIT_TAG 1.0.2 + #The following line is a dirty hack + #to prevent cmake from needlessly clone any submodule + #inspect `ext-mstch-prefix/tmp/ext-mstch-gitclone.cmake` for more info + GIT_SUBMODULES "NONE\ COMMAND\ true\ ERROR_QUIET" + CMAKE_ARGS -DWITH_UNIT_TESTS=NO + INSTALL_COMMAND "" + EXCLUDE_FROM_ALL 1 + ) + + add_library(mstch::mstch IMPORTED STATIC GLOBAL) + add_dependencies(mstch::mstch ext-mstch) + + ExternalProject_Get_Property(ext-mstch source_dir binary_dir) + set_target_properties(mstch::mstch PROPERTIES "IMPORTED_LOCATION" "${binary_dir}/src/${CMAKE_STATIC_LIBRARY_PREFIX}mstch${CMAKE_STATIC_LIBRARY_SUFFIX}") + include_directories(${source_dir}/include) +endif() + +########################################## + +set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}") + +include_directories(include) add_subdirectory(src) + +install(DIRECTORY templates + DESTINATION share/Lexesis + ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ba0bb2..49788ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,15 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(Lexesis main.cpp automata.cpp + backend.cpp re.cpp inputparser.cpp -) + template.cpp + ) + +install(TARGETS Lexesis + RUNTIME DESTINATION bin + )