Skip to content

Commit

Permalink
Merge pull request #108 from mailagentrus/dev
Browse files Browse the repository at this point in the history
travis and CMake 2.8.8 installation test;
  • Loading branch information
Cyan4973 committed Jan 12, 2016
2 parents 3a3b72f + 0b7c101 commit 62635c4
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 9 deletions.
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
language: c
compiler: gcc
script: make $ZSTD_TRAVIS_CI_ENV

before_install:
- "wget https://launchpad.net/ubuntu/+source/cmake/2.8.8-2ubuntu1/+build/3441442/+files/cmake_2.8.8-2ubuntu1_amd64.deb"
- "wget https://launchpad.net/ubuntu/+archive/primary/+files/cmake-data_2.8.8-2ubuntu1_all.deb"
- "sudo apt-get remove cmake-data cmake"
- sudo apt-get update -qq
- sudo apt-get install -qq gcc-arm-linux-gnueabi
- sudo apt-get install -qq clang
- sudo apt-get install -qq g++-multilib
- sudo apt-get install -qq gcc-multilib
- sudo apt-get install -qq valgrind

install:
- "sudo dpkg --install cmake-data_2.8.8-2ubuntu1_all.deb cmake_2.8.8-2ubuntu1_amd64.deb"

env:
- ZSTD_TRAVIS_CI_ENV=travis-install
- ZSTD_TRAVIS_CI_ENV=cmaketest
Expand All @@ -22,6 +27,11 @@ env:
- ZSTD_TRAVIS_CI_ENV=asan
- ZSTD_TRAVIS_CI_ENV=asan32
- ZSTD_TRAVIS_CI_ENV="-C programs valgrindTest"

compiler: gcc

script:
- make $ZSTD_TRAVIS_CI_ENV

matrix:
fast_finish: true
fast_finish: true
11 changes: 10 additions & 1 deletion contrib/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ################################################################

PROJECT(zstd)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)

OPTION(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)

Expand All @@ -44,6 +44,15 @@ ELSE (ZSTD_LEGACY_SUPPORT)
ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=0)
ENDIF (ZSTD_LEGACY_SUPPORT)

INCLUDE(CMakeModules/CompareVersion.cmake)
COMPARE_VERSION_STRINGS("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" "2.8.8" CMP_RESULT)

IF ((CMP_RESULT LESS 0) OR (CMP_RESULT EQUAL 0))
SET(USE_DEPRECATED_CODE_STYLE TRUE)
ELSE ()
SET(USE_DEPRECATED_CODE_STYLE FALSE)
ENDIF ((CMP_RESULT LESS 0) OR (CMP_RESULT EQUAL 0))

ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(programs)

Expand Down
70 changes: 70 additions & 0 deletions contrib/cmake/CMakeModules/CompareVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Computes the realtionship between two version strings. A version
# string is a number delineated by '.'s such as 1.3.2 and 0.99.9.1.
# You can feed version strings with different number of dot versions,
# and the shorter version number will be padded with zeros: 9.2 <
# 9.2.1 will actually compare 9.2.0 < 9.2.1.
#
# Input: a_in - value, not variable
# b_in - value, not variable
# result_out - variable with value:
# -1 : a_in < b_in
# 0 : a_in == b_in
# 1 : a_in > b_in
#
# Written by James Bigler.
MACRO(COMPARE_VERSION_STRINGS a_in b_in result_out)
# Since SEPARATE_ARGUMENTS using ' ' as the separation token,
# replace '.' with ' ' to allow easy tokenization of the string.
STRING(REPLACE "." " " a ${a_in})
STRING(REPLACE "." " " b ${b_in})
SEPARATE_ARGUMENTS(a)
SEPARATE_ARGUMENTS(b)

# Check the size of each list to see if they are equal.
LIST(LENGTH a a_length)
LIST(LENGTH b b_length)

# Pad the shorter list with zeros.

# Note that range needs to be one less than the length as the for
# loop is inclusive (silly CMake).
IF (a_length LESS b_length)
# a is shorter
SET(shorter a)
MATH(EXPR range "${b_length} - 1")
MATH(EXPR pad_range "${b_length} - ${a_length} - 1")
ELSE (a_length LESS b_length)
# b is shorter
SET(shorter b)
MATH(EXPR range "${a_length} - 1")
MATH(EXPR pad_range "${a_length} - ${b_length} - 1")
ENDIF (a_length LESS b_length)

