From f9c06163ee1e9b1095b2d345ac3e829694a74a32 Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Thu, 15 Oct 2015 20:22:19 +0200 Subject: [PATCH] how to use mstch in your project --- README.md | 27 +++++++++++++++++++++++++-- src/CMakeLists.txt | 5 ++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d2fa3f5..0da8e3a 100644 --- a/README.md +++ b/README.md @@ -204,9 +204,23 @@ Output: - Boost 1.54+ for [Boost.Variant](http://www.boost.org/libs/variant) - CMake 3.0+ for building -## Installing +## Using mstch in your project -From the root of the source tree: +If you are using CMake, the easiest way to include mstch in your project is to +copy the whole directory to your source tree, and use `add_subdirectory` in your +CMakeLists.txt. This will set a variable named `mstch_INCLUDE_DIR` that contains +its include path, and add a static library target named mstch. For example: + +```cmake +add_subdirectory(external/mstch) + +include_directories(${mstch_INCLUDE_DIR}) + +target_link_libraries(your_project mstch) +``` + +If you prefer to install the library globally, you can simply do the following +from the root of the source tree: ```bash $ mkdir build @@ -216,6 +230,15 @@ From the root of the source tree: $ make install ``` +The install command may require root privileges. This will also install CMake +config files, so you can use use `find_package` in your CMakeLists.txt: + +```cmake +find_package(mstch) + +target_link_libraries(your_project mstch::mstch) +``` + ## Running the unit tests Unit tests are using the [Catch](https://github.com/philsquared/Catch) framework, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d3dd42..6517fc4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,10 @@ find_package(Boost 1.54 REQUIRED) +set(mstch_INCLUDE_DIR + ${PROJECT_SOURCE_DIR}/include CACHE STRING "mstch include directory") + include_directories( - ${PROJECT_SOURCE_DIR}/include + ${mstch_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) set(SRC