Skip to content

Commit

Permalink
Test for building with different C++ standard versions
Browse files Browse the repository at this point in the history
Instead of specifying C++14 as the standard in the main CMakeLists
file use whatever version the user specifies falling back to whatever
the compiler uses by default if not specified.
  • Loading branch information
laudrup committed Dec 26, 2023
1 parent f358457 commit 142203c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
unittest:
name: "${{matrix.generator}} ${{matrix.toolset}} Boost ${{matrix.boost_version}} ${{matrix.build_type}} ${{matrix.name_args}}"
name: "${{matrix.generator}} ${{matrix.toolset}} Boost ${{matrix.boost_version}} ${{matrix.build_type}} C++${{matrix.standard}} ${{matrix.name_args}}"
runs-on: ${{matrix.os}}
defaults:
run:
Expand All @@ -16,6 +16,7 @@ jobs:
os: [windows-2019, windows-2022]
toolset: [v141, v142, v143, ClangCL]
build_type: [Debug, Release]
standard: [14, 17, 20]
generator: ["Visual Studio 16 2019", "Visual Studio 17 2022"]
config_args: [""]
build_args: [""]
Expand Down Expand Up @@ -123,6 +124,7 @@ jobs:
run: |
cmake -T "${{matrix.toolset}}" \
-G "${{matrix.generator}}" \
-DCMAKE_CXX_STANDARD=${{matrix.standard}} \
${{matrix.config_args}} \
${BOOST_COMPILER_ARG} \
"${GITHUB_WORKSPACE}"
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Building for 32 bit platform")
endif()

if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 14)
endif()

message(STATUS "C++ standard set to ${CMAKE_CXX_STANDARD}")

option(ENABLE_TESTING "Enable Test Builds" ${WIN32})
option(ENABLE_EXAMPLES "Enable Examples Builds" ${WIN32})
option(ENABLE_DOCUMENTATION "Enable Documentation Builds" ${UNIX})
Expand All @@ -33,8 +39,6 @@ target_include_directories(${PROJECT_NAME}
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_14)

if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
Expand Down

0 comments on commit 142203c

Please sign in to comment.