From 868d94fcb4769ad3a5d826c9f5483376433da8a5 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Tue, 11 Jun 2019 16:05:00 -0400 Subject: [PATCH] Apply c++ standard flag only to files of CXX language. (#1678) --- tools/pybind11Config.cmake.in | 6 +++++- tools/pybind11Tools.cmake | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/pybind11Config.cmake.in b/tools/pybind11Config.cmake.in index 3dd1b2c1a..8a7272ff9 100644 --- a/tools/pybind11Config.cmake.in +++ b/tools/pybind11Config.cmake.in @@ -90,7 +90,11 @@ if(NOT TARGET ${PN}::pybind11) set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES}) endif() - set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}") + if(CMAKE_VERSION VERSION_LESS 3.3) + 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}>) + endif() get_property(_iid TARGET ${PN}::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) get_property(_ill TARGET ${PN}::module PROPERTY INTERFACE_LINK_LIBRARIES) diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index ab8bf6270..e3ec572b5 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -185,7 +185,11 @@ function(pybind11_add_module target_name) endif() # Make sure C++11/14 are enabled - target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD}) + if(CMAKE_VERSION VERSION_LESS 3.3) + target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD}) + else() + target_compile_options(${target_name} PUBLIC $<$:${PYBIND11_CPP_STANDARD}>) + endif() if(ARG_NO_EXTRAS) return()