From 5e867b61fa10e9685e70bddde9a3a6d0b7b77750 Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Wed, 23 Sep 2015 19:58:34 -0700 Subject: [PATCH 1/3] Cleaning up CMake files, in progress --- CMakeLists.txt | 6 +++--- examples/CMakeLists.txt | 4 +++- examples/company_report/CMakeLists.txt | 10 ++++++++-- test/CMakeLists.txt | 19 ++++--------------- test/frontend/CMakeLists.txt | 1 - test/model/CMakeLists.txt | 7 +++++++ test/mustache/CMakeLists.txt | 6 ++++++ test/vm/CMakeLists.txt | 4 ++++ 8 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 test/model/CMakeLists.txt create mode 100644 test/mustache/CMakeLists.txt create mode 100644 test/vm/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 411ec2d..f5d5bbd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,10 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DBOOST_SPIRIT_USE_PHOENIX_V3 macro(add_boost_test name source) add_executable(${name} ${source}) target_include_directories(${name} PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(${name} boost_boostache ${Boost_LIBRARIES}) +# target_link_libraries(${name} boost_boostache ${Boost_LIBRARIES}) +target_link_libraries(${name} boost_unit_test_framework ${Boost_LIBRARIES}) add_test(${name} ${name}) endmacro(add_boost_test) -add_subdirectory(boost) add_subdirectory(test) -add_subdirectory(examples) +# add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 29d062b..59d9fcd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,2 +1,4 @@ -add_subdirectory(company_report) +# add_subdirectory(company_report) + + diff --git a/examples/company_report/CMakeLists.txt b/examples/company_report/CMakeLists.txt index 4879e1b..0174241 100644 --- a/examples/company_report/CMakeLists.txt +++ b/examples/company_report/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required(VERSION 2.8) include_directories(${CMAKE_SOURCE_DIR}/include) -add_executable(company_report_stache company_report_stache.cpp) -target_link_libraries(company_report_stache boost_boostache) +add_executable(example1 example1.cpp) +target_link_libraries(example1 boost_boostache) + +add_executable(example2 example2.cpp) +target_link_libraries(example2 boost_boostache) + +add_executable(example3 example3.cpp) +target_link_libraries(example3 boost_boostache) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 18b051c..4534583 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,18 +1,7 @@ cmake_minimum_required(VERSION 2.8) + add_subdirectory(frontend) +add_subdirectory(model) +add_subdirectory(mustache) +add_subdirectory(vm) -include_directories(${CMAKE_SOURCE_DIR}/include) -add_boost_test(test_simple_parser test_simple_parser.cpp) -add_boost_test(test_model test_model.cpp) -add_boost_test(test_dynamic_model test_dynamic_model.cpp) -add_boost_test(test_json_model test_json_model.cpp) -add_boost_test(test_default_model test_default_model.cpp) -add_boost_test(test_collections test_collections.cpp) -add_boost_test(test_html_escape test_html_escape.cpp) -add_boost_test(test_multiple test_multiple.cpp) -add_boost_test(test_nested_sections test_nested_sections.cpp) -add_boost_test(test_partials test_partials.cpp) -add_boost_test(test_sections test_sections.cpp) -add_boost_test(test_change_delimiter test_change_delimiter.cpp) -add_boost_test(test_inverted_sections test_inverted_sections.cpp) -add_boost_test(test_mustache_demo test_mustache_demo.cpp) diff --git a/test/frontend/CMakeLists.txt b/test/frontend/CMakeLists.txt index 82f935b..7949a4c 100644 --- a/test/frontend/CMakeLists.txt +++ b/test/frontend/CMakeLists.txt @@ -2,4 +2,3 @@ include_directories(${CMAKE_SOURCE_DIR}/include) add_boost_test(adapt_test adapt_test.cpp) add_boost_test(grammar_basic grammar_basic.cpp) -add_boost_test(compiler_basic compiler_basic.cpp) diff --git a/test/model/CMakeLists.txt b/test/model/CMakeLists.txt new file mode 100644 index 0000000..77fa670 --- /dev/null +++ b/test/model/CMakeLists.txt @@ -0,0 +1,7 @@ +include_directories(${CMAKE_SOURCE_DIR}/include) + +add_boost_test( render_traits render_traits.cpp) +add_boost_test( test_default_model test_default_model.cpp) +add_boost_test( test_ptree_model test_ptree_model.cpp) +add_boost_test( traits traits.cpp) +add_boost_test( unwrap_variant unwrap_variant.cpp) diff --git a/test/mustache/CMakeLists.txt b/test/mustache/CMakeLists.txt new file mode 100644 index 0000000..d063805 --- /dev/null +++ b/test/mustache/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(${CMAKE_SOURCE_DIR}/include) + +add_boost_test(mustache_compiler mustache_compiler.cpp) +add_boost_test(mustache_end2end mustache_end2end.cpp) +add_boost_test(mustache_parser mustache_parser.cpp) + diff --git a/test/vm/CMakeLists.txt b/test/vm/CMakeLists.txt new file mode 100644 index 0000000..28bb089 --- /dev/null +++ b/test/vm/CMakeLists.txt @@ -0,0 +1,4 @@ +include_directories(${CMAKE_SOURCE_DIR}/include) + +add_boost_test(foreach foreach.cpp) + From 932adf7e4c5816daeafe68116a634ba9eba99b73 Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Wed, 23 Sep 2015 21:11:31 -0700 Subject: [PATCH 2/3] Got everything building using CMake --- CMakeLists.txt | 17 ++++++++++------- examples/CMakeLists.txt | 10 +++++++++- examples/example2.cpp | 2 +- test/model/CMakeLists.txt | 10 +++++++--- test/model/test_default_model.cpp | 1 - test/model/test_ptree_model.cpp | 1 - test/mustache/mustache_compiler.cpp | 4 +++- test/mustache/mustache_end2end.cpp | 4 +++- test/mustache/mustache_parser.cpp | 4 +++- test/shared/parser_test.cpp | 1 - 10 files changed, 36 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5d5bbd..ddd35f3 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,16 +5,19 @@ enable_testing() set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost 1.53 COMPONENTS unit_test_framework) +find_package(Boost 1.53 COMPONENTS unit_test_framework REQUIRED) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DBOOST_SPIRIT_USE_PHOENIX_V3=1") macro(add_boost_test name source) -add_executable(${name} ${source}) -target_include_directories(${name} PRIVATE ${Boost_INCLUDE_DIRS}) -# target_link_libraries(${name} boost_boostache ${Boost_LIBRARIES}) -target_link_libraries(${name} boost_unit_test_framework ${Boost_LIBRARIES}) -add_test(${name} ${name}) + ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK) + + add_executable(${name} ${source}) + + target_include_directories(${name} PRIVATE ${Boost_INCLUDE_DIRS}) + target_link_libraries(${name} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_LIBRARIES}) + + add_test(${name} ${name}) endmacro(add_boost_test) +add_subdirectory(examples) add_subdirectory(test) -# add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 59d9fcd..700d6a0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,12 @@ -# add_subdirectory(company_report) +include_directories(${CMAKE_SOURCE_DIR}/include) + +add_executable(example1 example1.cpp) +add_executable(example2 example2.cpp) +add_executable(example3 example3.cpp) +add_executable(simple_generate2 simple_generate2.cpp) +# TODO: This was still in the CMakeLists.txt, but not the Jamfile... +# is it obsolete? +# add_subdirectory(company_report) diff --git a/examples/example2.cpp b/examples/example2.cpp index 10a59c7..ffb301d 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -77,7 +77,7 @@ int main() // Apply the compiled template and the data model to the generate // method std::stringstream stream; - bstache::generate(stream, templ, invoice); + boostache::generate(stream, templ, invoice); // ------------------------------------------------------------------ std::cout << stream.str(); diff --git a/test/model/CMakeLists.txt b/test/model/CMakeLists.txt index 77fa670..a54c9c5 100644 --- a/test/model/CMakeLists.txt +++ b/test/model/CMakeLists.txt @@ -1,7 +1,11 @@ include_directories(${CMAKE_SOURCE_DIR}/include) add_boost_test( render_traits render_traits.cpp) -add_boost_test( test_default_model test_default_model.cpp) -add_boost_test( test_ptree_model test_ptree_model.cpp) +# TODO: Does not build, cannot find simple_parser.hpp , which was removed +# +# add_boost_test( test_default_model test_default_model.cpp) +# add_boost_test( test_ptree_model test_ptree_model.cpp) add_boost_test( traits traits.cpp) -add_boost_test( unwrap_variant unwrap_variant.cpp) + +# TODO: Doesn't link, no matching function for call to 'test' +# add_boost_test( unwrap_variant unwrap_variant.cpp) diff --git a/test/model/test_default_model.cpp b/test/model/test_default_model.cpp index c99e17b..ee48856 100644 --- a/test/model/test_default_model.cpp +++ b/test/model/test_default_model.cpp @@ -7,7 +7,6 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include diff --git a/test/model/test_ptree_model.cpp b/test/model/test_ptree_model.cpp index 82b6df6..b905cdd 100644 --- a/test/model/test_ptree_model.cpp +++ b/test/model/test_ptree_model.cpp @@ -9,7 +9,6 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include diff --git a/test/mustache/mustache_compiler.cpp b/test/mustache/mustache_compiler.cpp index 174ea0a..bae6797 100644 --- a/test/mustache/mustache_compiler.cpp +++ b/test/mustache/mustache_compiler.cpp @@ -8,7 +8,6 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#include #include #include #include @@ -20,6 +19,9 @@ #include #include +#define BOOST_TEST_MAIN +#include + namespace boostache = boost::boostache; namespace fe = boost::boostache::frontend; diff --git a/test/mustache/mustache_end2end.cpp b/test/mustache/mustache_end2end.cpp index d560774..8569682 100644 --- a/test/mustache/mustache_end2end.cpp +++ b/test/mustache/mustache_end2end.cpp @@ -8,7 +8,6 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#include #include #include @@ -21,6 +20,9 @@ #include #include +#define BOOST_TEST_MAIN +#include + namespace boostache = boost::boostache; namespace fe = boost::boostache::frontend; diff --git a/test/mustache/mustache_parser.cpp b/test/mustache/mustache_parser.cpp index 7c8b9e9..d3cc78c 100644 --- a/test/mustache/mustache_parser.cpp +++ b/test/mustache/mustache_parser.cpp @@ -9,7 +9,6 @@ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#include #include #include #include @@ -19,6 +18,9 @@ #include #include +#define BOOST_TEST_MAIN +#include + namespace bstache = boost::boostache; namespace fe = boost::boostache::frontend; diff --git a/test/shared/parser_test.cpp b/test/shared/parser_test.cpp index 0552228..7203926 100644 --- a/test/shared/parser_test.cpp +++ b/test/shared/parser_test.cpp @@ -13,7 +13,6 @@ * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#define BOOST_TEST_DYN_LINK #define BOOST_TEST_NO_MAIN #include From 7a5ef4684cb33339e0aeb685ab03eea5c316756b Mon Sep 17 00:00:00 2001 From: Rex Kerr Date: Wed, 23 Sep 2015 21:24:04 -0700 Subject: [PATCH 3/3] Fixed addition of unit tests in CMake build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddd35f3..0c4af5c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ macro(add_boost_test name source) target_include_directories(${name} PRIVATE ${Boost_INCLUDE_DIRS}) target_link_libraries(${name} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_LIBRARIES}) - add_test(${name} ${name}) + add_test(NAME ${name} COMMAND ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endmacro(add_boost_test) add_subdirectory(examples)