Generalize cmake compiler support - #1428
Conversation
|
This is going to change the default flag to At the moment I mildly prefer the defaults going to the stricter language version (i.e. skipping the |
|
I get it, and I actually agree that keeping the default to use no extensions is preferred. So, really the motivation for doing it this way was to mimic CMake's behavior for language standards abstraction. In CMake >= 3.1 (which is when the language standards abstraction was first introduced), the default behavior is to have CXX extensions enabled. This was primarily to make CMake's default behavior match the default behavior of compilers that build with newer standards by default now. Most of them enable extensions by default as well. You can explicitly disable them with |
262653d to
bb8e389
Compare
|
Not sure why this would cause the Travis failure but I'll look into it |
bb8e389 to
8a10107
Compare
8a10107 to
58e551c
Compare
|
@chuckatkins CI fixed :) |
|
I borked these commit so let me rebase and push the correct ones... |
1954404 to
9241ae5
Compare
| if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD) | ||
| if(NOT MSVC) | ||
| if(MSVC) | ||
| set(PYBIND11_CPP_STANDARD /std:c++14) |
There was a problem hiding this comment.
This line is potentially problematic. The version requirement for pybind11 is MSVC 2015 Update 3. I don't think it will be able to deal with C++14 mode.
There was a problem hiding this comment.
MSVC 2015 Update 3 is the one that introduced /std:c++14 and /std:c++latest.
https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/
There was a problem hiding this comment.
Hm good point -- and I forgot that we're actually testing MSVC 2015 on AppVeyor.
There was a problem hiding this comment.
FWIW the MSVC behavior isn't changed in this PR from what it was before. I only inverted the if/else order to have the larger, most often followed, code block to be the if condition rather than the else.
|
Looks good to me – @jagerman ? |
|
Looks good to me. |
|
ping? |
|
One more change needed before merging: the documentation for compiling should be updated to reference the newer cmake style. It's a nicer approach and is likely to fit better with other cmake projects in the future. I have one other question: what happens if someone is using the existing PYBIND11_CPP_STANDARD and updates pybind -- does the project continue to build with the current flags? (In other words, is the |
|
@chuckatkins : I think this is basically ready to be merged, except for the documentation by @jagerman above. Could you please add this? Thanks! |
|
Will we ever merge a PR from a CMake co-author / Kitware employee that sits two doors from the CMake maintainers and just add the docs about changing style wishes ourselves? ;-) Yes, all |
|
Happy to merge it, but I don't have the clock cycles to look into documenting this atm. (Remote working with a two-year old who is bored out of her mind has been quite the challenge.) @ax3l -- if you want this merged, can you open a new PR based on this one? |
|
Sure thing, please see #2184. |
|
Merged via #2184 |
|
Thanks @chuckatkins and @ax3l |
Related to #1381