Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Corryvreckan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabian Simon Lex
Corryvreckan
Commits
e2242c1f
Commit
e2242c1f
authored
3 years ago
by
Simon Spannagel
Browse files
Options
Downloads
Patches
Plain Diff
Require C++17
parent
34833cf7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+17
-5
17 additions, 5 deletions
CMakeLists.txt
cmake/compiler-version-checks.cmake
+51
-0
51 additions, 0 deletions
cmake/compiler-version-checks.cmake
with
68 additions
and
5 deletions
CMakeLists.txt
+
17
−
5
View file @
e2242c1f
...
...
@@ -98,16 +98,28 @@ SET(COMPILER_FLAGS -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wconversion
INCLUDE
(
"cmake/compiler-flag-checks.cmake"
)
# Check for C++17 and require C++17 if available else fallback to C++14 (should currently be sufficient)
# Use CCache if available
FIND_PROGRAM
(
CCACHE_FOUND ccache
)
IF
(
CCACHE_FOUND
)
MESSAGE
(
STATUS
"Using Ccache:
${
CCACHE_FOUND
}
"
)
SET
(
CMAKE_CXX_COMPILER_LAUNCHER
"
${
CCACHE_FOUND
}
"
CACHE PATH
"CCache program"
FORCE
)
ENDIF
()
# Require C++17
CHECK_CXX_COMPILER_FLAG
(
-std=c++17 SUPPORT_STD_CXX17
)
IF
(
SUPPORT_STD_CXX17
)
SET
(
CMAKE_CXX_STANDARD 17
)
ELSE
()
SET
(
CMAKE_CXX_STANDARD 14
)
IF
(
NOT SUPPORT_STD_CXX17
)
MESSAGE
(
FATAL_ERROR
"Compiler does not support required standard C++17"
)
ENDIF
()
SET
(
CMAKE_CXX_STANDARD 17
)
SET
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
SET
(
CMAKE_CXX_EXTENSIONS OFF
)
# Check if compiler version supports all features:
INCLUDE
(
"cmake/compiler-version-checks.cmake"
)
# Set some debug flags
# FIXME: not using the flag checker now because it wrongly rejects a sanitizer flag..
IF
(
CMAKE_BUILD_TYPE MATCHES Debug
AND
((
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
OR
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)))
...
...
This diff is collapsed.
Click to expand it.
cmake/compiler-version-checks.cmake
0 → 100644
+
51
−
0
View file @
e2242c1f
# General overview for compiler support of CXX language and library features:
# https://en.cppreference.com/w/cpp/compiler_support
#
# TODO: at some point this should probably be replaced by a proper use of CMAKE_CXX_COMPILE_FEATURES
# https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html
# Minimum GCC versions for C++14 and C++17 feature support.
# based on
# https://gcc.gnu.org/projects/cxx-status.html
# https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
SET
(
GCC_CXX_14_VERSION_MIN
"6.1"
)
SET
(
GCC_CXX_17_VERSION_MIN
"8.0"
)
# Minimum Clang versions for C++14 and C++17 feature support.
# based on
# https://clang.llvm.org/cxx_status.html
SET
(
CLANG_CXX_14_VERSION_MIN
"3.4"
)
SET
(
CLANG_CXX_17_VERSION_MIN
"7.0"
)
# Minimum Apple Clang versions for C++14 and C++17 feature support.
# based on
# https://trac.macports.org/wiki/XcodeVersionInfo
SET
(
APPLECLANG_CXX_14_VERSION_MIN
"6.1"
)
SET
(
APPLECLANG_CXX_17_VERSION_MIN
"10.0"
)
IF
(
CMAKE_CXX_STANDARD EQUAL 17
)
SET
(
GCC_VERSION_MIN
${
GCC_CXX_17_VERSION_MIN
}
)
SET
(
CLANG_VERSION_MIN
${
CLANG_CXX_17_VERSION_MIN
}
)
SET
(
APPLECLANG_VERSION_MIN
${
APPLECLANG_CXX_17_VERSION_MIN
}
)
ELSE
()
SET
(
GCC_VERSION_MIN
${
GCC_CXX_14_VERSION_MIN
}
)
SET
(
CLANG_VERSION_MIN
${
CLANG_CXX_14_VERSION_MIN
}
)
SET
(
APPLECLANG_VERSION_MIN
${
APPLECLANG_CXX_14_VERSION_MIN
}
)
ENDIF
()
IF
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
IF
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_VERSION_MIN
)
MESSAGE
(
FATAL_ERROR
"Requiring at least GCC version
${
GCC_VERSION_MIN
}
. Available version"
"
${
CMAKE_CXX_COMPILER_VERSION
}
does not fully support required C++ features"
)
ENDIF
()
ELSEIF
(
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
IF
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_VERSION_MIN
)
MESSAGE
(
FATAL_ERROR
"Requiring at least Clang version
${
CLANG_VERSION_MIN
}
. Available version"
"
${
CMAKE_CXX_COMPILER_VERSION
}
does not fully support required C++ features"
)
ENDIF
()
ELSEIF
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
IF
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS APPLECLANG_VERSION_MIN
)
MESSAGE
(
FATAL_ERROR
"Requiring at least AppleClang version
${
APPLECLANG_VERSION_MIN
}
. Available version"
"
${
CMAKE_CXX_COMPILER_VERSION
}
does not fully support required C++ features"
)
ENDIF
()
ENDIF
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment