diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c485bd..90be40b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,17 +3,21 @@ project(mstch) option (WITH_UNIT_TESTS "enable building unit test executable" OFF) set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) set(CMAKE_BUILD_TYPE Release) +set(mstch_VERSION 0.2.2) + if(NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3") endif() add_subdirectory(src) + if(WITH_UNIT_TESTS) enable_testing() include_directories( - vendor/Catch/single_include - vendor/json.hpp/include) + vendor/Catch/single_include + vendor/json.hpp/include) add_subdirectory(test) endif() diff --git a/cmake/mstch-config.cmake b/cmake/mstch-config.cmake new file mode 100644 index 0000000..b2a50e0 --- /dev/null +++ b/cmake/mstch-config.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/mstch-targets.cmake") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecb1f82..2e30ded 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,25 +1,61 @@ find_package(Boost 1.54 REQUIRED) include_directories( - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIR}) + ${CMAKE_SOURCE_DIR}/include + ${Boost_INCLUDE_DIR}) set(SRC - state/in_section.cpp - state/outside_section.cpp - state/render_state.hpp - visitor/get_token.hpp - visitor/has_token.hpp - visitor/is_node_empty.hpp - visitor/render_node.hpp - visitor/render_section.hpp - mstch.cpp - render_context.cpp - template_type.cpp - token.cpp - utils.cpp) + state/in_section.cpp + state/outside_section.cpp + state/render_state.hpp + visitor/get_token.hpp + visitor/has_token.hpp + visitor/is_node_empty.hpp + visitor/render_node.hpp + visitor/render_section.hpp + mstch.cpp + render_context.cpp + template_type.cpp + token.cpp + utils.cpp) add_library(mstch STATIC ${SRC}) -install(TARGETS mstch DESTINATION lib) -install(FILES ${CMAKE_SOURCE_DIR}/include/mstch/mstch.hpp DESTINATION include/mstch) \ No newline at end of file +set_property(TARGET mstch PROPERTY VERSION ${mstch_VERSION}) + +install( + TARGETS mstch EXPORT mstchTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + +install( + FILES "${CMAKE_SOURCE_DIR}/include/mstch/mstch.hpp" + DESTINATION include/mstch + COMPONENT Devel) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config-version.cmake" + VERSION ${mstch_VERSION} + COMPATIBILITY AnyNewerVersion) + +export( + EXPORT mstchTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-targets.cmake" + NAMESPACE mstch::) + +configure_file( + "${CMAKE_SOURCE_DIR}/cmake/mstch-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config.cmake") + +install( + EXPORT mstchTargets + FILE mstch-targets.cmake + NAMESPACE mstch:: + DESTINATION lib/cmake/mstch) + +install(FILES + "${CMAKE_SOURCE_DIR}/cmake/mstch-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mstch/mstch-config-version.cmake" + DESTINATION lib/cmake/mstch + COMPONENT Devel)