diff --git a/.circleci/install_cmake.sh b/.circleci/install_cmake.sh new file mode 100644 index 000000000000..5f039b102c19 --- /dev/null +++ b/.circleci/install_cmake.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Usage: ./install_cmake.sh 3.28.3 +# Installs a specific CMake version on macOS from Kitware releases. +# Layout: +# /usr/local/cmake-/CMake.app/Contents/bin/{cmake,ccmake,cpack,ctest} +# Symlinks: +# /usr/local/bin/{cmake,ccmake,cpack,ctest} -> .../Contents/bin/ +# Works on both Intel and Apple Silicon (uses "macos-universal" tarball). + +set -euo pipefail + +if [ -z "${1:-}" ]; then + echo "Usage: $0 " + exit 1 +fi + +VERSION="$1" +INSTALL_DIR="/usr/local/cmake-$VERSION" +TARBALL="cmake-$VERSION-macos-universal.tar.gz" +URL="https://github.com/Kitware/CMake/releases/download/v$VERSION/$TARBALL" +TMPFILE="/tmp/$TARBALL" + +# Require basic tools +for cmd in curl tar; do + command -v "$cmd" >/dev/null || { echo "Missing $cmd"; exit 1; } +done + +# Skip if already installed +if [ -d "$INSTALL_DIR" ] && [ -x "$INSTALL_DIR/CMake.app/Contents/bin/cmake" ]; then + echo "CMake $VERSION already installed at $INSTALL_DIR" +else + echo "Downloading $URL ..." + # --fail makes curl exit non-zero on 404/5xx; -L follows redirects + curl -fL "$URL" -o "$TMPFILE" + + echo "Creating $INSTALL_DIR and extracting..." + sudo mkdir -p "$INSTALL_DIR" + + # The tarball contains a top-level directory (e.g., cmake--macos-universal/*) + # We strip that first component so CMake.app ends up directly under $INSTALL_DIR. + sudo tar -xzf "$TMPFILE" -C "$INSTALL_DIR" --strip-components=1 + + # Work around Gatekeeper quarantine if present (harmless if attribute absent) + if command -v xattr >/dev/null; then + sudo xattr -dr com.apple.quarantine "$INSTALL_DIR/CMake.app" || true + fi + + # Sanity check + if [ ! -x "$INSTALL_DIR/CMake.app/Contents/bin/cmake" ]; then + echo "Error: cmake binary not found under $INSTALL_DIR/CMake.app/Contents/bin" + exit 1 + fi +fi + +echo "Linking command-line tools into /usr/local/bin ..." +for tool in cmake ccmake cpack ctest; do + sudo ln -sfn "$INSTALL_DIR/CMake.app/Contents/bin/$tool" "/usr/local/bin/$tool" +done + +# Optional: link cmake-gui (will open the GUI app) +if [ -x "$INSTALL_DIR/CMake.app/Contents/bin/cmake-gui" ]; then + sudo ln -sfn "$INSTALL_DIR/CMake.app/Contents/bin/cmake-gui" /usr/local/bin/cmake-gui +fi + +echo "CMake $VERSION installed successfully." +which cmake +cmake --version diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index 14318c27add5..adfb21915488 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -52,12 +52,16 @@ then brew untap homebrew/homebrew-cask-versions brew update brew upgrade - brew install cmake +# brew install cmake brew install wget brew install coreutils brew install diffutils brew install grep + # install historical cmake + chmod +x .circleci/install_cmake.sh + .circleci/install_cmake.sh 3.28.3 + # boost boost_version="1.84.0" boost_package="boost_${boost_version//./_}.tar.bz2" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6901b9138579..18af34d26bf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,14 +50,6 @@ include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) find_package(Threads) -if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - if (CMAKE_VERSION VERSION_EQUAL "4.0.3" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "15.0.0.15000040") - # for Apple clang 15 under cmake 4.0.0, disable pedantic warnings explicitly as it fails to treat boost properly as - # system library, warnings propagate - set(PEDANTIC OFF) - endif() -endif() - if(NOT PEDANTIC) message(WARNING "-- Pedantic build flags turned off. Warnings will not make compilation fail. This is NOT recommended in development builds.") endif()