Skip to content

Commit

Permalink
Add a script in contrib to download a cmake binary (#19632)
Browse files Browse the repository at this point in the history
* Add a script in contrib to download a cmake binary

will help on Ubuntu 14.04 and other distros when we upgrade to a
version of LLVM that requires cmake 3.4.3 or newer

* Run in deps/scratch, fix shasum invocation on darwin
  • Loading branch information
tkelman authored Dec 22, 2016
1 parent 66ab171 commit 387e964
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions contrib/download_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
# This file is a part of Julia. License is MIT: http://julialang.org/license

# Script to download newest version of cmake on linux (or mac)
# saves you the trouble of compiling it if you don't have root
set -e # stop on failure
mkdir -p "$(dirname "$0")"/../deps/scratch
cd "$(dirname "$0")"/../deps/scratch

CMAKE_VERSION_MAJOR=3
CMAKE_VERSION_MINOR=7
CMAKE_VERSION_PATCH=1
CMAKE_VERSION_MAJMIN=$CMAKE_VERSION_MAJOR.$CMAKE_VERSION_MINOR
CMAKE_VERSION=$CMAKE_VERSION_MAJMIN.$CMAKE_VERSION_PATCH

# listed at https://cmake.org/files/v$CMAKE_VERSION_MAJMIN/cmake-$CMAKE_VERSION-SHA-256.txt
# for the files cmake-$CMAKE_VERSION-Darwin-x86_64.tar.gz
# and cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
CMAKE_SHA256_DARWIN=1851d1448964893fdc5a8c05863326119f397a3790e0c84c40b83499c7960267
CMAKE_SHA256_LINUX=7b4b7a1d9f314f45722899c0521c261e4bfab4a6b532609e37fef391da6bade2

PLATFORM="$(uname)-$(uname -m)"
FULLNAME=cmake-$CMAKE_VERSION-$PLATFORM
case $PLATFORM in
Darwin-x86_64)
../tools/jldownload https://cmake.org/files/v$CMAKE_VERSION_MAJMIN/$FULLNAME.tar.gz
echo "$CMAKE_SHA256_DARWIN $FULLNAME.tar.gz" | shasum -a 256 -c -
CMAKE_EXTRACTED_PATH=$FULLNAME/CMake.app/Contents/bin/cmake;;
Linux-x86_64)
../tools/jldownload https://cmake.org/files/v$CMAKE_VERSION_MAJMIN/$FULLNAME.tar.gz
echo "$CMAKE_SHA256_LINUX $FULLNAME.tar.gz" | sha256sum -c -
CMAKE_EXTRACTED_PATH=$FULLNAME/bin/cmake;;
*)
echo "This script only supports x86_64 Mac and Linux. For other platforms," >&2
echo "get cmake from your package manager or compile it from source." >&2
exit 1;;
esac

tar -xzf $FULLNAME.tar.gz
echo "CMAKE = $PWD/$CMAKE_EXTRACTED_PATH" >> ../../Make.user
3 changes: 2 additions & 1 deletion deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ $(LLVM_BUILDDIR_withtype)/build-configured: $(LLVM_SRC_DIR)/source-extracted | $
mkdir -p $(dir $@)
cd $(dir $@) && \
export PATH=$(llvm_python_workaround):$$PATH && \
$(CMAKE) $(LLVM_SRC_DIR) $(CMAKE_GENERATOR_COMMAND) $(CMAKE_COMMON) $(LLVM_CMAKE)
$(CMAKE) $(LLVM_SRC_DIR) $(CMAKE_GENERATOR_COMMAND) $(CMAKE_COMMON) $(LLVM_CMAKE) \
|| { echo '*** To install a newer version of cmake, run contrib/download_cmake.sh ***' && false; }
echo 1 > $@

$(LLVM_BUILDDIR_withtype)/build-compiled: $(LLVM_BUILDDIR_withtype)/build-configured | $(llvm_python_workaround)
Expand Down

0 comments on commit 387e964

Please sign in to comment.