From 754be04f114513914a3f8f8e5f46a1c7a5876292 Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Fri, 5 Feb 2016 14:33:56 +0100 Subject: [PATCH 1/7] state that sudo is required for CI This informs travis that the container-based build environment can not be used. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cbff7e597743..66bc413def31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: cpp +sudo: required # the doc target uses sudo to install dependencies os: - linux From 8c8877df5a648a231619fb9b524c897895f689ff Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Fri, 5 Feb 2016 15:27:49 +0100 Subject: [PATCH 2/7] treat format.cc like a header Given that it is required for header only builds it has to be installed too. --- cppformat/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cppformat/CMakeLists.txt b/cppformat/CMakeLists.txt index b33875bcdf99..e895b5decd3c 100644 --- a/cppformat/CMakeLists.txt +++ b/cppformat/CMakeLists.txt @@ -1,7 +1,6 @@ #------------------------------------------------------------------------------ # define the cppformat library, its includes and the needed defines -set(FMT_HEADERS format.h) -set(FMT_SOURCES format.cc) +set(FMT_HEADERS format.h format.cc) if (HAVE_OPEN) set(FMT_HEADERS ${FMT_HEADERS} posix.h) set(FMT_SOURCES ${FMT_SOURCES} posix.cc) From 6a79a3279bbc61e395fc4a6209c190c4074d703b Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Sun, 7 Feb 2016 18:23:02 +0100 Subject: [PATCH 3/7] build and test in c++11 and in c++98 mode --- .travis.yml | 6 ++-- CMakeLists.txt | 1 + cppformat/CMakeLists.txt | 4 ++- support/cmake/testCxx11.cmake | 4 ++- support/travis-build.py | 57 +++++++++++++++++++++++++++++++++-- test/CMakeLists.txt | 16 ++-------- 6 files changed, 69 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66bc413def31..be1f48d5ffed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,10 @@ env: 6pxmyzLHSn1ZR7OX5rfPvwM3tOyZ3H0= matrix: - BUILD=Doc - - BUILD=Debug - - BUILD=Release + - BUILD=Debug STANDARD=98 + - BUILD=Debug STANDARD=11 + - BUILD=Release STANDARD=98 + - BUILD=Release STANDARD=11 matrix: exclude: diff --git a/CMakeLists.txt b/CMakeLists.txt index 418048b8010d..ab58c67a7943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF) option(FMT_DOC "Generate the doc target." ${MASTER_PROJECT}) option(FMT_INSTALL "Generate the install target." ${MASTER_PROJECT}) option(FMT_TEST "Generate the test target." ${MASTER_PROJECT}) +option(FMT_USE_CPP11 "Enable the addition of c++11 compiler flags." ${MASTER_PROJECT}) project(FORMAT) diff --git a/cppformat/CMakeLists.txt b/cppformat/CMakeLists.txt index e895b5decd3c..576757045531 100644 --- a/cppformat/CMakeLists.txt +++ b/cppformat/CMakeLists.txt @@ -8,7 +8,9 @@ endif () add_library(cppformat ${FMT_SOURCES} ${FMT_HEADERS}) -target_compile_options(cppformat PUBLIC ${CPP11_FLAG}) # starting with cmake 3.1 the CXX_STANDARD property can be used +if (FMT_USE_CPP11) + target_compile_options(cppformat PUBLIC ${CPP11_FLAG}) # starting with cmake 3.1 the CXX_STANDARD property can be used +endif () if (FMT_PEDANTIC) target_compile_options(cppformat PRIVATE ${PEDANTIC_COMPILE_FLAGS}) endif () diff --git a/support/cmake/testCxx11.cmake b/support/cmake/testCxx11.cmake index 592147d0cce8..d49ae6d014ca 100644 --- a/support/cmake/testCxx11.cmake +++ b/support/cmake/testCxx11.cmake @@ -29,8 +29,10 @@ else () endif () endif () +if (FMT_USE_CPP11) + set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG}) +endif () -set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG}) # Check if variadic templates are working and not affected by GCC bug 39653: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653 check_cxx_source_compiles(" diff --git a/support/travis-build.py b/support/travis-build.py index dd74ed6655c8..19ff41c993d2 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -12,6 +12,13 @@ def rmtree_if_exists(dir): if e.errno == errno.ENOENT: pass +def makedirs_if_not_exist(dir): + try: + os.makedirs(dir) + except OSError as e: + if e.errno != errno.EEXIST: + raise + build = os.environ['BUILD'] if build == 'Doc': travis = 'TRAVIS' in os.environ @@ -67,11 +74,57 @@ def rmtree_if_exists(dir): raise CalledProcessError(p.returncode, cmd) exit(0) -check_call(['git', 'submodule', 'update', '--init']) -check_call(['cmake', '-DCMAKE_BUILD_TYPE=' + build, '-DFMT_PEDANTIC=ON', '.']) +cppStandard = os.environ['STANDARD'] +srcDir = os.getcwd() +srcDir_test = os.path.join(srcDir,"test","find-package-test") + +installDir = os.path.join(srcDir,"_install") +buildDir = os.path.join(srcDir,"_build") +buildDir_test = os.path.join(srcDir,"_build_test") + +# configure library +makedirs_if_not_exist(buildDir) +os.chdir(buildDir) +if cppStandard == '98': + check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + '-DCMAKE_CXX_FLAGS=-std=c++98', + '-DFMT_USE_CPP11=OFF', + '-DFMT_DOC=OFF', + '-DFMT_PEDANTIC=ON', + srcDir]) +else: + # default configuration + check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + '-DFMT_DOC=OFF', + '-DFMT_PEDANTIC=ON', + srcDir]) + +# build library check_call(['make', '-j4']) + +# test library env = os.environ.copy() env['CTEST_OUTPUT_ON_FAILURE'] = '1' if call(['make', 'test'], env=env): with open('Testing/Temporary/LastTest.log', 'r') as f: print(f.read()) + sys.exit(-1) + +# install library +check_call(['make', 'install']) + +# test installation +makedirs_if_not_exist(buildDir_test) +os.chdir(buildDir_test) +if cppStandard == '98': + check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + '-DCMAKE_CXX_FLAGS=-std=c++98', + srcDir_test]) +else: + check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + srcDir_test]) +check_call(['make', '-j4']) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 10e753fc8d27..2bbe5057ec1b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,7 +10,9 @@ add_library(gmock STATIC ${FMT_GMOCK_DIR}/gmock-gtest-all.cc ${FMT_GMOCK_DIR}/gmock/gmock.h ${FMT_GMOCK_DIR}/gtest/gtest.h ${FMT_GMOCK_DIR}/gtest/gtest-spi.h) target_include_directories(gmock PUBLIC ${FMT_GMOCK_DIR}) -target_compile_options(gmock PUBLIC ${CPP11_FLAG}) +if (FMT_USE_CPP11) + target_compile_options(gmock PUBLIC ${CPP11_FLAG}) +endif () find_package(Threads) if (Threads_FOUND) @@ -112,18 +114,6 @@ if (HAVE_FNO_EXCEPTIONS_FLAG) endif () if (FMT_PEDANTIC) - # syntax test which checks if the library builds in gnu++98 mode - file(GLOB test_src *.cc *.h) - file(GLOB lib_src ../cppformat/*.cc ../cppformat/*.h) - add_library(testformat STATIC ${test_src} ${lib_src}) - target_include_directories(testformat PRIVATE .. ../gmock) - target_compile_definitions(testformat PRIVATE - FMT_USE_FILE_DESCRIPTORS=$) - check_cxx_compiler_flag(-std=gnu++98 HAVE_STD_GNUPP98_FLAG) - if (HAVE_STD_GNUPP98_FLAG) - target_compile_options(testformat PRIVATE -std=gnu++98) - endif () - # Test that the library compiles without windows.h. if (CMAKE_SYSTEM_NAME STREQUAL "Windows") add_library(no-windows-h-test ../cppformat/format.cc) From 27a1b787c88355211dd85402ab466268f71adcbd Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Sun, 7 Feb 2016 18:32:23 +0100 Subject: [PATCH 4/7] test in c++ 98, 03 and 11 mode --- .travis.yml | 2 +- support/travis-build.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index be1f48d5ffed..0af0f167cf16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,9 @@ env: 6pxmyzLHSn1ZR7OX5rfPvwM3tOyZ3H0= matrix: - BUILD=Doc - - BUILD=Debug STANDARD=98 - BUILD=Debug STANDARD=11 - BUILD=Release STANDARD=98 + - BUILD=Release STANDARD=03 - BUILD=Release STANDARD=11 matrix: diff --git a/support/travis-build.py b/support/travis-build.py index 19ff41c993d2..1997f99dfa02 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -93,6 +93,14 @@ def makedirs_if_not_exist(dir): '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', srcDir]) +if cppStandard == '03': + check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + '-DCMAKE_CXX_FLAGS=-std=c++03', + '-DFMT_USE_CPP11=OFF', + '-DFMT_DOC=OFF', + '-DFMT_PEDANTIC=ON', + srcDir]) else: # default configuration check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, @@ -118,13 +126,8 @@ def makedirs_if_not_exist(dir): # test installation makedirs_if_not_exist(buildDir_test) os.chdir(buildDir_test) -if cppStandard == '98': - check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, - '-DCMAKE_BUILD_TYPE=' + build, - '-DCMAKE_CXX_FLAGS=-std=c++98', - srcDir_test]) -else: - check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, - '-DCMAKE_BUILD_TYPE=' + build, - srcDir_test]) +check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, + '-DCMAKE_BUILD_TYPE=' + build, + '-DCMAKE_CXX_FLAGS=-std=c++' + cppStandard, + srcDir_test]) check_call(['make', '-j4']) \ No newline at end of file From f9616835162906efc80d51f9b534f790e445941b Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Sun, 7 Feb 2016 18:41:46 +0100 Subject: [PATCH 5/7] specify c++11 as c++0x for travis --- .travis.yml | 4 ++-- support/travis-build.py | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0af0f167cf16..9a97e51bade4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ env: 6pxmyzLHSn1ZR7OX5rfPvwM3tOyZ3H0= matrix: - BUILD=Doc - - BUILD=Debug STANDARD=11 + - BUILD=Debug STANDARD=0x - BUILD=Release STANDARD=98 - BUILD=Release STANDARD=03 - - BUILD=Release STANDARD=11 + - BUILD=Release STANDARD=0x matrix: exclude: diff --git a/support/travis-build.py b/support/travis-build.py index 1997f99dfa02..8888198bea04 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -85,29 +85,23 @@ def makedirs_if_not_exist(dir): # configure library makedirs_if_not_exist(buildDir) os.chdir(buildDir) -if cppStandard == '98': +if cppStandard == '0x': + # default configuration check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, '-DCMAKE_BUILD_TYPE=' + build, - '-DCMAKE_CXX_FLAGS=-std=c++98', - '-DFMT_USE_CPP11=OFF', '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', srcDir]) -if cppStandard == '03': +else: check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, '-DCMAKE_BUILD_TYPE=' + build, - '-DCMAKE_CXX_FLAGS=-std=c++03', + '-DCMAKE_CXX_FLAGS=-std=c++' + cppStandard, '-DFMT_USE_CPP11=OFF', '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', srcDir]) else: - # default configuration - check_call(['cmake', '-DCMAKE_INSTALL_PREFIX='+installDir, - '-DCMAKE_BUILD_TYPE=' + build, - '-DFMT_DOC=OFF', - '-DFMT_PEDANTIC=ON', - srcDir]) + # build library check_call(['make', '-j4']) From 016af73d19180c12849d29f2ee655d07ec937d80 Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Sun, 7 Feb 2016 18:47:39 +0100 Subject: [PATCH 6/7] fixed typo in script --- support/travis-build.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/support/travis-build.py b/support/travis-build.py index 8888198bea04..65632a6e31ab 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -100,8 +100,6 @@ def makedirs_if_not_exist(dir): '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', srcDir]) -else: - # build library check_call(['make', '-j4']) From c57f8f563b0e8fa41b7229550a850db008080081 Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Tue, 9 Feb 2016 09:08:11 +0100 Subject: [PATCH 7/7] omit the c++ 2003 tests --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a97e51bade4..89b359094666 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ env: - BUILD=Doc - BUILD=Debug STANDARD=0x - BUILD=Release STANDARD=98 - - BUILD=Release STANDARD=03 - BUILD=Release STANDARD=0x matrix: