proper cmake package

This commit is contained in:
Daniel Sipka 2015-09-30 16:30:19 +02:00
parent e456c8d930
commit 110a07d808
3 changed files with 61 additions and 20 deletions

View file

@ -3,13 +3,17 @@ project(mstch)
option (WITH_UNIT_TESTS "enable building unit test executable" OFF) option (WITH_UNIT_TESTS "enable building unit test executable" OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
set(mstch_VERSION 0.2.2)
if(NOT MSVC) 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() endif()
add_subdirectory(src) add_subdirectory(src)
if(WITH_UNIT_TESTS) if(WITH_UNIT_TESTS)
enable_testing() enable_testing()
include_directories( include_directories(

1
cmake/mstch-config.cmake Normal file
View file

@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/mstch-targets.cmake")

View file

@ -21,5 +21,41 @@ set(SRC
add_library(mstch STATIC ${SRC}) add_library(mstch STATIC ${SRC})
install(TARGETS mstch DESTINATION lib) set_property(TARGET mstch PROPERTY VERSION ${mstch_VERSION})
install(FILES ${CMAKE_SOURCE_DIR}/include/mstch/mstch.hpp DESTINATION include/mstch)
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)