mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
add cmake option XLNT_CXX_LANG to set the targetted cxx standard
- valid options are 11, 14, and 17 - default is 14 - cmake will error if an invalid value is provided - requires cmake >= 3.10.* to take effect in visual studio
This commit is contained in:
parent
25d75cb5c3
commit
5671167d1d
57
.travis.yml
57
.travis.yml
|
@ -12,25 +12,6 @@ notifications:
|
||||||
# set up build matrix
|
# set up build matrix
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# ============= CODE COVERAGE ===============
|
|
||||||
# gcc-6, c++11, debug build, static linking, code coverage enabled
|
|
||||||
- os: linux
|
|
||||||
compiler: gcc
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-6
|
|
||||||
- lcov
|
|
||||||
env:
|
|
||||||
- CXX_COMPILER=g++-6
|
|
||||||
- C_COMPILER=gcc-6
|
|
||||||
- BUILD_TYPE=Debug
|
|
||||||
- COVERAGE=ON
|
|
||||||
- STATIC=ON
|
|
||||||
- SAMPLES=OFF
|
|
||||||
|
|
||||||
# ============= GCC ==================
|
# ============= GCC ==================
|
||||||
# gcc-6, c++11, debug build, dynamic linking
|
# gcc-6, c++11, debug build, dynamic linking
|
||||||
- os: linux
|
- os: linux
|
||||||
|
@ -44,12 +25,13 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-6
|
- CXX_COMPILER=g++-6
|
||||||
- C_COMPILER=gcc-6
|
- C_COMPILER=gcc-6
|
||||||
|
- CXX_VER=11
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=OFF
|
- STATIC=OFF
|
||||||
- SAMPLES=OFF
|
- SAMPLES=OFF
|
||||||
|
|
||||||
# gcc-8, c++11, release build, static linking, samples + benchmarks compiled
|
# gcc-7, c++14, release build, static linking, samples + benchmarks compiled
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
addons:
|
addons:
|
||||||
|
@ -61,12 +43,13 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-7
|
- CXX_COMPILER=g++-7
|
||||||
- C_COMPILER=gcc-7
|
- C_COMPILER=gcc-7
|
||||||
|
- CXX_VER=14
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=ON
|
- STATIC=ON
|
||||||
- SAMPLES=ON
|
- SAMPLES=ON
|
||||||
|
|
||||||
# gcc-8, c++11, release build, static linking, samples + benchmarks compiled
|
# gcc-8, c++17, release build, static linking, samples + benchmarks compiled
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
addons:
|
addons:
|
||||||
|
@ -78,6 +61,7 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-8
|
- CXX_COMPILER=g++-8
|
||||||
- C_COMPILER=gcc-8
|
- C_COMPILER=gcc-8
|
||||||
|
- CXX_VER=17
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=ON
|
- STATIC=ON
|
||||||
|
@ -97,11 +81,13 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-4.0
|
- CXX_COMPILER=clang++-4.0
|
||||||
- C_COMPILER=clang-4.0
|
- C_COMPILER=clang-4.0
|
||||||
|
- CXX_VER=11
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=OFF
|
- STATIC=OFF
|
||||||
- SAMPLES=OFF
|
- SAMPLES=OFF
|
||||||
# clang 5, c++11, release build, dynamic linking, samples + benchmarks compiled
|
|
||||||
|
# clang 5, c++14, release build, dynamic linking, samples + benchmarks compiled
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
addons:
|
addons:
|
||||||
|
@ -114,11 +100,13 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-5.0
|
- CXX_COMPILER=clang++-5.0
|
||||||
- C_COMPILER=clang-5.0
|
- C_COMPILER=clang-5.0
|
||||||
|
- CXX_VER=14
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=ON
|
- STATIC=ON
|
||||||
- SAMPLES=ON
|
- SAMPLES=ON
|
||||||
# clang 6, c++11, release build, static linking, samples compiled
|
|
||||||
|
# clang 6, c++17, release build, static linking, samples compiled
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
addons:
|
addons:
|
||||||
|
@ -131,11 +119,32 @@ matrix:
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-6.0
|
- CXX_COMPILER=clang++-6.0
|
||||||
- C_COMPILER=clang-6.0
|
- C_COMPILER=clang-6.0
|
||||||
|
- CXX_VER=17
|
||||||
- BUILD_TYPE=Release
|
- BUILD_TYPE=Release
|
||||||
- COVERAGE=OFF
|
- COVERAGE=OFF
|
||||||
- STATIC=ON
|
- STATIC=ON
|
||||||
- SAMPLES=ON
|
- SAMPLES=ON
|
||||||
|
|
||||||
|
# ============= CODE COVERAGE ===============
|
||||||
|
# gcc-6, c++11, debug build, static linking, code coverage enabled
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-6
|
||||||
|
- lcov
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=g++-6
|
||||||
|
- C_COMPILER=gcc-6
|
||||||
|
- CXX_VER=11
|
||||||
|
- BUILD_TYPE=Debug
|
||||||
|
- COVERAGE=ON
|
||||||
|
- STATIC=ON
|
||||||
|
- SAMPLES=OFF
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export CC=${C_COMPILER}
|
- export CC=${C_COMPILER}
|
||||||
- export CXX=${CXX_COMPILER}
|
- export CXX=${CXX_COMPILER}
|
||||||
|
@ -158,7 +167,7 @@ script:
|
||||||
|
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake -D STATIC=$STATIC -D BENCHMARKS=$BENCHMARKS -D SAMPLES=$SAMPLES -D COVERAGE=$COVERAGE -D CMAKE_BUILD_TYPE=$BUILD_TYPE ..
|
- cmake .. -DXLNT_CXX_LANG=${CXX_VER} -DSTATIC=$STATIC -DBENCHMARKS=$BENCHMARKS -DSAMPLES=$SAMPLES -DCOVERAGE=$COVERAGE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||||
- cmake --build . -- -j2
|
- cmake --build . -- -j2
|
||||||
- ./tests/xlnt.test
|
- ./tests/xlnt.test
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,18 @@ set(COMBINED_PROJECT TRUE)
|
||||||
# Library type
|
# Library type
|
||||||
option(STATIC "Set to ON to build xlnt as a static library instead of a shared library" OFF)
|
option(STATIC "Set to ON to build xlnt as a static library instead of a shared library" OFF)
|
||||||
|
|
||||||
|
# c++ language standard to use
|
||||||
|
set(XLNT_LANGS 11 14 17)
|
||||||
|
set(XLNT_CXX_LANG "14" CACHE STRING "c++ language features to compile with")
|
||||||
|
# enumerate allowed values for cmake gui
|
||||||
|
set_property(CACHE XLNT_CXX_LANG PROPERTY STRINGS ${XLNT_LANGS})
|
||||||
|
# validate value is in XLNT_LANGS
|
||||||
|
list(FIND XLNT_LANGS ${XLNT_CXX_LANG} index)
|
||||||
|
if(index EQUAL -1)
|
||||||
|
message(FATAL_ERROR "XLNT_CXX_LANG must be one of ${XLNT_LANGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# Optional components
|
# Optional components
|
||||||
option(TESTS "Set to OFF to skip building test executable (in ./tests)" ON)
|
option(TESTS "Set to OFF to skip building test executable (in ./tests)" ON)
|
||||||
option(SAMPLES "Set to ON to build executable code samples (in ./samples)" OFF)
|
option(SAMPLES "Set to ON to build executable code samples (in ./samples)" OFF)
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project(xlnt VERSION 1.2)
|
project(xlnt VERSION 1.2)
|
||||||
|
|
||||||
# Require C99 and C++11 compilers
|
set(CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_C_STANDARD 99)
|
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
# Project metadata
|
# Project metadata
|
||||||
set(PROJECT_VENDOR "Thomas Fussell")
|
set(PROJECT_VENDOR "Thomas Fussell")
|
||||||
|
@ -156,6 +152,8 @@ else()
|
||||||
target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1)
|
target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_features(xlnt PUBLIC cxx_std_${XLNT_CXX_LANG})
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
|
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
|
||||||
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
|
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
|
||||||
|
@ -178,8 +176,7 @@ if(MSVC)
|
||||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/cryptography/aes.cpp
|
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/cryptography/aes.cpp
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
COMPILE_FLAGS "/wd\"4996\"")
|
COMPILE_FLAGS "/wd\"4996\"")
|
||||||
endif()
|
else()
|
||||||
|
|
||||||
# Platform- and file-specific settings, Clang
|
# Platform- and file-specific settings, Clang
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/miniz.cpp
|
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/detail/serialization/miniz.cpp
|
||||||
|
@ -196,6 +193,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
COMPILE_FLAGS "-Wno-strict-aliasing")
|
COMPILE_FLAGS "-Wno-strict-aliasing")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Group files into pseudo-folders in IDEs
|
# Group files into pseudo-folders in IDEs
|
||||||
source_group(xlnt FILES ${ROOT_HEADERS})
|
source_group(xlnt FILES ${ROOT_HEADERS})
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project(xlnt.test)
|
project(xlnt.test)
|
||||||
|
|
||||||
# Require C++11 compiler
|
set(CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
if(NOT COMBINED_PROJECT)
|
if(NOT COMBINED_PROJECT)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source)
|
||||||
|
@ -48,6 +46,7 @@ target_include_directories(xlnt.test
|
||||||
|
|
||||||
set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
||||||
target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})
|
target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})
|
||||||
|
target_compile_features(xlnt.test PRIVATE cxx_std_${XLNT_CXX_LANG})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# bigobj because there are so many headers in one source file
|
# bigobj because there are so many headers in one source file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user