Skip to content

Commit

Permalink
chore: c++ 17 compatibility (#430)
Browse files Browse the repository at this point in the history
* feat: c++ 17 compatibility

* Apply suggestions from code review

Co-authored-by: kyle-cochran <kyle.ray.cochran@gmail.com>

---------

Co-authored-by: kyle-cochran <kyle.ray.cochran@gmail.com>
  • Loading branch information
vishwa2710 and kyle-cochran authored Aug 23, 2024
1 parent 122a3e0 commit 50cdf2a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
40 changes: 38 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OPTION (BUILD_DOCUMENTATION "Build documentation" OFF)
OPTION (BUILD_WITH_DEBUG_SYMBOLS "Build with debug symbols" ON)
OPTION (BUILD_BENCHMARK "Build benchmark" ON)
OPTION (BUILD_SCRIPT "Build script" OFF)
OPTION (BUILD_WITH_CXX_17 "Build with C++ 17 support." OFF)

## Setup

Expand Down Expand Up @@ -129,9 +130,44 @@ IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

ENDIF ()

### C++ 20 support
### C++ 17/20 support

IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

IF (BUILD_WITH_CXX_17)

SET (CMAKE_CXX_STANDARD 17)

MESSAGE (STATUS "C++17 support enabled")

IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)

MESSAGE (FATAL_ERROR "GCC version must be at least 7.0 to build with C++17")

ENDIF ()

ELSE ()

MESSAGE (STATUS "C++20 support enabled")

SET (CMAKE_CXX_STANDARD 20)

IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)

MESSAGE (FATAL_ERROR "GCC version must be at least 13.0 to build with C++20")

ENDIF ()

ENDIF ()

SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wshadow -Wno-deprecated")

ELSE ()

SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wshadow")

ENDIF ()

SET (CMAKE_CXX_STANDARD 20)
SET (CMAKE_CXX_STANDARD_REQUIRED ON)
SET (CMAKE_CXX_EXTENSIONS OFF)

Expand Down
14 changes: 14 additions & 0 deletions docker/development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ RUN apt-get update \
&& apt-get install -y unzip jq git-lfs locales \
&& rm -rf /var/lib/apt/lists/*

## fmt

ARG FMT_VERSION="5.2.0"

RUN cd /tmp \
&& git clone --branch ${FMT_VERSION} --depth 1 https://github.com/fmtlib/fmt.git \
&& cd fmt \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE .. \
&& make --silent -j $(nproc) \
&& make install \
&& rm -rf /tmp/fmt

## ordered-map

ARG ORDERED_MAP_VERSION="0.6.0"
Expand Down

0 comments on commit 50cdf2a

Please sign in to comment.