Pybind11: PYBIND11_CPP_STANDARD detects and adds the /std:c++14 flag when CMAKE_CXX_STANDARD 17 resulting in both flags

Created on 13 Aug 2017  路  3Comments  路  Source: pybind/pybind11

Hi!

I'm using the latest VS 2017 Preview (15.3.0 Preview 7.1) with the latest CMake nightly (cmake-3.9.20170812-g71ee6).

CMake has recently added support for set(CMAKE_CXX_STANDARD 17) on MSVC, which will set /std:c++17 (in fact it sets -std:c++17 which still works but I guess they should use the slash instead so that the VS IDE displays it correctly) (https://gitlab.kitware.com/cmake/cmake/issues/16482).

Now pybind11 detects PYBIND11_CPP_STANDARD to be /std:c++14, and adds the /std:c++14 flag in addition to /std:c++17 which is added by CMake, resulting in a (benign) compiler warning:

cl : Command line warning D9025: overriding '/std:c++14' with '/std:c++17'

I realise I'm a bit cutting-edge here but both of these things will be released officially soon so we may well improve them now or at least have it on the radar.
I think the logic here (https://github.com/pybind/pybind11/blob/master/tools/pybind11Tools.cmake#L35) will need some adjustments. I'm happy to try to change it if you give me some guidance, or test a fix.

Cheers!

Most helpful comment

The fix has been merged. Thanks very much for reporting and testing this!

All 3 comments

Can you check if #999 works as intended? The flag duplication affects all compilers, it's just that others don't warn about it.

Ah, nice idea your fix!

I tested #999 and I can confirm it works for above use-case, PYBIND11_CPP_STANDARD stays empty and /std:c++14 does not get set (and everything still compiles fine).

Excellent! Thank you.

The fix has been merged. Thanks very much for reporting and testing this!

Was this page helpful?
0 / 5 - 0 ratings