From ae800e3aaff86b513a2a67aee31d39c4ff84ef25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 15 Jun 2016 22:52:41 +0200 Subject: [PATCH 1/2] Added CMake option to enable tests (disabled by default). --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a50a0f..50182af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 2.8.4) set(project_name clangmm) project(${project_name}) +option(LIBCLANGMM_BUILD_TESTS "Build unit tests" OFF) + if(APPLE) set(Boost_USE_STATIC_LIBS "YES") set(CMAKE_MACOSX_RPATH 1) @@ -9,5 +11,7 @@ endif() add_subdirectory(src) -# enable_testing() -# add_subdirectory(tests) +if(libclangmm_BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() From 9154d5fe2be5523fde6231c7d526a26f38fbb345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 15 Jun 2016 23:04:39 +0200 Subject: [PATCH 2/2] Updated readme file with information about CMake option for enabling unit tests. --- README.md | 60 +++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 14d4b6a..8cce918 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,30 @@ # libclangmm - an easy to use C++-wrapper for libclang # - -## About ## -Provides C++ bindings and class structure to the [libclang](http://www.llvm.org) C library. + +## About ## +Provides C++ bindings and class structure to the [libclang](http://www.llvm.org) C library. Developed for [juCi++](https://github.com/cppit/jucipp) - a lightweight platform independent C++-IDE. - -## Dependencies ## -* libclang - -## Installation ## -See [installation guide](https://github.com/cppit/libclangmm/blob/master/docs/install.md) - -# Tests # -The compilation of the tests are disabled due to ease of installation. Simply enter CMakeList.txt and uncomment the last two lines in the file to enable testing. - -```sh -# enable_testing() -# add_subdirectory(tests) -``` -Then simply: -```sh -cmake . -make -ctest -``` -If you want an more detailed look at the tests run the binary instead -```sh -cmake . -make -cd tests -./clangmm_tests --log_level=all -``` -To see more log parameters see [here](http://www.boost.org/doc/libs/1_58_0/libs/test/doc/html/utf/user-guide/runtime-config/reference.html). - - + +## Dependencies ## +* libclang + +## Installation ## +See [installation guide](https://github.com/cppit/libclangmm/blob/master/docs/install.md) + +# Tests # +To run the unit tests, first enable the CMake option `LIBCLANGMM_BUILD_TESTS`: +```sh +cmake -DLIBCLANGMM_BUILD_TESTS=ON . +``` +Then, simply call: +```sh +make +ctest +``` +You may also run the test binary directly to get more details: +```sh +make +cd tests +./clangmm_tests --log_level=all +``` +For more options, see the [documentation of boost’s unit testing framework](http://www.boost.org/doc/libs/1_58_0/libs/test/doc/html/utf/user-guide/runtime-config/reference.html).