Merge pull request #9 from nemequ/master

Build system improvements
This commit is contained in:
Chris Taylor 2018-07-21 15:48:48 -07:00 committed by GitHub
commit 01cd769606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 343 additions and 5 deletions

234
.travis.yml Normal file
View File

@ -0,0 +1,234 @@
language: c++
sudo: false
branches:
except:
- /^(wip\/)?(appveyor|msvc|mingw|windows)(\-.+)?$/
matrix:
include:
###
## Release build using the latest GCC
###
- env: CMAKE_BUILD_TYPE=Release C_COMPILER=gcc-8 CXX_COMPILER=g++-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-8
- g++-8
- cmake
- cmake-data
###
## Linux builds using various versions of GCC.
###
- env: C_COMPILER=gcc-8 CXX_COMPILER=g++-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-8
- g++-8
- cmake
- cmake-data
# - env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-7
# - g++-7
# - cmake
# - cmake-data
- env: C_COMPILER=gcc-6 CXX_COMPILER=g++-6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-6
- g++-6
- cmake
- cmake-data
- env: C_COMPILER=gcc-5 CXX_COMPILER=g++-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-5
- g++-5
- cmake
- cmake-data
# - env: C_COMPILER=gcc-4.9 CXX_COMPILER=g++-4.9
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-4.9
# - g++-4.9
# - cmake
# - cmake-data
- env: C_COMPILER=gcc-4.8 CXX_COMPILER=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-4.8
- g++-4.8
- cmake
- cmake-data
# - env: C_COMPILER=gcc-4.7 CXX_COMPILER=g++-4.7
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-4.7
# - g++-4.7
# - cmake
# - cmake-data
# - env: C_COMPILER=gcc-4.6 CXX_COMPILER=g++-4.6
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-4.6
# - g++-4.6
# - cmake
# - cmake-data
# - os: linux
# env: C_COMPILER=gcc-4.5 CXX_COMPILER=g++-4.5
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-4.5
# - g++-4.5
# - cmake
# - cmake-data
# - env: C_COMPILER=gcc-4.4 CXX_COMPILER=g++-4.4
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - gcc-4.4
# - g++-4.4
# - cmake
# - cmake-data
###
## clang on Linux
###
- env: C_COMPILER=clang-3.9 CXX_COMPILER=clang++-3.9
addons:
apt:
sources:
- llvm-toolchain-precise-3.9
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- clang-3.9
- cmake
- cmake-data
# - env: C_COMPILER=clang-3.8 CXX_COMPILER=clang++-3.8
# addons:
# apt:
# sources:
# - llvm-toolchain-precise-3.8
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - clang-3.8
# - cmake
# - cmake-data
- env: C_COMPILER=clang-3.7 CXX_COMPILER=clang++-3.7
addons:
apt:
sources:
- llvm-toolchain-precise-3.7
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- clang-3.7
- cmake
- cmake-data
# - env: C_COMPILER=clang-3.6 CXX_COMPILER=clang++-3.6
# addons:
# apt:
# sources:
# - llvm-toolchain-precise-3.6
# - ubuntu-toolchain-r-test
# - george-edison55-precise-backports
# packages:
# - clang-3.6
# - cmake
# - cmake-data
- env: C_COMPILER=clang-3.5 CXX_COMPILER=clang++-3.5
addons:
apt:
sources:
- llvm-toolchain-precise-3.5
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- clang-3.5
- cmake
- cmake-data
###
## PGI
###
- env: C_COMPILER=pgcc CXX_COMPILER=pgc++
addons:
apt:
sources:
- george-edison55-precise-backports
packages:
- cmake
- cmake-data
###
## OS X
###
- os: osx
before_install:
- if [ "${C_COMPILER}" = "pgcc" -o "${CXX_COMPILER}" = "pgc++" ]; then curl -s 'https://raw.githubusercontent.com/nemequ/pgi-travis/master/install-pgi.sh' | /bin/sh; fi
###
## If we use the matrix to set CC/CXX Travis overwrites the values,
## so instead we use C/CXX_COMPILER then copy the values to CC/CXX
## here (after Travis has set CC/CXX).
###
- if [ -n "${C_COMPILER}" ]; then export CC="${C_COMPILER}"; fi
- if [ -n "${CXX_COMPILER}" ]; then export CXX="${CXX_COMPILER}"; fi
# Debug builds by default
- if [ -z "${CMAKE_BUILD_TYPE}" ]; then export CMAKE_BUILD_TYPE=Debug; fi
- mkdir build
- cd build
script:
- if [ "${CXX}" != "pgc++" ]; then export AVX_FLAG="-mavx"; fi
- cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" -DCMAKE_CXX_FLAGS="${AVX_FLAG} ${CXXFLAGS}"
- make VERBOSE=1

