From bfbdf4f45feb632977b504fb34070d51d9da2e57 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 8 Jan 2020 05:08:37 +0200 Subject: [PATCH] Add CMake install support, tests --- .travis.yml | 18 ++++++++ CMakeLists.txt | 38 ++++++++++------ test/CMakeLists.txt | 11 +++++ test/Jamfile | 63 +++++++++++++++++--------- test/cmake_install_test/CMakeLists.txt | 18 ++++++++ test/cmake_subdir_test/CMakeLists.txt | 3 +- 6 files changed, 113 insertions(+), 38 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/cmake_install_test/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml index 2da6f8d..57e7281 100644 --- a/.travis.yml +++ b/.travis.yml @@ -322,6 +322,13 @@ matrix: compiler: clang++ env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z + - os: linux + env: CMAKE_TEST=1 + script: + - mkdir __build__ && cd __build__ + - cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=smart_ptr .. + - ctest --output-on-failure -R boost_smart_ptr + - os: linux compiler: g++ env: CMAKE_SUBDIR_TEST=1 @@ -331,6 +338,17 @@ matrix: - cmake --build . - cmake --build . --target check + - os: linux + env: CMAKE_INSTALL_TEST=1 + script: + - mkdir __build__ && cd __build__ + - cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="smart_ptr;assert;config;core;move;static_assert;throw_exception;type_traits" -DCMAKE_INSTALL_PREFIX=~/.local .. + - cmake --build . --target install + - cd ../libs/smart_ptr/test/cmake_install_test && mkdir __build__ && cd __build__ + - cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + - cmake --build . + - cmake --build . --target check + install: - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true - cd .. diff --git a/CMakeLists.txt b/CMakeLists.txt index e3acea0..bbb6a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,10 @@ -# Copyright 2018 Mike Dev +# Copyright 2018-2020 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 -# Partial (add_subdirectory only) and experimental CMake support -# Subject to change; please do not rely on the contents of this file yet +cmake_minimum_required(VERSION 3.5...3.16) -cmake_minimum_required(VERSION 3.5) -project(BoostSmartPtr LANGUAGES CXX) +project(boost_smart_ptr VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_smart_ptr INTERFACE) add_library(Boost::smart_ptr ALIAS boost_smart_ptr) @@ -14,13 +12,25 @@ add_library(Boost::smart_ptr ALIAS boost_smart_ptr) target_include_directories(boost_smart_ptr INTERFACE include) target_link_libraries(boost_smart_ptr - INTERFACE - Boost::assert - Boost::config - Boost::core - Boost::move - Boost::predef - Boost::static_assert - Boost::throw_exception - Boost::type_traits + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::move + Boost::static_assert + Boost::throw_exception + Boost::type_traits ) + +if(BOOST_SUPERPROJECT_VERSION) + + include(BoostInstall) + boost_install(TARGETS boost_smart_ptr 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..0004512 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,11 @@ +# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(HAVE_BOOST_TEST) + +boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::smart_ptr Boost::core Boost::align Boost::atomic Boost::container_hash) + +endif() diff --git a/test/Jamfile b/test/Jamfile index 4e9e62e..f055d21 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -57,10 +57,11 @@ run yield_k_test.cpp : : : multi : yield_k_test.mt ; run spinlock_test.cpp ; run spinlock_try_test.cpp ; run spinlock_try_test.cpp : : : multi : spinlock_try_test.mt ; -run spinlock_pool_test.cpp : : : - # msvc-8.0, 9.0 optimizer codegen bug for `x % 41` - msvc-8.0,release:no - msvc-9.0,release:no ; +run spinlock_pool_test.cpp + : : : + # msvc-8.0, 9.0 optimizer codegen bug for `x % 41` + msvc-8.0,release:no + msvc-9.0,release:no ; run make_shared_test.cpp ; run make_shared_move_emulation_test.cpp ; @@ -78,7 +79,10 @@ run sp_recursive_assign_test.cpp ; run sp_recursive_assign2_test.cpp ; run sp_recursive_assign_rv_test.cpp ; run sp_recursive_assign2_rv_test.cpp ; -compile-fail auto_ptr_lv_fail.cpp : gcc-4.4.7:no ; + +compile-fail auto_ptr_lv_fail.cpp + : gcc-4.4.7:no ; + run atomic_count_test2.cpp ; run sp_typeinfo_test.cpp ; compile make_shared_fp_test.cpp ; @@ -158,23 +162,33 @@ compile-fail array_fail_dereference.cpp ; compile-fail array_fail_member_access.cpp ; compile-fail array_fail_array_access.cpp ; -run make_shared_array_test.cpp : : : msvc-8.0:no ; -run make_shared_arrays_test.cpp ; # -fno-deduce-init-list no longer needed for gcc-4.6 -run make_shared_array_throws_test.cpp : : : msvc-8.0:no ; -run make_shared_array_esft_test.cpp : : : msvc-8.0:no ; -run make_shared_array_noinit_test.cpp : : : msvc-8.0:no ; -run make_shared_array_value_test.cpp : : : msvc-8.0:no ; +run make_shared_array_test.cpp + : : : msvc-8.0:no ; +run make_shared_arrays_test.cpp ; +run make_shared_array_throws_test.cpp + : : : msvc-8.0:no ; +run make_shared_array_esft_test.cpp + : : : msvc-8.0:no ; +run make_shared_array_noinit_test.cpp + : : : msvc-8.0:no ; +run make_shared_array_value_test.cpp + : : : msvc-8.0:no ; run allocate_shared_array_test.cpp ; -run allocate_shared_arrays_test.cpp ; # -fno-deduce-init-list no longer needed for gcc-4.6 -run allocate_shared_array_throws_test.cpp : : : msvc-8.0:no ; -run allocate_shared_array_esft_test.cpp : : : msvc-8.0:no ; -run allocate_shared_array_noinit_test.cpp : : : msvc-8.0:no ; -run allocate_shared_array_value_test.cpp : : : msvc-8.0:no ; +run allocate_shared_arrays_test.cpp ; +run allocate_shared_array_throws_test.cpp + : : : msvc-8.0:no ; +run allocate_shared_array_esft_test.cpp + : : : msvc-8.0:no ; +run allocate_shared_array_noinit_test.cpp + : : : msvc-8.0:no ; +run allocate_shared_array_value_test.cpp + : : : msvc-8.0:no ; run allocate_shared_array_construct_test.cpp ; run make_unique_test.cpp ; run make_unique_args_test.cpp ; -run make_unique_value_test.cpp : : : gcc-4.6:-fno-deduce-init-list ; +run make_unique_value_test.cpp + : : : gcc-4.6:-fno-deduce-init-list ; run make_unique_noinit_test.cpp ; run make_unique_throws_test.cpp ; run make_unique_array_test.cpp ; @@ -236,7 +250,8 @@ run shared_ptr_fn_test.cpp ; run get_deleter_test2.cpp ; run get_deleter_test3.cpp ; run get_deleter_array_test2.cpp ; -run get_deleter_array_test3.cpp : : : msvc-8.0:no ; +run get_deleter_array_test3.cpp + : : : msvc-8.0:no ; run sp_convertible_test2.cpp ; @@ -258,13 +273,15 @@ run allocate_local_shared_test.cpp ; run allocate_local_shared_esft_test.cpp ; run make_local_shared_array_test.cpp ; -run make_local_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ; +run make_local_shared_arrays_test.cpp + : : : gcc-4.6.3_0x:-fno-deduce-init-list ; run make_local_shared_array_throws_test.cpp ; run make_local_shared_array_esft_test.cpp ; run make_local_shared_array_noinit_test.cpp ; run make_local_shared_array_value_test.cpp ; run allocate_local_shared_array_test.cpp ; -run allocate_local_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ; +run allocate_local_shared_arrays_test.cpp + : : : gcc-4.6.3_0x:-fno-deduce-init-list ; run allocate_local_shared_array_throws_test.cpp ; run allocate_local_shared_array_esft_test.cpp ; run allocate_local_shared_array_noinit_test.cpp ; @@ -275,9 +292,11 @@ run local_sp_fn_test.cpp ; run lsp_convertible_test.cpp ; run lsp_convertible_test2.cpp ; -run make_shared_array_tmp_test.cpp : : : msvc-8.0:no ; +run make_shared_array_tmp_test.cpp + : : : msvc-8.0:no ; -run lw_thread_test.cpp : : : multi ; +run lw_thread_test.cpp + : : : multi ; compile sp_windows_h_test.cpp ; compile spinlock_windows_h_test.cpp ; diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 0000000..1aa372b --- /dev/null +++ b/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,18 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_subdir_test LANGUAGES CXX) + +find_package(boost_smart_ptr REQUIRED) +find_package(boost_core REQUIRED) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::smart_ptr Boost::core) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index 3e94729..cf11b08 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -2,7 +2,7 @@ # 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 -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.5...3.16) project(cmake_subdir_test LANGUAGES CXX) @@ -11,7 +11,6 @@ add_subdirectory(../../../assert boostorg/assert) add_subdirectory(../../../config boostorg/config) add_subdirectory(../../../core boostorg/core) add_subdirectory(../../../move boostorg/move) -add_subdirectory(../../../predef boostorg/predef) add_subdirectory(../../../static_assert boostorg/static_assert) add_subdirectory(../../../throw_exception boostorg/throw_exception) add_subdirectory(../../../type_traits boostorg/type_traits)