diff --git a/.travis.yml b/.travis.yml index bb92cb3..73a2afe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -240,6 +240,15 @@ matrix: compiler: clang++ env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + - os: linux + compiler: g++ + env: CMAKE_SUBDIR_TEST=1 + script: + - cd libs/variant2/test/cmake_subdir_test && mkdir __build__ && cd __build__ + - cmake .. + - 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 new file mode 100644 index 0000000..88ed21d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# 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) + +project(BoostVariant2 LANGUAGES CXX) + +add_library(boost_variant2 INTERFACE) +add_library(Boost::variant2 ALIAS boost_variant2) + +target_include_directories(boost_variant2 INTERFACE include) + +target_link_libraries(boost_variant2 + INTERFACE + Boost::config + Boost::mp11 +) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 0000000..90fd014 --- /dev/null +++ b/test/cmake_subdir_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 + +cmake_minimum_required(VERSION 3.5) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/variant2) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../mp11 boostorg/mp11) + +add_executable(quick quick.cpp) +target_link_libraries(quick Boost::variant2) + +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/quick.cpp b/test/cmake_subdir_test/quick.cpp new file mode 100644 index 0000000..e16c563 --- /dev/null +++ b/test/cmake_subdir_test/quick.cpp @@ -0,0 +1,15 @@ + +// Copyright 2019 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include + +using namespace boost::variant2; + +int main() +{ + variant v( 2 ); + return get<1>( v ) == 2; +}