diff --git a/.appveyor.yml b/.appveyor.yml index 8fbb726108..ed646f944d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,22 +12,22 @@ platform: environment: matrix: - PYTHON: 36 - CPP: 14 + CPP: 17 CONFIG: Debug - PYTHON: 27 - CPP: 14 + CPP: 17 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: | @@ -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_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%"=="latest" (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/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..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, @@ -217,9 +219,11 @@ 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") + 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() @@ -247,7 +251,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