# PAD out if we need to
IF (NOT pad_range LESS 0)
FOREACH (pad RANGE ${pad_range})
# Since shorter is an alias for b, we need to get to it by by dereferencing shorter.
LIST(APPEND ${shorter} 0)
ENDFOREACH (pad RANGE ${pad_range})
ENDIF (NOT pad_range LESS 0)

SET(result 0)
FOREACH (index RANGE ${range})
IF (result EQUAL 0)
# Only continue to compare things as long as they are equal
LIST(GET a ${index} a_version)
LIST(GET b ${index} b_version)
# LESS
IF (a_version LESS b_version)
SET(result -1)
ENDIF (a_version LESS b_version)
# GREATER
IF (a_version GREATER b_version)
SET(result 1)
ENDIF (a_version GREATER b_version)
ENDIF (result EQUAL 0)
ENDFOREACH (index)

# Copy out the return result
SET(${result_out} ${result})
ENDMACRO(COMPARE_VERSION_STRINGS)
18 changes: 14 additions & 4 deletions contrib/cmake/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
# ################################################################

IF (USE_DEPRECATED_CODE_STYLE)
IF (POLICY CMP0021)
cmake_policy(SET CMP0021 OLD)
ENDIF ()
ENDIF (USE_DEPRECATED_CODE_STYLE)

# Get library version based on information from input content (use regular exp)
function(GetLibraryVersion _content _outputVar1 _outputVar2 _outputVar3)
string(REGEX MATCHALL ".*define ZSTD_VERSION_MAJOR+.* ([0-9]+).*define ZSTD_VERSION_MINOR+.* ([0-9]+).*define ZSTD_VERSION_RELEASE+.* ([0-9]+)" VERSION_REGEX "${_content}")
Expand Down Expand Up @@ -109,12 +115,16 @@ IF (MSVC)
SET_TARGET_PROPERTIES(libzstd_shared PROPERTIES COMPILE_DEFINITIONS "ZSTD_DLL_EXPORT=1;ZSTD_HEAPMODE=0;_CONSOLE;_CRT_SECURE_NO_WARNINGS")
ENDIF (MSVC)

TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_DIR})
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_DIR})
IF (NOT USE_DEPRECATED_CODE_STYLE)
TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_DIR})
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_DIR})
ENDIF (NOT USE_DEPRECATED_CODE_STYLE)

IF (ZSTD_LEGACY_SUPPORT)
TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_LEGACY_DIR})
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_LEGACY_DIR})
IF (NOT USE_DEPRECATED_CODE_STYLE)
TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_LEGACY_DIR})
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_LEGACY_DIR})
ENDIF (NOT USE_DEPRECATED_CODE_STYLE)
ENDIF (ZSTD_LEGACY_SUPPORT)

# Define library base name
Expand Down
12 changes: 11 additions & 1 deletion contrib/cmake/programs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,24 @@ SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
# Define project root directory
SET(ROOT_DIR ../../..)

# Define зкщпкфьы directory, where sources and header files are located
# Define programs directory, where sources and header files are located
SET(PROGRAMS_DIR ${ROOT_DIR}/programs)
INCLUDE_DIRECTORIES(${PROGRAMS_DIR})

IF (USE_DEPRECATED_CODE_STYLE)
# Define library directory, where sources and header files are located
SET(LIBRARY_DIR ${ROOT_DIR}/lib)
INCLUDE_DIRECTORIES(${LIBRARY_DIR})
ENDIF (USE_DEPRECATED_CODE_STYLE)

IF (ZSTD_LEGACY_SUPPORT)
SET(PROGRAMS_LEGACY_DIR ${PROGRAMS_DIR}/legacy)
INCLUDE_DIRECTORIES(${PROGRAMS_LEGACY_DIR})

IF (USE_DEPRECATED_CODE_STYLE)
INCLUDE_DIRECTORIES(${LIBRARY_DIR}/legacy)
ENDIF (USE_DEPRECATED_CODE_STYLE)

SET(ZSTD_FILEIO_LEGACY ${PROGRAMS_LEGACY_DIR}/fileio_legacy.c)
ENDIF (ZSTD_LEGACY_SUPPORT)

Expand Down

0 comments on commit 62635c4

Please sign in to comment.