mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-20 07:51:32 +02:00
Configure Travis CI, to extend more compile environments.
Revert commit 9e5d57c to support string tpye VERSION. Add cmake compilation switch to choose language stanard.
This commit is contained in:
parent
d2c205206d
commit
d9ffdc4bcb
156
.travis.yml
156
.travis.yml
@ -9,18 +9,18 @@ sudo: false
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- clang-format
|
||||
- meson
|
||||
- ninja
|
||||
- clang-format
|
||||
- meson
|
||||
- ninja
|
||||
update: false # do not update homebrew by default
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
packages:
|
||||
- clang-format-8
|
||||
- clang-8
|
||||
- valgrind
|
||||
- clang-format-8
|
||||
- clang-8
|
||||
- valgrind
|
||||
matrix:
|
||||
allow_failures:
|
||||
- os: osx
|
||||
@ -30,27 +30,74 @@ matrix:
|
||||
osx_image: xcode11
|
||||
compiler: clang
|
||||
env:
|
||||
CXX="clang++"
|
||||
CC="clang"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
CXX="clang++"
|
||||
CC="clang"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
LANGUAGE_STANDARD="11"
|
||||
script: ./.travis_scripts/meson_builder.sh
|
||||
- name: Linux xenial clang meson static release testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
env:
|
||||
CXX="clang++"
|
||||
CC="clang"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
CXX="clang++"
|
||||
CC="clang"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
LANGUAGE_STANDARD="11"
|
||||
# before_install and install steps only needed for linux meson builds
|
||||
before_install:
|
||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||
install:
|
||||
- source ./.travis_scripts/travis.install.${TRAVIS_OS_NAME}.sh
|
||||
- source ./.travis_scripts/travis.install.${TRAVIS_OS_NAME}.sh
|
||||
script: ./.travis_scripts/meson_builder.sh
|
||||
- name: Linux xenial gcc cmake coverage
|
||||
- name: Linux xenial gcc-4.6 meson static release with C++03 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.6
|
||||
env:
|
||||
CC=gcc-4.6
|
||||
CXX=g++-4.6
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
LANGUAGE_STANDARD="03"
|
||||
# before_install and install steps only needed for linux meson builds
|
||||
before_install:
|
||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||
install:
|
||||
- source ./.travis_scripts/travis.install.${TRAVIS_OS_NAME}.sh
|
||||
script: ./.travis_scripts/meson_builder.sh
|
||||
- name: Linux xenial gcc-4.6 meson static release with C++98 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.6
|
||||
env:
|
||||
CC=gcc-4.6
|
||||
CXX=g++-4.6
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
LANGUAGE_STANDARD="98"
|
||||
# before_install and install steps only needed for linux meson builds
|
||||
before_install:
|
||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||
install:
|
||||
- source ./.travis_scripts/travis.install.${TRAVIS_OS_NAME}.sh
|
||||
script: ./.travis_scripts/meson_builder.sh
|
||||
|
||||
- name: Linux xenial gcc-5.4 cmake-3.12 coverage
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
@ -62,10 +109,77 @@ matrix:
|
||||
BUILD_TYPE=Debug
|
||||
LIB_TYPE=shared
|
||||
DESTDIR=/tmp/cmake_json_cpp
|
||||
LANGUAGE_STANDARD="11"
|
||||
before_install:
|
||||
- pip install --user cpp-coveralls
|
||||
- pip install --user cpp-coveralls
|
||||
script: ./.travis_scripts/cmake_builder.sh
|
||||
after_success:
|
||||
- coveralls --include src/lib_json --include include
|
||||
- coveralls --include src/lib_json --include include
|
||||
- name: Linux xenial gcc-4.6 cmake-3.12 with C++98 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.6
|
||||
- valgrind
|
||||
env:
|
||||
CC=gcc-4.6
|
||||
CXX=g++-4.6
|
||||
DO_MemCheck=ON
|
||||
BUILD_TOOL="Unix Makefiles"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
DESTDIR=/tmp/cmake_json_cpp
|
||||
LANGUAGE_STANDARD="98"
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install python3
|
||||
script: ./.travis_scripts/cmake_builder.sh
|
||||
- name: Linux xenial gcc-5.4 cmake-3.12 with C++98 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
env:
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
DO_MemCheck=ON
|
||||
BUILD_TOOL="Unix Makefiles"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
DESTDIR=/tmp/cmake_json_cpp
|
||||
LANGUAGE_STANDARD="98"
|
||||
script: ./.travis_scripts/cmake_builder.sh
|
||||
- name: Linux xenial clang cmake-3.12 with C++11 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
env:
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
DO_MemCheck=ON
|
||||
BUILD_TOOL="Unix Makefiles"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
DESTDIR=/tmp/cmake_json_cpp
|
||||
LANGUAGE_STANDARD="11"
|
||||
script: ./.travis_scripts/cmake_builder.sh
|
||||
- name: Linux xenial clang cmake-3.12 with C++98 testing
|
||||
os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
env:
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
DO_MemCheck=ON
|
||||
BUILD_TOOL="Unix Makefiles"
|
||||
LIB_TYPE=static
|
||||
BUILD_TYPE=release
|
||||
DESTDIR=/tmp/cmake_json_cpp
|
||||
LANGUAGE_STANDARD="98"
|
||||
script: ./.travis_scripts/cmake_builder.sh
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -66,7 +66,7 @@ cmake --version
|
||||
echo ${CXX}
|
||||
${CXX} --version
|
||||
_COMPILER_NAME=`basename ${CXX}`
|
||||
if [ "${BUILD_TYPE}" == "shared" ]; then
|
||||
if [ "${BUILD_TYPE}" = "shared" ]; then
|
||||
_CMAKE_BUILD_SHARED_LIBS=ON
|
||||
else
|
||||
_CMAKE_BUILD_SHARED_LIBS=OFF
|
||||
@ -98,6 +98,14 @@ else
|
||||
export _BUILD_EXE=make
|
||||
fi
|
||||
|
||||
# Language standard
|
||||
# Set default to ON
|
||||
if [ "${LANGUAGE_STANDARD}" = "98" ]; then
|
||||
_BUILD_WITH_CXX_11=OFF
|
||||
else
|
||||
_BUILD_WITH_CXX_11=ON
|
||||
fi
|
||||
|
||||
_BUILD_DIR_NAME="build-cmake_${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}_${_BUILD_EXE}"
|
||||
mkdir -p ${_BUILD_DIR_NAME}
|
||||
cd "${_BUILD_DIR_NAME}"
|
||||
@ -112,6 +120,7 @@ cd "${_BUILD_DIR_NAME}"
|
||||
-DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} \
|
||||
-DBUILD_SHARED_LIBS:BOOL=${_CMAKE_BUILD_SHARED_LIBS} \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR} \
|
||||
-DBUILD_WITH_CXX_11=${_BUILD_WITH_CXX_11} \
|
||||
../
|
||||
|
||||
ctest -C ${BUILD_TYPE} -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild ${CTEST_TESTING_OPTION} -D ExperimentalSubmit
|
||||
|
@ -64,11 +64,15 @@ ninja --version
|
||||
_COMPILER_NAME=`basename ${CXX}`
|
||||
_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
|
||||
|
||||
# if LANGUAGE_STANDARD not set or null, set it to 11
|
||||
_CPP_STD=${LANGUAGE_STANDARD:="11"}
|
||||
|
||||
./.travis_scripts/run-clang-format.sh
|
||||
meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
|
||||
ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
|
||||
|
||||
cd "${_BUILD_DIR_NAME}"
|
||||
meson configure -Dcpp_std="c++${_CPP_STD}"
|
||||
ninja -v -j 2 -C ./
|
||||
meson test --no-rebuild --print-errorlogs
|
||||
|
||||
if [ "${DESTDIR}" != "/usr/local" ]; then
|
||||
|
@ -37,12 +37,6 @@ foreach(pold "") # Currently Empty
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Build the library with C++11 standard support, independent from other including
|
||||
# software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||
@ -59,19 +53,47 @@ if(CCACHE_EXECUTABLE)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" CACHE PATH "ccache" FORCE)
|
||||
endif()
|
||||
|
||||
# Note: project(VERSION XX) - the VERSION here is number, but VERSION in meson is string.
|
||||
# Thus, it is better to be consistent.
|
||||
project(JSONCPP
|
||||
# Note: version must be updated in three places when doing a release. This
|
||||
# annoying process ensures that amalgamate, CMake, and meson all report the
|
||||
# correct version.
|
||||
# 1. ./meson.build
|
||||
# 2. ./include/json/version.h
|
||||
# 3. ./CMakeLists.txt
|
||||
# IMPORTANT: also update the JSONCPP_SOVERSION!!
|
||||
VERSION 1.9.3 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
||||
LANGUAGES CXX)
|
||||
|
||||
# Set variable named ${VAR_NAME} to value ${VALUE}
|
||||
function(set_using_dynamic_name VAR_NAME VALUE)
|
||||
set( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Extract major, minor, patch from version text
|
||||
# Parse a version string "X.Y.Z" and outputs
|
||||
# version parts in ${OUPUT_PREFIX}_MAJOR, _MINOR, _PATCH.
|
||||
# If parse succeeds then ${OUPUT_PREFIX}_FOUND is TRUE.
|
||||
macro(jsoncpp_parse_version VERSION_TEXT OUPUT_PREFIX)
|
||||
set(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9_]+)?")
|
||||
if( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||
string(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_]+)" VERSION_PARTS ${VERSION_TEXT})
|
||||
list(GET VERSION_PARTS 0 ${OUPUT_PREFIX}_MAJOR)
|
||||
list(GET VERSION_PARTS 1 ${OUPUT_PREFIX}_MINOR)
|
||||
list(GET VERSION_PARTS 2 ${OUPUT_PREFIX}_PATCH)
|
||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE )
|
||||
else( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE )
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Note: version must be updated in three places when doing a release. This
|
||||
# annoying process ensures that amalgamate, CMake, and meson all report the
|
||||
# correct version.
|
||||
# 1. ./meson.build
|
||||
# 2. ./include/json/version.h
|
||||
# 3. ./CMakeLists.txt
|
||||
# IMPORTANT: also update the JSONCPP_SOVERSION!!
|
||||
set( JSONCPP_VERSION 00.11.0 )
|
||||
set( JSONCPP_SOVERSION 23 )
|
||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||
message(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
||||
set(JSONCPP_SOVERSION 23)
|
||||
#if(NOT JSONCPP_VERSION_FOUND)
|
||||
# message(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||
#endif(NOT JSONCPP_VERSION_FOUND)
|
||||
|
||||
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
||||
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
||||
@ -81,6 +103,36 @@ option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
||||
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
|
||||
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
|
||||
option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
|
||||
option(BUILD_WITH_CXX_11 "Build jsoncpp_lib with C++11 standard." ON)
|
||||
|
||||
## To compatible with C++0x and C++1x
|
||||
set(CMAKE_MINIMUN_CXX_STANDARD 98)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CXX_VERSION)
|
||||
if(CXX_VERSION VERSION_GREATER 4.8.0)
|
||||
if(BUILD_WITH_CXX_11)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
message(STATUS "Compiled with C++11(or newer) standard!")
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 98)
|
||||
message(STATUS "Compiled with C++0x standard!")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 98)
|
||||
message(STATUS "Compiled with C++0x standard!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CXX_STANDARD)
|
||||
if (BUILD_WITH_CXX_11)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
message(STATUS "Compiled with C++1x standard!")
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 98)
|
||||
message(STATUS "Compiled with C++0x standard!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Adhere to GNU filesystem layout conventions
|
||||
include(GNUInstallDirs)
|
||||
@ -127,7 +179,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# not yet ready for -Wsign-conversion
|
||||
|
||||
if(JSONCPP_WITH_STRICT_ISO)
|
||||
add_compile_options(-Wpedantic)
|
||||
add_compile_options(-Wall)
|
||||
endif()
|
||||
if(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||
add_compile_options(-Werror=conversion)
|
||||
@ -160,7 +212,7 @@ if(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
||||
FILE jsoncppConfig.cmake)
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
VERSION ${JSONCPP_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
||||
|
@ -9,7 +9,7 @@ project(
|
||||
# 2. /include/json/version.h
|
||||
# 3. /CMakeLists.txt
|
||||
# IMPORTANT: also update the SOVERSION!!
|
||||
version : '1.9.3',
|
||||
version : '00.11.0',
|
||||
default_options : [
|
||||
'buildtype=release',
|
||||
'cpp_std=c++11',
|
||||
|
@ -90,6 +90,7 @@ endif()
|
||||
# Specify compiler features required when compiling a given target.
|
||||
# See https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
|
||||
# for complete list of features available
|
||||
if(CMAKE_CXX_STANDARD EQUAL "11")
|
||||
target_compile_features(jsoncpp_lib PUBLIC
|
||||
cxx_std_11 # Compiler mode is aware of C++ 11.
|
||||
#MSVC 1900 cxx_alignas # Alignment control alignas, as defined in N2341.
|
||||
@ -136,6 +137,10 @@ target_compile_features(jsoncpp_lib PUBLIC
|
||||
cxx_variadic_macros # Variadic macros, as defined in N1653.
|
||||
cxx_variadic_templates # Variadic templates, as defined in N2242.
|
||||
)
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 98)
|
||||
target_compile_features(jsoncpp_lib PUBLIC)
|
||||
endif()
|
||||
|
||||
install(TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
|
Loading…
x
Reference in New Issue
Block a user