21,22c21,22
< function(select_cxx_standard)
< if(NOT MSVC AND NOT PYBIND11_CPP_STANDARD)
---
> if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD)
> if(NOT MSVC)
24d23
< check_cxx_compiler_flag("-std=c++11" HAS_CPP11_FLAG)
28,29d26
< elseif (HAS_CPP11_FLAG)
< set(PYBIND11_CPP_STANDARD -std=c++11)
31c28,33
< message(FATAL_ERROR "Unsupported compiler -- pybind11 requires C++11 support!")
---
> check_cxx_compiler_flag("-std=c++11" HAS_CPP11_FLAG)
> if (HAS_CPP11_FLAG)
> set(PYBIND11_CPP_STANDARD -std=c++11)
> else()
> message(FATAL_ERROR "Unsupported compiler -- pybind11 requires C++11 support!")
> endif()
33,35c35,36
<
< set(PYBIND11_CPP_STANDARD ${PYBIND11_CPP_STANDARD} CACHE STRING
< "C++ standard flag, e.g. -std=c++11 or -std=c++14. Defaults to latest available." FORCE)
---
> elseif(MSVC)
> set(PYBIND11_CPP_STANDARD /std:c++14)
37d37
< endfunction()
38a39,42
> set(PYBIND11_CPP_STANDARD ${PYBIND11_CPP_STANDARD} CACHE STRING
> "C++ standard flag, e.g. -std=c++11, -std=c++14, /std:c++14. Defaults to C++14 mode." FORCE)
> endif()
>
137a142,148
> # -fvisibility=hidden is required to allow multiple modules compiled against
> # different pybind versions to work properly, and for some features (e.g.
> # py::module_local). We force it on everything inside the `pybind11`
> # namespace; also turning it on for a pybind module compilation here avoids
> # potential warnings or issues from having mixed hidden/non-hidden types.
> set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
>
164,168c175,176
< select_cxx_standard()
< if(NOT MSVC)
< # Make sure C++11/14 are enabled
< target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
< endif()
---
> # Make sure C++11/14 are enabled
> target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
177,179d184
< # Set the default symbol visibility to hidden (very important to obtain small binaries)
< target_compile_options(${target_name} PRIVATE "-fvisibility=hidden")
<