View File

@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.7)
project(leopard)
include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 11)
@ -25,12 +28,85 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_cxx_compiler_flag("/O2" CXX_FLAG_O2)
check_cxx_compiler_flag("/Oy" CXX_FLAG_Oy)
check_cxx_compiler_flag("/Zi" CXX_FLAG_Zi)
check_cxx_compiler_flag("/W4" CXX_FLAG_W4)
#Use this version instead for OpenMP:
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp")
if(CXX_FLAG_O2)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2")
endif()
if(CXX_FLAG_Oy)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oy")
endif()
if(CXX_FLAG_Zi)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi")
endif()
if(CXX_FLAG_W4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
check_cxx_compiler_flag("-G" CXX_FLAG_g)
check_cxx_compiler_flag("-O0" CXX_FLAG_O0)
check_cxx_compiler_flag("-O3" CXX_FLAG_O3)
check_cxx_compiler_flag("-Minform=inform" CXX_FLAG_MINFORM_INFORM)
if(CXX_FLAG_g)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
endif(CXX_FLAG_g)
if(CXX_FLAG_O0)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
endif(CXX_FLAG_O0)
if(CXX_FLAG_O3)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -O3")
endif(CXX_FLAG_O3)
if(CXX_FLAG_MINFORM_INFORM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Minform=inform")
endif(CXX_FLAG_MINFORM_INFORM)
else()
check_cxx_compiler_flag("-G" CXX_FLAG_g)
check_cxx_compiler_flag("-O0" CXX_FLAG_O0)
check_cxx_compiler_flag("-O3" CXX_FLAG_O3)
check_cxx_compiler_flag("-Wall" CXX_FLAG_Wall)
check_cxx_compiler_flag("-Wextra" CXX_FLAG_Wextra)
if(CXX_FLAG_g)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
endif(CXX_FLAG_g)
if(CXX_FLAG_O0)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
endif(CXX_FLAG_O0)
if(CXX_FLAG_O3)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -O3")
endif(CXX_FLAG_O3)
if(CXX_FLAG_Wall)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif(CXX_FLAG_Wall)
if(CXX_FLAG_Wextra)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif(CXX_FLAG_Wextra)
endif()
find_package(OpenMP)
cmake_dependent_option(ENABLE_OPENMP "Enable OpenMP support" ON "OPENMP_FOUND" OFF)
if(ENABLE_OPENMP)
if(NOT OPENMP_FOUND)
message(FATAL_ERROR "OpenMP support requested, but could not be found")
endif(NOT OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(ENABLE_OPENMP)
add_library(libleopard STATIC ${LIB_SOURCE_FILES})

28
appveyor.yml Normal file
View File

@ -0,0 +1,28 @@
environment:
matrix:
- GENERATOR: Visual Studio 14 2015 Win64
- GENERATOR: Visual Studio 14 2015
- GENERATOR: Visual Studio 12 2013 Win64
# - GENERATOR: Visual Studio 11 2012
# - GENERATOR: Visual Studio 10 2010 Win64
# - GENERATOR: Visual Studio 9 2008
branches:
except:
- /^(wip\/)?(travis|osx|ipp)(\-.+)?$/
- /^master$/
before_build:
- ps: |
git submodule -q update --init --recursive
mkdir build
cd build
cmake -G "$env:GENERATOR" ..
build_script:
- ps: |
cmake --build . --config Debug
# test_script:
# - ps: |
# ctest --output-on-failure --interactive-debug-mode 0 -C Debug -V