From 13b8bdc2b51805c3ccd666a511ae092784b1c20e Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 1 May 2019 09:06:12 +0100 Subject: [PATCH] Bump required cmake version from 2.x to 3.x (#801) --- .travis.yml | 46 ++++++++++++++++++++++++++++++++++------------ CMakeLists.txt | 2 +- README.md | 3 +++ dependencies.md | 18 ++++++++++++++++++ src/CMakeLists.txt | 6 ++++++ 5 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 dependencies.md diff --git a/.travis.yml b/.travis.yml index 51d652cf..6b6cfc70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,25 @@ matrix: apt: packages: - g++-multilib - env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Debug BUILD_32_BITS=ON + - libc6:i386 + env: + - COMPILER=g++ + - C_COMPILER=gcc + - BUILD_TYPE=Debug + - BUILD_32_BITS=ON + - EXTRA_FLAGS="-m32" - compiler: gcc addons: apt: packages: - g++-multilib - env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Release BUILD_32_BITS=ON + - libc6:i386 + env: + - COMPILER=g++ + - C_COMPILER=gcc + - BUILD_TYPE=Release + - BUILD_32_BITS=ON + - EXTRA_FLAGS="-m32" - compiler: gcc env: - INSTALL_GCC6_FROM_PPA=1 @@ -51,7 +63,7 @@ matrix: - INSTALL_GCC6_FROM_PPA=1 - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - LIBCXX_BUILD=1 - - EXTRA_FLAGS="-stdlib=libc++" + - EXTRA_CXX_FLAGS="-stdlib=libc++" - compiler: clang dist: xenial addons: @@ -62,7 +74,7 @@ matrix: - INSTALL_GCC6_FROM_PPA=1 - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release - LIBCXX_BUILD=1 - - EXTRA_FLAGS="-stdlib=libc++" + - EXTRA_CXX_FLAGS="-stdlib=libc++" # Clang w/ 32bit libc++ - compiler: clang dist: xenial @@ -71,12 +83,14 @@ matrix: packages: - clang-3.8 - g++-multilib + - libc6:i386 env: - INSTALL_GCC6_FROM_PPA=1 - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - LIBCXX_BUILD=1 - BUILD_32_BITS=ON - - EXTRA_FLAGS="-stdlib=libc++ -m32" + - EXTRA_FLAGS="-m32" + - EXTRA_CXX_FLAGS="-stdlib=libc++" # Clang w/ 32bit libc++ - compiler: clang dist: xenial @@ -85,12 +99,14 @@ matrix: packages: - clang-3.8 - g++-multilib + - libc6:i386 env: - INSTALL_GCC6_FROM_PPA=1 - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release - LIBCXX_BUILD=1 - BUILD_32_BITS=ON - - EXTRA_FLAGS="-stdlib=libc++ -m32" + - EXTRA_FLAGS="-m32" + - EXTRA_CXX_FLAGS="-stdlib=libc++" # Clang w/ libc++, ASAN, UBSAN - compiler: clang dist: xenial @@ -103,7 +119,8 @@ matrix: - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - LIBCXX_BUILD=1 LIBCXX_SANITIZER="Undefined;Address" - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=undefined,address -fno-sanitize-recover=all" + - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=undefined,address -fno-sanitize-recover=all" + - EXTRA_CXX_FLAGS="-stdlib=libc++" - UBSAN_OPTIONS=print_stacktrace=1 # Clang w/ libc++ and MSAN - compiler: clang @@ -117,7 +134,8 @@ matrix: - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - LIBCXX_BUILD=1 LIBCXX_SANITIZER=MemoryWithOrigins - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins" + - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins" + - EXTRA_CXX_FLAGS="-stdlib=libc++" # Clang w/ libc++ and MSAN - compiler: clang dist: xenial @@ -130,7 +148,8 @@ matrix: - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=RelWithDebInfo - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + - EXTRA_CXX_FLAGS="-stdlib=libc++" - os: osx osx_image: xcode8.3 compiler: clang @@ -145,7 +164,10 @@ matrix: osx_image: xcode8.3 compiler: clang env: - - COMPILER=clang++ BUILD_TYPE=Release BUILD_32_BITS=ON + - COMPILER=clang++ + - BUILD_TYPE=Release + - BUILD_32_BITS=ON + - EXTRA_FLAGS="-m32" - os: osx osx_image: xcode8.3 compiler: gcc @@ -192,7 +214,7 @@ install: fi - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then sudo apt-get update -qq; - sudo apt-get install -qq unzip; + sudo apt-get install -qq unzip cmake3; wget https://github.com/bazelbuild/bazel/releases/download/0.10.1/bazel-0.10.1-installer-linux-x86_64.sh --output-document bazel-installer.sh; travis_wait sudo bash bazel-installer.sh; fi @@ -202,7 +224,7 @@ install: fi script: - - cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ${EXTRA_OPTIONS} .. + - cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_C_FLAGS="${EXTRA_FLAGS}" -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS} ${EXTRA_CXX_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ${EXTRA_OPTIONS} .. - make - ctest -C ${BUILD_TYPE} --output-on-failure - bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/... diff --git a/CMakeLists.txt b/CMakeLists.txt index 5797f87f..856bc98b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.12) +cmake_minimum_required (VERSION 3.5.1) foreach(p CMP0048 # OK to clear PROJECT_VERSION on project() diff --git a/README.md b/README.md index 251c5cd6..45e41588 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ The following minimum versions are required to build the library: This describes the installation process using cmake. As pre-requisites, you'll need git and cmake installed. +_See [dependencies.md](dependencies.md) for more details regarding supported +versions of build tools._ + ```bash # Check out the library. $ git clone https://github.com/google/benchmark.git diff --git a/dependencies.md b/dependencies.md new file mode 100644 index 00000000..6289b4e3 --- /dev/null +++ b/dependencies.md @@ -0,0 +1,18 @@ +# Build tool dependency policy + +To ensure the broadest compatibility when building the benchmark library, but +still allow forward progress, we require any build tooling to be available for: + +* Debian stable AND +* The last two Ubuntu LTS releases AND + +Currently, this means using build tool versions that are available for Ubuntu +16.04 (Xenial), Ubuntu 18.04 (Bionic), and Debian stretch. + +_Note, [travis](.travis.yml) runs under Ubuntu 14.04 (Trusty) for linux builds._ + +## cmake +The current supported version is cmake 3.5.1 as of 2018-06-06. + +_Note, this version is also available for Ubuntu 14.04, the previous Ubuntu LTS +release, as `cmake3`._ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 977474f4..4c75a9de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,12 @@ if(LIBRT) target_link_libraries(benchmark ${LIBRT}) endif() +string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER) +if(NOT CMAKE_THREAD_LIBS_INIT AND "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" MATCHES ".*-fsanitize=[^ ]*address.*") + message(WARNING "CMake's FindThreads.cmake did not fail, but CMAKE_THREAD_LIBS_INIT ended up being empty. This was fixed in https://github.com/Kitware/CMake/commit/d53317130e84898c5328c237186dbd995aaf1c12 Let's guess that -pthread is sufficient.") + target_link_libraries(benchmark -pthread) +endif() + # We need extra libraries on Windows if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_link_libraries(benchmark Shlwapi)