diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cc07aa..20f22c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,13 +7,19 @@ project(Serene LANGUAGES CXX C) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) +option(CPP_20_SUPPORT "C++20 Support" OFF) # Only do these if this is the main project, and not if it is included through add_subdirectory if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ## Settings ----------------------------------------- # specify the C++ standard - set(CMAKE_CXX_STANDARD 14) + if (CPP_20_SUPPORT) + set(CMAKE_CXX_STANDARD 20) + else() + set(CMAKE_CXX_STANDARD 14) + endif() + set(CMAKE_CXX_STANDARD_REQUIRED True) set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 5b88c5d..953ef13 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -2,7 +2,14 @@ add_executable(serenec serene.cpp) # Make sure to generate files related to the dialects first add_dependencies(serenec SereneDialectGen) -target_compile_features(serenec PRIVATE cxx_std_14) +if (CPP_20_SUPPORT) + target_compile_features(serenec PRIVATE cxx_std_20) +else() + target_compile_features(serenec PRIVATE cxx_std_14) +endif() + + + target_link_libraries(serenec PRIVATE serene diff --git a/builder b/builder index 99bbb44..db7661c 100755 --- a/builder +++ b/builder @@ -34,6 +34,13 @@ function build() { popd_build } +function build-20() { + pushed_build + cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCPP_20_SUPPORT=ON "$@" $ROOT_DIR + ninja -j `nproc` + popd_build +} + function build-release() { pushed_build cmake -G Ninja -DCMAKE_BUILD_TYPE=Release $ROOT_DIR @@ -93,6 +100,12 @@ case "$command" in mkdir -p $BUILD_DIR build "${@:2}" ;; + "build-20") + clean + mkdir -p $BUILD_DIR + build-20 "${@:2}" + ;; + "build-docs") clean mkdir -p $BUILD_DIR diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8aaa3f0..0368fda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,8 +54,15 @@ add_library(serene # Make sure to generate files related to the dialects first add_dependencies(serene SereneDialectGen) + +if (CPP_20_SUPPORT) + target_compile_features(serene PUBLIC cxx_std_20) +else() + target_compile_features(serene PUBLIC cxx_std_14) +endif() + + # We need this directory, and users of our library will need it too -target_compile_features(serene PUBLIC cxx_std_14) target_include_directories(serene PRIVATE ${INCLUDE_DIR}) target_include_directories(serene PUBLIC ${PROJECT_BINARY_DIR})