Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Core Modules
dune-common
Commits
acdec4ee
Commit
acdec4ee
authored
9 years ago
by
Steffen Müthing
Browse files
Options
Downloads
Patches
Plain Diff
[CMake] Move C++14 check into separate function
parent
45cdc4b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!46
[CMake] Rewrite C++ standard detection
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmake/modules/CheckCXXFeatures.cmake
+22
-14
22 additions, 14 deletions
cmake/modules/CheckCXXFeatures.cmake
with
22 additions
and
14 deletions
cmake/modules/CheckCXXFeatures.cmake
+
22
−
14
View file @
acdec4ee
...
...
@@ -30,6 +30,25 @@ include(CMakePushCheckState)
include
(
CheckCXXCompilerFlag
)
include
(
CheckCXXSourceCompiles
)
function
(
dune_check_cxx_14 COMPILER_SUPPORT_VAR
)
check_cxx_source_compiles
(
"
#include <memory>
int main() {
// lambdas with auto parameters are C++14 - so this checks the compiler
auto l = [](auto x) { return x; };
// std::make_unique() is a C++14 library feature - this checks whether the
// compiler uses a C++14 compliant library to work around problems like
// self-installed clang with an older, C++11 only system compiler
auto v = std::make_unique<int>(l(0));
return *v;
}
"
CHECK_COMPILER_SUPPORTS_CXX14
)
set
(
${
COMPILER_SUPPORT_VAR
}
${
CHECK_COMPILER_SUPPORTS_CXX14
}
PARENT_SCOPE
)
endfunction
()
# test for C++14 flags
if
(
NOT DISABLE_CXX_VERSION_CHECK
)
...
...
@@ -38,14 +57,9 @@ if(NOT DISABLE_CXX_VERSION_CHECK)
cmake_push_check_state
()
set
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
-std=c++14"
)
check_cxx_source_compiles
(
"
#include <memory>
int main() {
std::make_unique<int>();
}
"
CXX_LIB_SUPPORTS_CXX14
)
dune_check_cxx_14
(
CXX_LIB_SUPPORTS_CXX14
)
cmake_pop_check_state
()
endif
()
if
(
CXX_FLAG_CXX14 AND CXX_LIB_SUPPORTS_CXX14
)
...
...
@@ -63,13 +77,7 @@ else()
cmake_push_check_state
()
set
(
CMAKE_REQUIRED_FLAGS
"
${
CMAKE_REQUIRED_FLAGS
}
-std=c++1y"
)
check_cxx_source_compiles
(
"
#include <memory>
int main() {
std::make_unique<int>();
}
"
CXX_LIB_SUPPORTS_CXX1Y
)
dune_check_cxx_14
(
CXX_LIB_SUPPORTS_CXX1Y
)
cmake_pop_check_state
()
endif
()
if
(
CXX_FLAG_CXX1Y AND CXX_LIB_SUPPORTS_CXX1Y
)
...
...
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