You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This started in the discussion for #1089. The core issue was that C++ flags mix into C compilation, because PyBind has it's own implementation of C++ flags, and it doesn't include a way to separate C code.
CMake 2.8 was released in 2009, long before C++11 (much less the other standards) were released. Modern CMake does have a way to select C++ versions, and PyBind can be in contention with them.
Method 1: CMake 3.1+: CMAKE_CXX_STANDARD (and CMAKE_CXX_STANDARD_REQUIRED, CMAKE_CXX_EXTENSIONS). The current implementation does include checks for these, and turns off custom flags.
Method 2: CMake 3.1+: Manually listing features with target_compile_features. This was supposed to be the "best" way to do things, but listing every feature in C++11 is tedious.
Method 3: CMake 3.8: Meta-compile features were added for C++ standards, finally allowing target_compile_features(my_target PUBLIC cxx_std_11) or similar.
The first method is checked and appropriately handled by pybind11. The final method is not well supported by pybind11. I believe that by leaving PYBIND_CPP_STANDARD on CMake 3.8+, PyBind should default to this method. This should allow overriding the standard (automatically handled by CMake if you request it on a pybind target), as well as keep the C++/C separate without non-portable generator expressions.
And we can avoid the awful CPP/CXX mixed name by phasing out PYBIND_CPP_STANDARD on new targets 😉.
The text was updated successfully, but these errors were encountered:
This started in the discussion for #1089. The core issue was that C++ flags mix into C compilation, because PyBind has it's own implementation of C++ flags, and it doesn't include a way to separate C code.
CMake 2.8 was released in 2009, long before C++11 (much less the other standards) were released. Modern CMake does have a way to select C++ versions, and PyBind can be in contention with them.
Method 1: CMake 3.1+:
CMAKE_CXX_STANDARD
(andCMAKE_CXX_STANDARD_REQUIRED
,CMAKE_CXX_EXTENSIONS
). The current implementation does include checks for these, and turns off custom flags.Method 2: CMake 3.1+: Manually listing features with
target_compile_features
. This was supposed to be the "best" way to do things, but listing every feature in C++11 is tedious.Method 3: CMake 3.8: Meta-compile features were added for C++ standards, finally allowing
target_compile_features(my_target PUBLIC cxx_std_11)
or similar.The first method is checked and appropriately handled by pybind11. The final method is not well supported by pybind11. I believe that by leaving
PYBIND_CPP_STANDARD
on CMake 3.8+, PyBind should default to this method. This should allow overriding the standard (automatically handled by CMake if you request it on a pybind target), as well as keep the C++/C separate without non-portable generator expressions.And we can avoid the awful CPP/CXX mixed name by phasing out
PYBIND_CPP_STANDARD
on new targets 😉.The text was updated successfully, but these errors were encountered: