From 05e3580b6233ff1a5a18885b72e353b26c33e7df Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 5 Jan 2020 15:24:23 +0200 Subject: [PATCH] Add CMake install support, tests --- .travis.yml | 9 +++++++++ CMakeLists.txt | 29 ++++++++++++++++++++--------- test/CMakeLists.txt | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 test/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml index 937bc5a..e9c3a48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -178,6 +178,15 @@ jobs: - cd $BOOST_ROOT/libs/$SELF - ci/travis/valgrind.sh + - os: linux + env: + - COMMENT=cmake + script: + - cd $BOOST_ROOT + - mkdir __build__ && cd __build__ + - cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=move .. + - ctest --output-on-failure -R boost_move + #################### Jobs to run on pushes to master, develop ################### # Coverity Scan diff --git a/CMakeLists.txt b/CMakeLists.txt index f68503a..0ae3bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,11 @@ # Copyright 2018 Mike Dev +# Copyright 2019 Peter Dimov # 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 # -# NOTE: CMake support for Boost.Move is currently experimental at best -# and the interface is likely to change in the future +cmake_minimum_required(VERSION 3.5...3.16) -cmake_minimum_required(VERSION 3.5) -project(BoostMove LANGUAGES CXX) +project(boost_move VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_move INTERFACE) add_library(Boost::move ALIAS boost_move) @@ -14,10 +13,22 @@ add_library(Boost::move ALIAS boost_move) target_include_directories(boost_move INTERFACE include) target_link_libraries(boost_move - INTERFACE - Boost::assert - Boost::config - Boost::core - Boost::static_assert + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::static_assert ) +if(BOOST_SUPERPROJECT_VERSION) + + include(BoostInstall) + boost_install(TARGETS boost_move HEADER_DIRECTORY include/) + +endif() + +if(BUILD_TESTING) + + add_subdirectory(test) + +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..6da16bc --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright 2018, 2019 Peter Dimov +# 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(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(NOT HAVE_BOOST_TEST) + return() +endif() + +file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) + +set(BOOST_TEST_LINK_LIBRARIES Boost::move Boost::assert Boost::config Boost::container Boost::core Boost::static_assert Boost::timer) + +foreach(test IN LISTS tests) + + boost_test(SOURCES ${test}) + +endforeach()