Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Cmake: Set c++23 as default.
Browse files Browse the repository at this point in the history
  • Loading branch information
AriDEV3 committed Jan 7, 2024
1 parent 79cac13 commit 28801f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
29 changes: 18 additions & 11 deletions cmake/compiler/gcc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@
# Set build-directive (used in core to tell which buildtype we used)
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')

# Check C++20 compiler support
# Check C++23 compiler support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++20" COMPILER_SUPPORTS_CXX20)
if(COMPILER_SUPPORTS_CXX20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") #c++20
CHECK_CXX_COMPILER_FLAG("-std=c++23" COMPILER_SUPPORTS_CXX20)
if(COMPILER_SUPPORTS_CXX23)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23") #c++23
else()
message(FATAL_ERROR "Error, SkyFire requires a compiler that supports C++20!")
message(FATAL_ERROR "Error, SkyFire requires a compiler that supports C++23!")
endif()

if(WITH_CXX_20_STD)
if(NOT WITH_CXX_DRAFT_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") #c++20
if(NOT WITH_CXX_DRAFT_STD AND NOT WITH_CXX_23_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") #c++20
message(STATUS "GCC: C++20 Standard Enabled.")
else()
message(FATAL_ERROR "GCC: Only 1 CXX Standard can be used!")
endif()
endif()
if(WITH_CXX_23_STD)
if(NOT WITH_CXX_DRAFT_STD AND NOT WITH_CXX_20_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23") #c++23
message(STATUS "GCC: C++23 Standard Enabled.")
else()
message(FATAL_ERROR "GCC: Only 1 CXX Standard can be used!")
endif()
endif()
if(WITH_CXX_DRAFT_STD)
if(NOT WITH_CXX_20_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2b") #c++23
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2b") #c++23
if(NOT WITH_CXX_23_STD AND NOT WITH CXX_20_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2c") #c++26
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2c") #c++26
message(STATUS "GCC: C++ Draft Standard Enabled.")
endif()
endif()
Expand Down
10 changes: 8 additions & 2 deletions cmake/compiler/msvc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,23 @@ if(NOT WITH_WARNINGS)
message(STATUS "MSVC: Disabled generic compiletime warnings")
endif()

if(WITH_CXX_23_STD)
if(NOT WITH_CXX_20_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest") #c++latest is currently c++23 in msvc 2022
message(STATUS "MSVC: C++23 Draft Standard Enabled.")
endif()
endif()
if(WITH_CXX_20_STD)
if(NOT WITH_CXX_DRAFT_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20") #c++20
message(STATUS "MSVC: C++20 Standard Enabled.")
else()
message(FATAL_ERROR "MSVC: Only 1 CXX Standard can be used!")
endif()
endif()
if(WITH_CXX_DRAFT_STD)
if(NOT WITH_CXX_20_STD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest") #c++23
message(STATUS "MSVC: C++ Draft Standard Enabled.")
endif()
endif()
Expand Down
3 changes: 2 additions & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(USE_COREPCH "Use precompiled headers when compiling servers"
option(WITH_WARNINGS "Show all warnings during compile" 0)
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
option(WITH_CXX_20_STD "Use c++20 standard" 1)
option(WITH_CXX_20_STD "Use c++20 standard" 0)
option(WITH_CXX_23_STD "Use c++23 standard" 1)
option(WITH_CXX_DRAFT_STD "Use c++ draft standard" 0)

0 comments on commit 28801f1

Please sign in to comment.