From 8eca59be5b576f2fdff47ffb4526e8e8c5623ce9 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Sun, 12 Apr 2020 15:44:17 +0200 Subject: [PATCH 1/5] added cpp 20 support --- cookiecutter.json | 2 +- .../CMakeLists.txt | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index d9f2dbd..7fe385d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -9,7 +9,7 @@ "cpp_namespace": "{{ cookiecutter.package_name }}", "cpp_root_folder_name": "{{ cookiecutter.package_name }}", "cpp_macro_prefix": "{{ cookiecutter.project_name|upper|replace(' ', '_')|replace('-', '_') }}", - "cpp_standart": ["C++14", "C++11", "NotSpecified"], + "cpp_standart": ["C++20", "C++17", "C++14", "C++11", "NotSpecified"], "cmake_project_name": "{{ cookiecutter.package_name }}", "cmake_interface_library_name": "{{ cookiecutter.package_name }}", "github_project_name": "{{ cookiecutter.project_slug }}", diff --git a/{{cookiecutter.github_project_name}}/CMakeLists.txt b/{{cookiecutter.github_project_name}}/CMakeLists.txt index 417894a..9e26a19 100644 --- a/{{cookiecutter.github_project_name}}/CMakeLists.txt +++ b/{{cookiecutter.github_project_name}}/CMakeLists.txt @@ -8,7 +8,27 @@ set(PROJECT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) set(CPP_ROOT_FOLDER_NAME {{cookiecutter.cpp_root_folder_name}}) include_directories(${PROJECT_INCLUDE_DIR}) -{% if cookiecutter.cpp_standart == 'C++14' -%} +{% if cookiecutter.cpp_standart == 'C++20' -%} +include(CheckCXXCompilerFlag) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG) + if (HAS_CPP17_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + else() + message(FATAL_ERROR "Unsupported compiler -- C++14 support required!") + endif() +endif() +{% if cookiecutter.cpp_standart == 'C++17' -%} +include(CheckCXXCompilerFlag) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG) + if (HAS_CPP17_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + else() + message(FATAL_ERROR "Unsupported compiler -- C++14 support required!") + endif() +endif() +{% elif cookiecutter.cpp_standart == 'C++14' -%} # C++ 14 # =========== include(CheckCXXCompilerFlag) From 8a726c7cbcda855bd81aeee396bd8a260a245b34 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 9 Sep 2020 10:16:15 +0200 Subject: [PATCH 2/5] updates --- .travis.yml | 23 +++++++------------ .../CMakeLists.txt | 10 ++++---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee37729..51430d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,33 +28,26 @@ matrix: packages: - g++-6 env: COMPILER=gcc GCC=6 + - os: linux addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.6 - packages: - - clang-3.6 - env: COMPILER=clang CLANG=3.6 - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 + - llvm-toolchain-xenial-5.0 packages: - - clang-3.7 - env: COMPILER=clang CLANG=3.7 + - g++-4.9 + - clang-5.0 + env: COMPILER=clang CLANG=5.0 - os: linux addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.9 + - llvm-toolchain-xenial-6.0 packages: - - clang-3.9 - env: COMPILER=clang CLANG=3.9 + - clang-6.0 + env: COMPILER=clang CLANG=6.0 - os: osx osx_image: xcode8 compiler: clang diff --git a/{{cookiecutter.github_project_name}}/CMakeLists.txt b/{{cookiecutter.github_project_name}}/CMakeLists.txt index 9e26a19..35dbd18 100644 --- a/{{cookiecutter.github_project_name}}/CMakeLists.txt +++ b/{{cookiecutter.github_project_name}}/CMakeLists.txt @@ -11,11 +11,11 @@ include_directories(${PROJECT_INCLUDE_DIR}) {% if cookiecutter.cpp_standart == 'C++20' -%} include(CheckCXXCompilerFlag) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG) + CHECK_CXX_COMPILER_FLAG("-std=c++20" HAS_CPP17_FLAG) if (HAS_CPP17_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") else() - message(FATAL_ERROR "Unsupported compiler -- C++14 support required!") + message(FATAL_ERROR "Unsupported compiler -- C++20 support required!") endif() endif() {% if cookiecutter.cpp_standart == 'C++17' -%} @@ -23,9 +23,9 @@ include(CheckCXXCompilerFlag) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG) if (HAS_CPP17_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") else() - message(FATAL_ERROR "Unsupported compiler -- C++14 support required!") + message(FATAL_ERROR "Unsupported compiler -- C++17 support required!") endif() endif() {% elif cookiecutter.cpp_standart == 'C++14' -%} From c0d79e796886b432f92989bfd58dd6118c4146b8 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 9 Sep 2020 10:20:18 +0200 Subject: [PATCH 3/5] changed azure pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1fa8ada..463a14b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ jobs: - job: macOS pool: - vmImage: 'xcode9-macos10.13' + vmImage: 'macOS-10.15' strategy: maxParallel: 2 variables: From 2f475e8cc929cdd9601958646302d6149ea2ff26 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 9 Sep 2020 10:26:11 +0200 Subject: [PATCH 4/5] changed cmakelist --- {{cookiecutter.github_project_name}}/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.github_project_name}}/CMakeLists.txt b/{{cookiecutter.github_project_name}}/CMakeLists.txt index 35dbd18..26b79e8 100644 --- a/{{cookiecutter.github_project_name}}/CMakeLists.txt +++ b/{{cookiecutter.github_project_name}}/CMakeLists.txt @@ -18,7 +18,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" message(FATAL_ERROR "Unsupported compiler -- C++20 support required!") endif() endif() -{% if cookiecutter.cpp_standart == 'C++17' -%} +{% elif cookiecutter.cpp_standart == 'C++17' -%} include(CheckCXXCompilerFlag) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") CHECK_CXX_COMPILER_FLAG("-std=c++17" HAS_CPP17_FLAG) From 543f403fadbac156fe33854bebdece05ade0936b Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 9 Sep 2020 10:28:39 +0200 Subject: [PATCH 5/5] updates --- {{cookiecutter.github_project_name}}/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.github_project_name}}/CMakeLists.txt b/{{cookiecutter.github_project_name}}/CMakeLists.txt index 26b79e8..ff7516d 100644 --- a/{{cookiecutter.github_project_name}}/CMakeLists.txt +++ b/{{cookiecutter.github_project_name}}/CMakeLists.txt @@ -11,8 +11,8 @@ include_directories(${PROJECT_INCLUDE_DIR}) {% if cookiecutter.cpp_standart == 'C++20' -%} include(CheckCXXCompilerFlag) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - CHECK_CXX_COMPILER_FLAG("-std=c++20" HAS_CPP17_FLAG) - if (HAS_CPP17_FLAG) + CHECK_CXX_COMPILER_FLAG("-std=c++20" HAS_CPP20_FLAG) + if (HAS_CPP20_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") else() message(FATAL_ERROR "Unsupported compiler -- C++20 support required!")