Add CMake install support, tests

This commit is contained in:
Peter Dimov
2020-01-05 03:29:05 +02:00
parent 816c7597e3
commit 3a50c15a97
11 changed files with 178 additions and 41 deletions

View File

@ -330,15 +330,41 @@ matrix:
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=endian ..
- ctest --output-on-failure -R boost_endian
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH https://github.com/boostorg/static_assert.git ../static_assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/type_traits.git ../type_traits
script:
- cd libs/endian/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- 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="assert;config;core;endian;static_assert;type_traits" -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/endian/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 ..

View File

@ -2,11 +2,9 @@
# 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(BoostEndian LANGUAGES CXX)
project(boost_endian VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_endian INTERFACE)
add_library(Boost::endian ALIAS boost_endian)
@ -14,10 +12,22 @@ add_library(Boost::endian ALIAS boost_endian)
target_include_directories(boost_endian INTERFACE include)
target_link_libraries(boost_endian
INTERFACE
Boost::config
Boost::core
Boost::predef
Boost::static_assert
Boost::type_traits
INTERFACE
Boost::config
Boost::core
Boost::static_assert
Boost::type_traits
)
if(BOOST_SUPERPROJECT_VERSION)
include(BoostInstall)
boost_install(TARGETS boost_endian HEADER_DIRECTORY include/)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

11
test/CMakeLists.txt Normal file
View File

@ -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.v2 LINK_LIBRARIES Boost::endian Boost::core)
endif()

View File

@ -28,23 +28,24 @@ project
<toolset>clang:<warnings-as-errors>on
;
local rule endian-run ( sources + )
local rule run-ni ( sources + )
{
local result ;
result += [ run $(sources) ] ;
result += [ run $(sources) : : : <define>BOOST_ENDIAN_NO_INTRINSICS : $(sources[1]:B)_ni ] ;
return $(result) ;
return [ run $(sources) : : : <define>BOOST_ENDIAN_NO_INTRINSICS : $(sources[1]:B)_ni ] ;
}
endian-run buffer_test.cpp ;
endian-run endian_test.cpp ;
endian-run endian_operations_test.cpp ;
run buffer_test.cpp ;
run-ni buffer_test.cpp ;
run endian_test.cpp ;
run-ni endian_test.cpp ;
run endian_operations_test.cpp ;
run-ni endian_operations_test.cpp ;
run endian_in_union_test.cpp ;
endian-run conversion_test.cpp ;
run conversion_test.cpp ;
run-ni conversion_test.cpp ;
run intrinsic_test.cpp ;
@ -55,29 +56,41 @@ local allow-warnings =
"-<toolset>gcc:<warnings-as-errors>on"
"-<toolset>clang:<warnings-as-errors>on" ;
compile spirit_conflict_test.cpp
: $(allow-warnings) ;
compile spirit_conflict_test.cpp : $(allow-warnings) ;
endian-run endian_reverse_test.cpp ;
run endian_reverse_test.cpp ;
run-ni endian_reverse_test.cpp ;
endian-run endian_load_test.cpp ;
endian-run endian_store_test.cpp ;
endian-run endian_ld_st_roundtrip_test.cpp ;
run endian_load_test.cpp ;
run-ni endian_load_test.cpp ;
endian-run endian_arithmetic_test.cpp ;
run endian_store_test.cpp ;
run-ni endian_store_test.cpp ;
run endian_ld_st_roundtrip_test.cpp ;
run-ni endian_ld_st_roundtrip_test.cpp ;
run endian_arithmetic_test.cpp ;
run-ni endian_arithmetic_test.cpp ;
run deprecated_test.cpp ;
compile endian_reverse_cx_test.cpp ;
compile endian_reverse_cx_test.cpp : <define>BOOST_ENDIAN_NO_INTRINSICS : endian_reverse_cx_test_ni ;
endian-run load_convenience_test.cpp ;
endian-run store_convenience_test.cpp ;
run load_convenience_test.cpp ;
run-ni load_convenience_test.cpp ;
endian-run float_typedef_test.cpp ;
run store_convenience_test.cpp ;
run-ni store_convenience_test.cpp ;
endian-run data_test.cpp ;
run float_typedef_test.cpp ;
run-ni float_typedef_test.cpp ;
endian-run endian_hpp_test.cpp ;
run data_test.cpp ;
run-ni data_test.cpp ;
run endian_hpp_test.cpp ;
run-ni endian_hpp_test.cpp ;
run order_test.cpp ;

View File

@ -12,7 +12,6 @@
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
@ -322,4 +321,17 @@ int cpp_main(int, char *[])
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@ -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_install_test LANGUAGES CXX)
find_package(boost_endian REQUIRED)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::endian Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -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)
@ -20,7 +20,6 @@ endfunction()
boost_add_subdir(config)
boost_add_subdir(core)
boost_add_subdir(predef)
boost_add_subdir(static_assert)
boost_add_subdir(type_traits)

View File

@ -10,7 +10,6 @@
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <cstring>
@ -376,4 +375,17 @@ int cpp_main(int, char * [])
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@ -13,7 +13,6 @@
#define BOOST_ENDIAN_DEPRECATED_NAMES
#include <boost/endian/endian.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
@ -181,4 +180,17 @@ int cpp_main(int, char *[])
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@ -29,7 +29,6 @@
#include <boost/endian/arithmetic.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/cstdint.hpp>
#include <cassert>
#include <iostream>
@ -489,3 +488,16 @@ int cpp_main(int, char * [])
return boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}

View File

@ -20,7 +20,6 @@
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <iostream>
#include <limits>
@ -838,3 +837,16 @@ int cpp_main( int argc, char * argv[] )
return err_count ? 1 : 0;
} // main
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
std::cout << "Exception: " << x.what() << std::endl;
return 1;
}
}