diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..fb708ef08 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,193 @@ +sudo: required +dist: trusty +language: cpp +script: cmake + +matrix: + include: + # OSX + - env: LIBCXX=off STDCXX=c++1y + os: osx + compiler: clang + + # - env: LIBCXX=off STDCXX=c++11 + # os: osx + # compiler: clang + + # - env: LIBCXX=off STDCXX=c++03 + # os: osx + # compiler: clang + + # Clang + - env: CLANG_VERSION=3.5 LIBCXX=off STDCXX=c++14 + os: linux + compiler: clang + addons: &clang + apt: + packages: + - util-linux + - g++-5 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + - env: CLANG_VERSION=3.8 LIBCXX=on STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + - env: CLANG_VERSION=3.8 LIBCXX=off STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + - env: CLANG_VERSION=3.9 LIBCXX=on STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + - env: CLANG_VERSION=3.9 LIBCXX=off STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + - env: CLANG_VERSION=4.0 LIBCXX=on STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + - env: CLANG_VERSION=4.0 LIBCXX=off STDCXX=c++1z + os: linux + compiler: clang + addons: *clang + + # Gcc + - env: GCC_VERSION=6 LIBCXX=off STDCXX=gnu++1y + os: linux + compiler: gcc-6 + addons: &gcc6 + apt: + packages: + - g++-6 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + - env: GCC_VERSION=5 LIBCXX=off STDCXX=gnu++1y + os: linux + compiler: gcc-5 + addons: &gcc5 + apt: + packages: + - g++-5 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + - env: GCC_VERSION=4.9 LIBCXX=off STDCXX=gnu++1y + os: linux + compiler: gcc-4.9 + addons: &gcc49 + apt: + packages: + - g++-4.9 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + - env: GCC_VERSION=4.8 LIBCXX=off STDCXX=gnu++11 + os: linux + compiler: gcc-4.8 + addons: &gcc48 + apt: + packages: + - g++-4.8 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + + - env: GCC_VERSION=4.7 LIBCXX=off STDCXX=gnu++0x + os: linux + compiler: gcc-4.7 + addons: &gcc47 + apt: + packages: + - g++-4.7 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + + - env: GCC_VERSION=4.6 LIBCXX=off STDCXX=gnu++0x + os: linux + compiler: gcc-4.6 + addons: &gcc46 + apt: + packages: + - g++-4.6 + - valgrind + - python-pip + sources: + - ubuntu-toolchain-r-test + +cache: + directories: + - $HOME/.config/cget + +install: + - export CHECKOUT_PATH=`pwd`; + # Setup deps directory + - export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - export CGET_PREFIX="${DEPS_DIR}/usr" + - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} + - mkdir usr + - export PATH=${DEPS_DIR}/usr/bin:${PATH} + # Install cget + - pip install cget + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + pip install backports.lzma + cget install pfultz2/cget-travis-recipes + cget install cmake-3.3 + if [ -n "$CLANG_VERSION" ]; then + cget install clang-${CLANG_VERSION} + export CXX="clang++" + export CC="clang" + fi + if [ -n "$GCC_VERSION" ]; then + export CXX="g++-${GCC_VERSION}" + export CC="gcc-${GCC_VERSION}" + fi + fi + # Show compiler info + - $CXX --version + - which $CXX + - $CC --version + - which $CC + - which cmake + - cmake --version + # Use libc++ + - | + if [[ "$LIBCXX" == "on" ]]; then + export LDFLAGS="-L${DEPS_DIR}/usr/lib -lc++ -lc++abi" + export CFLAGS="${CFLAGS} -stdlib=libc++ -I${DEPS_DIR}/usr/include/c++/v1" + export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -I${DEPS_DIR}/usr/include/c++/v1" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${DEPS_DIR}/usr/lib" + fi + # Add stdflags + export CXXFLAGS="${CXXFLAGS} -std=${STDCXX}" + + +script: + - cd $CHECKOUT_PATH + - | + for build_type in debug release; do + cget install boostorg/config,. -DCMAKE_BUILD_TYPE=$build_type --test + cget rm boostorg/config -y + done diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..afd7095da --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 3.5) +project(boost_config) + +enable_language(C) +enable_language(CXX) + +find_package(BCM) +include(BCMDeploy) +include(BCMSetupVersion) + +bcm_setup_version(VERSION 1.61.0) + +add_library(boost_config INTERFACE) +set_property(TARGET boost_config PROPERTY EXPORT_NAME config) + +bcm_deploy(TARGETS boost_config INCLUDE include NAMESPACE boost::) + +add_subdirectory(test) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..bcd4621c4 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,52 @@ + +os: Visual Studio 2015 + +environment: + matrix: + # - GENERATOR: "Visual Studio 14 2015 Win64" + # CONFIG: Debug + + # - GENERATOR: "Visual Studio 14 2015 Win64" + # CONFIG: Release + + - GENERATOR: "Visual Studio 14 2015" + CONFIG: Debug + + - GENERATOR: "Visual Studio 14 2015" + CONFIG: Release + + - GENERATOR: "Visual Studio 12 2013" + CONFIG: Debug + + - GENERATOR: "Visual Studio 12 2013" + CONFIG: Release + + - GENERATOR: "Visual Studio 11 2012" + CONFIG: Debug + + - GENERATOR: "Visual Studio 11 2012" + CONFIG: Release + + - GENERATOR: "Visual Studio 10 2010" + CONFIG: Debug + + - GENERATOR: "Visual Studio 10 2010" + CONFIG: Release + +matrix: + fast_finish: false + +install: + - ps: Invoke-WebRequest "https://bootstrap.pypa.io/ez_setup.py" -OutFile "c:\\ez_setup.py" + - ps: Invoke-WebRequest "https://bootstrap.pypa.io/get-pip.py" -OutFile "c:\\get-pip.py" + - "c:\\Python34\\python c:\\ez_setup.py" + - "c:\\Python34\\python c:\\get-pip.py" + - "c:\\Python34\\Scripts\\pip install https://github.com/pfultz2/cget/archive/master.zip" + +build_script: + - cmd: set PATH=C:\Program Files (x86)\CMake\bin;%PATH% + - cmd: set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% + - cmd: set PATH=c:\cget\bin;c:\Python34\Scripts\;%PATH% + - cmd: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" + - cmd: cmake --version + - cmd: cget -p c:\cget build -G "%GENERATOR%" --test --verbose diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..d24939da7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +boost-cmake/bcm@master --build diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..125db78b3 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,75 @@ + +include(BCMTest) +include(BCMProperties) + +bcm_test_link_libraries(boost_config) + +find_package(Threads) +add_library(config_threads INTERFACE) +target_link_libraries(config_threads INTERFACE "${CMAKE_THREAD_LIBS_INIT}") +set(LIBS_TO_CHECK atomic rt) +foreach(lib ${LIBS_TO_CHECK}) + find_library(FIND_LIB${lib} ${lib}) + if(FIND_LIB${lib}) + target_link_libraries(config_threads INTERFACE "${FIND_LIB${lib}}") + endif() +endforeach() +string(STRIP "${THREADED_LIBS}" THREADED_LIBS) +message(STATUS "Threaded libs: ${THREADED_LIBS}") +include_directories(.) + +include(TestGen.cmake) + +set(SKIP_TESTS + boost_has_macro_use_facet.ipp + boost_no_com_value_init.ipp + boost_no_cxx11_addressof.ipp + boost_no_cxx11_hdr_atomic.ipp + boost_no_cxx11_hdr_codecvt.ipp + boost_no_cxx11_hdr_tuple.ipp + boost_no_cxx11_std_align.ipp + boost_no_cxx11_trailing_result_types.ipp + boost_no_decltype_n3276.ipp + boost_no_ded_typename.ipp + boost_no_sfinae_expr.ipp + boost_no_two_phase_lookup.ipp +) +file(GLOB TESTS *.ipp) +foreach(TEST ${TESTS}) + if(NOT "${TEST}" IN_LIST SKIP_TESTS) + parse_test(${TEST}) + endif() +endforeach() + +bcm_test(NAME config_test_c SOURCES config_test_c.c) +bcm_test(NAME config_info SOURCES config_info.cpp) + +bcm_test(NAME config_test SOURCES config_test.cpp) +bcm_test(NAME config_test_no_rtti SOURCES config_test.cpp) +set_target_properties(config_test_no_rtti PROPERTIES CXX_RTTI Off) +bcm_test(NAME config_test_no_exceptions SOURCES config_test.cpp) +set_target_properties(config_test_no_exceptions PROPERTIES CXX_EXCEPTIONS Off) + +foreach(CONFIG_TEST config_test config_test_no_rtti config_test_no_exceptions) + target_link_libraries(${CONFIG_TEST} config_threads) +endforeach() + +bcm_test(NAME test_thread_fail1 SOURCES threads/test_thread_fail1.cpp COMPILE_ONLY WILL_FAIL) +bcm_test(NAME test_thread_fail2 SOURCES threads/test_thread_fail2.cpp COMPILE_ONLY WILL_FAIL) + +bcm_test(NAME abi_test SOURCES abi/abi_test.cpp abi/main.cpp) +bcm_test(NAME limits_test SOURCES limits_test.cpp) +bcm_test(NAME math_info SOURCES math_info.cpp) + +include(CheckCXXCompilerFlag) +set(IMPLICIT_FALLTHROUGH_FLAG "-std=c++11 -Wimplicit-fallthrough -Wall -Werror") +check_cxx_compiler_flag(${IMPLICIT_FALLTHROUGH_FLAG} HAS_IMPLICIT_FALLTHROUGH) +bcm_test(NAME boost_fallthrough_test SOURCES boost_fallthrough_test.cpp COMPILE_ONLY) +if(HAS_IMPLICIT_FALLTHROUGH) + target_compile_options(boost_fallthrough_test ${IMPLICIT_FALLTHROUGH_FLAG}) +endif(HAS_IMPLICIT_FALLTHROUGH) +bcm_test(NAME helper_macro_test SOURCES helper_macro_test.cpp COMPILE_ONLY) + +bcm_test(NAME cstdint_include_test SOURCES cstdint_include_test.cpp COMPILE_ONLY) + + diff --git a/test/TestGen.cmake b/test/TestGen.cmake new file mode 100644 index 000000000..c64f7a281 --- /dev/null +++ b/test/TestGen.cmake @@ -0,0 +1,52 @@ +# +# Functions to create tests from the .ipp files +# +function(create_test BOOST_CONFIG_MACRO BOOST_CONFIG_FILE POSITIVE_TEST EXPECT_SUCCESS) + string(TOLOWER ${BOOST_CONFIG_MACRO} BOOST_CONFIG_NS) + if(${POSITIVE_TEST} EQUAL ${EXPECT_SUCCESS}) + set(BOOST_CONFIG_IFDEF "#ifdef") + else() + set(BOOST_CONFIG_IFDEF "#ifndef") + endif() + + if(BOOST_CONFIG_MACRO MATCHES "BOOST_HAS_TR1.*") + set(BOOST_CONFIG_TR1_INCLUDE "#include ") + else() + set(BOOST_CONFIG_TR1_INCLUDE "") + endif() + + if(${EXPECT_SUCCESS}) + configure_file(pass.cpp ${BOOST_CONFIG_FILE}_pass.cpp) + bcm_test(NAME ${BOOST_CONFIG_FILE}_pass SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${BOOST_CONFIG_FILE}_pass.cpp) + target_link_libraries(${BOOST_CONFIG_FILE}_pass config_threads) + else() + configure_file(fail.cpp ${BOOST_CONFIG_FILE}_fail.cpp) + bcm_test(NAME ${BOOST_CONFIG_FILE}_fail SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${BOOST_CONFIG_FILE}_fail.cpp COMPILE_ONLY WILL_FAIL) + if(MSVC) + target_compile_options(${BOOST_CONFIG_FILE}_fail PUBLIC /WX) + else() + target_compile_options(${BOOST_CONFIG_FILE}_fail PUBLIC -Werror -Wall) + endif() + endif() +endfunction() + +function(parse_test SRC) + if(SRC MATCHES "boost_has_tr1.*") + # Skip tr1 tests for now + return() + endif() + set(MACRO_REGEX "//[ ]*MACRO[ ]*:[ ]*([A-Za-z0-9_]+)") + file(STRINGS ${SRC} SRC_MACRO_LINE REGEX ${MACRO_REGEX}) + string(REGEX REPLACE ${MACRO_REGEX} "\\1" BOOST_CONFIG_MACRO ${SRC_MACRO_LINE}) + get_filename_component(BOOST_CONFIG_FILE ${SRC} NAME_WE) + + if(SRC MATCHES "boost_no_") + set(POSITIVE_TEST 0) + else() + set(POSITIVE_TEST 1) + endif() + + create_test(${BOOST_CONFIG_MACRO} ${BOOST_CONFIG_FILE} ${POSITIVE_TEST} 1) + create_test(${BOOST_CONFIG_MACRO} ${BOOST_CONFIG_FILE} ${POSITIVE_TEST} 0) + +endfunction() diff --git a/test/fail.cpp b/test/fail.cpp new file mode 100644 index 000000000..ee4a02eda --- /dev/null +++ b/test/fail.cpp @@ -0,0 +1,18 @@ +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" +@BOOST_CONFIG_TR1_INCLUDE@ + +@BOOST_CONFIG_IFDEF@ @BOOST_CONFIG_MACRO@ +#include "@BOOST_CONFIG_FILE@.ipp" +#else +#error "this file should not compile" +#endif + +int main( int, char *[] ) +{ + return @BOOST_CONFIG_NS@::test(); +} diff --git a/test/limits_test.cpp b/test/limits_test.cpp index 62444965d..3586966ee 100644 --- a/test/limits_test.cpp +++ b/test/limits_test.cpp @@ -9,10 +9,19 @@ */ #include -#include -#include #include +namespace boost { namespace config_test { + +inline void fail(bool b) +{ + if (!b) std::abort(); +} + +}} + +#define BOOST_TEST(x) boost::config_test::fail(x) + /* * General portability note: * MSVC mis-compiles explicit function template instantiations. @@ -172,7 +181,7 @@ void test_float_limits(const T &, const char * msg) } -int cpp_main(int, char*[]) +int main(int, char*[]) { test_integral_limits(bool(), "bool"); test_integral_limits(char(), "char"); diff --git a/test/math_info.cpp b/test/math_info.cpp index 47fe9ffe4..49f3074d7 100644 --- a/test/math_info.cpp +++ b/test/math_info.cpp @@ -14,6 +14,7 @@ // #include +#include #include #include #include @@ -21,7 +22,9 @@ #include #include #include -#include +#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS +#include +#endif #ifdef BOOST_NO_STDC_NAMESPACE namespace std{ using ::strcmp; using ::pow; using ::fabs; using ::sqrt; using ::sin; using ::atan2; } @@ -155,8 +158,10 @@ void print_limits(T, const char* name) } std::cout << " sizeof(" << name << ") = " << sizeof(T) << std::endl; +#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS std::cout << - " alignment_of<" << name << "> = " << boost::alignment_of::value << std::endl << std::endl; + " alignment_of<" << name << "> = " << std::alignment_of::value << std::endl; +#endif } /* template diff --git a/test/pass.cpp b/test/pass.cpp new file mode 100644 index 000000000..ad3813028 --- /dev/null +++ b/test/pass.cpp @@ -0,0 +1,18 @@ +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" +@BOOST_CONFIG_TR1_INCLUDE@ + +@BOOST_CONFIG_IFDEF@ @BOOST_CONFIG_MACRO@ +#include "@BOOST_CONFIG_FILE@.ipp" +#else +namespace @BOOST_CONFIG_NS@ = empty_boost; +#endif + +int main( int, char *[] ) +{ + return @BOOST_CONFIG_NS@::test(); +}