Skip to content

Commit 6ebfc4b

Browse files
ax3lwjakob
authored andcommitted
Document CMAKE_CXX_STANDARD
This variable is a CMake community standard to set the C++ standard of a build. Document it in favor of the previous variable, which stays as a legacy flag for existing projects. https://cmake.org/cmake/help/v3.17/variable/CMAKE_CXX_STANDARD.html
1 parent d730fbc commit 6ebfc4b

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

docs/compiling.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,14 @@ on the target compiler, falling back to C++11 if C++14 support is not
105105
available. Note, however, that this default is subject to change: future
106106
pybind11 releases are expected to migrate to newer C++ standards as they become
107107
available. To override this, the standard flag can be given explicitly in
108-
``PYBIND11_CPP_STANDARD``:
108+
`CMAKE_CXX_STANDARD <https://cmake.org/cmake/help/v3.17/variable/CMAKE_CXX_STANDARD.html>`_:
109109

110110
.. code-block:: cmake
111111
112112
# Use just one of these:
113-
# GCC/clang:
114-
set(PYBIND11_CPP_STANDARD -std=c++11)
115-
set(PYBIND11_CPP_STANDARD -std=c++14)
116-
set(PYBIND11_CPP_STANDARD -std=c++1z) # Experimental C++17 support
117-
# MSVC:
118-
set(PYBIND11_CPP_STANDARD /std:c++14)
119-
set(PYBIND11_CPP_STANDARD /std:c++latest) # Enables some MSVC C++17 features
113+
set(CMAKE_CXX_STANDARD 11)
114+
set(CMAKE_CXX_STANDARD 14)
115+
set(CMAKE_CXX_STANDARD 17) # Experimental C++17 support
120116
121117
add_subdirectory(pybind11) # or find_package(pybind11)
122118

tools/pybind11Config.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#
2929
# Python headers, libraries (as needed by platform), and the C++ standard
3030
# are attached to the target. Set PythonLibsNew variables to influence
31-
# python detection and PYBIND11_CPP_STANDARD (-std=c++11 or -std=c++14) to
32-
# influence standard setting. ::
31+
# python detection and CMAKE_CXX_STANDARD (11 or 14) to influence standard
32+
# setting. ::
3333
#
3434
# find_package(pybind11 CONFIG REQUIRED)
3535
# message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")

0 commit comments

Comments
 (0)