Add install targets and CPack support

This commit is contained in:
Denis Blank 2017-10-04 22:58:08 +02:00
parent c75baaec90
commit 0fb0058f6b
2 changed files with 40 additions and 5 deletions

View File

@ -1,11 +1,12 @@
cmake_minimum_required(VERSION 3.2)
project(continuable C CXX)
project(continuable VERSION 2.0.0 LANGUAGES C CXX)
# Dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if (NOT DEFINED CONTINUABLE_UNIT_TESTS
AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CONTINUABLE_UNIT_TESTS ON)
endif()
@ -13,10 +14,12 @@ add_subdirectory(dep)
# continuable-base
add_library(continuable-base INTERFACE)
add_library(continuable::continuable-base ALIAS continuable-base)
target_include_directories(continuable-base
INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/include")
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(continuable-base
INTERFACE
@ -45,8 +48,40 @@ target_link_libraries(continuable
continuable-base
function2)
# Create an install target
install(TARGETS continuable-base
EXPORT ContinuableConfig
INCLUDES DESTINATION include)
install(EXPORT ContinuableConfig
FILE ContinuableConfig.cmake
NAMESPACE continuable::
DESTINATION lib/cmake/continuable)
install(DIRECTORY include/continuable
DESTINATION include FILES_MATCHING PATTERN "*.hpp")
install(FILES LICENSE Readme.md
DESTINATION .)
# Setup CPack for bundling
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
# Since the header only library is platform independent
# we name the packages after the native line feed
if(WIN32)
set(CPACK_SYSTEM_NAME "crlf")
else()
set(CPACK_SYSTEM_NAME "lf")
endif()
include(CPack)
# Testing
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if (CONTINUABLE_UNIT_TESTS)
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@ -99,7 +99,7 @@ int main(int, char**) {
// auto socket = std::make_shared<udp::socket>(service);
// socket->async_send_to()
})
.fail([](cti::error_type error) {
.fail([](cti::error_type /*error*/) {
// ...
});