From 9a7dfeffdcf2ec66f08e53f2f05cd0ad7509cc32 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sat, 11 Jul 2020 18:12:34 +0200 Subject: [PATCH 1/3] Change /std:c++latest flag to /std:c++17 and quote it, since CMake otherwise doesn't seem to pick it up --- .appveyor.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 8fbb726108..d654a7a1e2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -18,16 +18,16 @@ environment: CPP: 14 CONFIG: Debug - CONDA: 36 - CPP: latest + CPP: 17 CONFIG: Release matrix: exclude: - image: Visual Studio 2015 platform: x86 - image: Visual Studio 2015 - CPP: latest + CPP: 17 - image: Visual Studio 2017 - CPP: latest + CPP: 17 platform: x86 install: - ps: | @@ -58,7 +58,7 @@ install: $env:CMAKE_INCLUDE_PATH = "eigen-eigen-67e894c6cd8f;$env:CMAKE_INCLUDE_PATH" build_script: - cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" - -DPYBIND11_CPP_STANDARD=/std:c++%CPP% + -DPYBIND11_CPP_STANDARD="/std:c++%CPP%" -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DCMAKE_SUPPRESS_REGENERATION=1 @@ -66,5 +66,5 @@ build_script: - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% - cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% -- if "%CPP%"=="latest" (cmake --build . --config %CONFIG% --target test_cmake_build -- /m /v:m /logger:%MSBuildLogger%) +- if "%CPP%"=="17" (cmake --build . --config %CONFIG% --target test_cmake_build -- /m /v:m /logger:%MSBuildLogger%) on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* From f995cfce6c2914d8a8c793bfae37eafaee2ad12b Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 12 Jul 2020 01:22:49 +0200 Subject: [PATCH 2/3] Don't use $ to add PYBIND11_CPP_STANDARD for VS CMake generators --- tools/pybind11Config.cmake.in | 2 +- tools/pybind11Tools.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/pybind11Config.cmake.in b/tools/pybind11Config.cmake.in index 58426887a5..5186c925ea 100644 --- a/tools/pybind11Config.cmake.in +++ b/tools/pybind11Config.cmake.in @@ -90,7 +90,7 @@ if(NOT TARGET ${PN}::pybind11) set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES}) endif() - if(CMAKE_VERSION VERSION_LESS 3.3) + if(CMAKE_VERSION VERSION_LESS 3.3 OR CMAKE_GENERATOR MATCHES "Visual Studio") set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}") else() set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$:${PYBIND11_CPP_STANDARD}>) diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index a3603abe97..729a293718 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -217,7 +217,7 @@ function(pybind11_add_module target_name) # Make sure C++11/14 are enabled if(PYBIND11_CPP_STANDARD) - if(CMAKE_VERSION VERSION_LESS 3.3) + if(CMAKE_VERSION VERSION_LESS 3.3 OR CMAKE_GENERATOR MATCHES "Visual Studio") target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD}) else() target_compile_options(${target_name} PUBLIC $<$:${PYBIND11_CPP_STANDARD}>) @@ -247,7 +247,7 @@ function(pybind11_add_module target_name) # /MP enables multithreaded builds (relevant when there are many files), /bigobj is # needed for bigger binding projects due to the limit to 64k addressable sections target_compile_options(${target_name} PRIVATE /bigobj) - if(CMAKE_VERSION VERSION_LESS 3.11) + if(CMAKE_VERSION VERSION_LESS 3.11 OR CMAKE_GENERATOR MATCHES "Visual Studio") target_compile_options(${target_name} PRIVATE $<$>:/MP>) else() # Only set these options for C++ files. This is important so that, for From f7f3847f33328921b48c52a181c5644b15dd9f12 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sat, 11 Jul 2020 19:17:51 +0200 Subject: [PATCH 3/3] Debugging non-failure of /std:c++17 --- .appveyor.yml | 16 ++++++++-------- tools/pybind11Tools.cmake | 6 +++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index d654a7a1e2..ed646f944d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,10 +12,10 @@ platform: environment: matrix: - PYTHON: 36 - CPP: 14 + CPP: 17 CONFIG: Debug - PYTHON: 27 - CPP: 14 + CPP: 17 CONFIG: Debug - CONDA: 36 CPP: 17 @@ -35,7 +35,6 @@ install: if ($env:APPVEYOR_JOB_NAME -like "*Visual Studio 2017*") { $env:CMAKE_GENERATOR = "Visual Studio 15 2017" $env:CMAKE_INCLUDE_PATH = "C:\Libraries\boost_1_64_0" - $env:CXXFLAGS = "-permissive-" } else { $env:CMAKE_GENERATOR = "Visual Studio 14 2015" } @@ -57,14 +56,15 @@ install: 7z x 3.3.3.zip -y > $null $env:CMAKE_INCLUDE_PATH = "eigen-eigen-67e894c6cd8f;$env:CMAKE_INCLUDE_PATH" build_script: +- set VERBOSE=1 +- cmake --version - cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" - -DPYBIND11_CPP_STANDARD="/std:c++%CPP%" + -DPYBIND11_CPP_STANDARD=/std:c++%CPP% -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - -DCMAKE_SUPPRESS_REGENERATION=1 . - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -- cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% -- cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% -- if "%CPP%"=="17" (cmake --build . --config %CONFIG% --target test_cmake_build -- /m /v:m /logger:%MSBuildLogger%) +- cmake --build . --config %CONFIG% --target pytest -- /m /logger:%MSBuildLogger% +- cmake --build . --config %CONFIG% --target cpptest -- /m /logger:%MSBuildLogger% +- if "%CPP%"=="17" (cmake --build . --config %CONFIG% --target test_cmake_build -- /m /logger:%MSBuildLogger%) on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index 729a293718..7f12bc6b2a 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -20,7 +20,7 @@ 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(NOT CMAKE_CXX_STANDARD AND NOT PYBIND11_CPP_STANDARD) if(CMAKE_CXX14_STANDARD_COMPILE_OPTION) set(CMAKE_CXX_STANDARD 14) elseif(CMAKE_CXX11_STANDARD_COMPILE_OPTION) @@ -56,6 +56,8 @@ if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD) "C++ standard flag, e.g. -std=c++11, -std=c++14, /std:c++14. Defaults to C++14 mode." FORCE) endif() +message(PYBIND11_CPP_STANDARD = ${PYBIND11_CPP_STANDARD}) + # Checks whether the given CXX/linker flags can compile and link a cxx file. cxxflags and # linkerflags are lists of flags to use. The result variable is a unique variable name for each set # of flags: the compilation result will be cached base on the result variable. If the flags work, @@ -218,8 +220,10 @@ function(pybind11_add_module target_name) # Make sure C++11/14 are enabled if(PYBIND11_CPP_STANDARD) if(CMAKE_VERSION VERSION_LESS 3.3 OR CMAKE_GENERATOR MATCHES "Visual Studio") + message("HERE, I hope?") target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD}) else() + message("NOT HERE, I hope?") target_compile_options(${target_name} PUBLIC $<$:${PYBIND11_CPP_STANDARD}>) endif() endif()