Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation of tests with /std:c++17 #2292

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
Expand All @@ -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*
6 changes: 5 additions & 1 deletion tools/pybind11Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?")
YannickJadoul marked this conversation as resolved.
Show resolved Hide resolved
target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
endif()
endif()
Expand Down