Browse Source

Merge pull request #19 from ethereum-mining/upgrade-cmake

Travis CI: Use CMake 3.8.1
cl-refactor
Paweł Bylica 8 years ago
committed by GitHub
parent
commit
7828480f21
  1. 1
      .travis.yml
  2. 12
      CMakeLists.txt
  3. 15
      libethash/CMakeLists.txt
  4. 55
      scripts/install_cmake.sh

1
.travis.yml

@ -16,6 +16,7 @@ cache:
- $HOME/.hunter/_Base/Cache
before_install:
- if [[ "$CUDA" = ON ]]; then source scripts/install-cuda-trusty.sh; fi
- if [ "$TRAVIS_OS_NAME" = linux ]; then scripts/install_cmake.sh; fi
script:
- cmake -DHUNTER_JOBS_NUMBER=4 -DETHASHCUDA=$CUDA -DETHASHCL=ON -H. -Bbuild
- cmake --build build

12
CMakeLists.txt

@ -1,12 +1,9 @@
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
# The default toolchain file configures compilers and build environment.
# This configuration is also used by hunter to build dependencies.
# CMake will cache this value, not need to explictly specify CACHE param.
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchain.cmake)
endif()
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchain.cmake CACHE FILEPATH "CMake toolchain file")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type on single-configuration generators")
set(HUNTER_CONFIGURATION_TYPES Release)
include(HunterGate)
@ -33,9 +30,6 @@ cmake_policy(SET CMP0054 NEW)
######################################################################################################
# Default CMAKE_BUILD_TYPE.
set(CMAKE_BUILD_TYPE CACHE STRING Release)
option(ETHASHCL "Build with OpenCL mining" ON)
option(ETHASHCUDA "Build with CUDA mining" OFF)
option(ETHSTRATUM "Build with Stratum protocol support" ON)

15
libethash/CMakeLists.txt

@ -1,11 +1,3 @@
set(LIBRARY ethash)
if (CPPETHEREUM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif ()
set(CMAKE_BUILD_TYPE Release)
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
endif()
@ -27,10 +19,5 @@ endif()
list(APPEND FILES sha3.c sha3.h)
add_library(${LIBRARY} ${FILES})
if (CRYPTOPP_FOUND)
TARGET_LINK_LIBRARIES(${LIBRARY} ${CRYPTOPP_LIBRARIES})
endif()
add_library(ethash ${FILES})
install( TARGETS ${LIBRARY} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )

55
scripts/install_cmake.sh

@ -0,0 +1,55 @@
#!/usr/bin/env sh
# This script downloads the CMake binary and installs it in $PREFIX directory
# (the cmake executable will be in $PREFIX/bin). By default $PREFIX is
# ~/.local but can we changes with --prefix <PREFIX> argument.
# This is mostly suitable for CIs, not end users.
set -e
VERSION=3.8.1
if [ "$1" = "--prefix" ]; then
PREFIX="$2"
else
PREFIX=~/.local
fi
OS=$(uname -s)
case $OS in
Linux) SHA256=10ca0e25b7159a03da0c1ec627e686562dc2a40aad5985fd2088eb684b08e491;;
Darwin) SHA256=cf8cf16eb1281127006507e69bbcfabec2ccbbc3dfb95888c39d578d037569f1;;
esac
BIN=$PREFIX/bin
if test -f $BIN/cmake && ($BIN/cmake --version | grep -q "$VERSION"); then
echo "CMake $VERSION already installed in $BIN"
else
FILE=cmake-$VERSION-$OS-x86_64.tar.gz
VERSION_SERIES=$(echo $VERSION | awk '{ string=substr($0, 1, 3); print string; }')
URL=https://cmake.org/files/v$VERSION_SERIES/$FILE
ERROR=0
TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz)
echo "Downloading CMake ($URL)..."
curl -s "$URL" > "$TMPFILE"
if type -p sha256sum > /dev/null; then
SHASUM_TOOL="sha256sum"
else
SHASUM_TOOL="shasum -a256"
fi
SHASUM=$($SHASUM_TOOL "$TMPFILE")
if ! (echo "$SHASUM" | grep -q "$SHA256"); then
echo "Checksum mismatch!"
echo "Actual: $SHASUM"
echo "Expected: $SHA256"
exit 1
fi
mkdir -p "$PREFIX"
tar xzf "$TMPFILE" -C "$PREFIX" --strip 1
rm $TMPFILE
fi
Loading…
Cancel
Save