Add c++20 support flag to cmake
This commit is contained in:
parent
c1bec1ec99
commit
a42259d684
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
13
builder
13
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
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
Loading…
Reference in New Issue