Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
d730fbc0
Commit
d730fbc0
authored
Jun 12, 2018
by
Chuck Atkins
Committed by
Wenzel Jakob
Apr 26, 2020
Browse files
Utilize CMake's language standards abstraction when possible
parent
f6e543b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
tools/pybind11Tools.cmake
tools/pybind11Tools.cmake
+24
-8
No files found.
tools/pybind11Tools.cmake
View file @
d730fbc0
...
...
@@ -18,24 +18,40 @@ find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)
include
(
CheckCXXCompilerFlag
)
include
(
CMakeParseArguments
)
# Use the language standards abstraction if CMake supports it with the current compiler
if
(
NOT CMAKE_VERSION VERSION_LESS 3.1
)
if
(
NOT CMAKE_CXX_STANDARD
)
if
(
CMAKE_CXX14_STANDARD_COMPILE_OPTION
)
set
(
CMAKE_CXX_STANDARD 14
)
elseif
(
CMAKE_CXX11_STANDARD_COMPILE_OPTION
)
set
(
CMAKE_CXX_STANDARD 11
)
endif
()
endif
()
if
(
CMAKE_CXX_STANDARD
)
set
(
CMAKE_CXX_EXTENSIONS OFF
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
endif
()
endif
()
# Fall back to heuristics
if
(
NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD
)
if
(
NOT MSVC
)
if
(
MSVC
)
set
(
PYBIND11_CPP_STANDARD /std:c++14
)
else
()
check_cxx_compiler_flag
(
"-std=c++14"
HAS_CPP14_FLAG
)
if
(
HAS_CPP14_FLAG
)
if
(
HAS_CPP14_FLAG
)
set
(
PYBIND11_CPP_STANDARD -std=c++14
)
else
()
check_cxx_compiler_flag
(
"-std=c++11"
HAS_CPP11_FLAG
)
if
(
HAS_CPP11_FLAG
)
if
(
HAS_CPP11_FLAG
)
set
(
PYBIND11_CPP_STANDARD -std=c++11
)
else
()
message
(
FATAL_ERROR
"Unsupported compiler -- pybind11 requires C++11 support!"
)
endif
()
endif
()
elseif
(
MSVC
)
set
(
PYBIND11_CPP_STANDARD /std:c++14
)
endif
()
if
(
NOT PYBIND11_CPP_STANDARD
)
message
(
FATAL_ERROR
"Unsupported compiler -- pybind11 requires C++11 support!"
)
endif
()
set
(
PYBIND11_CPP_STANDARD
${
PYBIND11_CPP_STANDARD
}
CACHE STRING
"C++ standard flag, e.g. -std=c++11, -std=c++14, /std:c++14. Defaults to C++14 mode."
FORCE
)
endif
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment