Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
d730fbc0
Commit
d730fbc0
authored
Jun 12, 2018
by
Chuck Atkins
Committed by
Wenzel Jakob
Apr 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utilize CMake's language standards abstraction when possible
parent
f6e543b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
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)
...
@@ -18,24 +18,40 @@ find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)
include
(
CheckCXXCompilerFlag
)
include
(
CheckCXXCompilerFlag
)
include
(
CMakeParseArguments
)
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 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
)
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
)
set
(
PYBIND11_CPP_STANDARD -std=c++14
)
else
()
else
()
check_cxx_compiler_flag
(
"-std=c++11"
HAS_CPP11_FLAG
)
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
)
set
(
PYBIND11_CPP_STANDARD -std=c++11
)
else
()
message
(
FATAL_ERROR
"Unsupported compiler -- pybind11 requires C++11 support!"
)
endif
()
endif
()
endif
()
endif
()
elseif
(
MSVC
)
set
(
PYBIND11_CPP_STANDARD /std:c++14
)
endif
()
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
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
)
"C++ standard flag, e.g. -std=c++11, -std=c++14, /std:c++14. Defaults to C++14 mode."
FORCE
)
endif
()
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