Skip to content

Commit

Permalink
Add CMake install support, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 5, 2020
1 parent 816c759 commit 3a50c15
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 40 deletions.
28 changes: 27 additions & 1 deletion .travis.yml
Expand Up @@ -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 ..
Expand Down
30 changes: 20 additions & 10 deletions CMakeLists.txt
Expand Up @@ -2,22 +2,32 @@
# 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)

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 changes: 11 additions & 0 deletions 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.v2 LINK_LIBRARIES Boost::endian Boost::core)

endif()
57 changes: 35 additions & 22 deletions test/Jamfile.v2
Expand Up @@ -28,23 +28,24 @@ project
<toolset>clang:<warnings-as-errors>on
;

local rule endian-run ( sources + )
local rule run-ni ( sources + )
{
local result ;
return [ run $(sources) : : : <define>BOOST_ENDIAN_NO_INTRINSICS : $(sources[1]:B)_ni ] ;
}

result += [ run $(sources) ] ;
result += [ run $(sources) : : : <define>BOOST_ENDIAN_NO_INTRINSICS : $(sources[1]:B)_ni ] ;
run buffer_test.cpp ;
run-ni buffer_test.cpp ;

return $(result) ;
}
run endian_test.cpp ;
run-ni endian_test.cpp ;

endian-run buffer_test.cpp ;
endian-run endian_test.cpp ;
endian-run endian_operations_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 ;

Expand All @@ -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) ;

run endian_reverse_test.cpp ;
run-ni endian_reverse_test.cpp ;

endian-run endian_reverse_test.cpp ;
run endian_load_test.cpp ;
run-ni endian_load_test.cpp ;

endian-run endian_load_test.cpp ;
endian-run endian_store_test.cpp ;
endian-run endian_ld_st_roundtrip_test.cpp ;
run endian_store_test.cpp ;
run-ni endian_store_test.cpp ;

endian-run endian_arithmetic_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 ;

run store_convenience_test.cpp ;
run-ni store_convenience_test.cpp ;

endian-run float_typedef_test.cpp ;
run float_typedef_test.cpp ;
run-ni float_typedef_test.cpp ;

endian-run data_test.cpp ;
run data_test.cpp ;
run-ni data_test.cpp ;

endian-run endian_hpp_test.cpp ;
run endian_hpp_test.cpp ;
run-ni endian_hpp_test.cpp ;

run order_test.cpp ;
14 changes: 13 additions & 1 deletion test/buffer_test.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
18 changes: 18 additions & 0 deletions 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_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>)
3 changes: 1 addition & 2 deletions test/cmake_subdir_test/CMakeLists.txt
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
14 changes: 13 additions & 1 deletion test/conversion_test.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
14 changes: 13 additions & 1 deletion test/deprecated_test.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
14 changes: 13 additions & 1 deletion test/endian_operations_test.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
}
}
14 changes: 13 additions & 1 deletion test/endian_test.cpp
Expand Up @@ -20,7 +20,6 @@

#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/detail/lightweight_main.hpp>

#include <iostream>
#include <limits>
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 3a50c15

Please sign in to comment.