diff --git a/CMakeLists.txt b/CMakeLists.txt index 81e0d85987..359d510292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,8 +229,7 @@ if(NOT TARGET pybind11_headers) # (long name used here to keep this from clashing in subdirectory mode) add_library(pybind11_headers INTERFACE) add_library(pybind11::pybind11_headers ALIAS pybind11_headers) # to match exported target - add_library(pybind11::headers IMPORTED INTERFACE) - set_target_properties(pybind11::headers PROPERTIES INTERFACE_LINK_LIBRARIES pybind11_headers) + add_library(pybind11::headers ALIAS pybind11_headers) target_include_directories( pybind11_headers ${pybind11_system} INTERFACE $ diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index d8ed0c8878..48c09e2c4e 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -79,14 +79,25 @@ if(CMAKE_SYSTEM_NAME MATCHES Emscripten AND NOT _pybind11_no_exceptions) if(CMAKE_VERSION VERSION_LESS 3.13) message(WARNING "CMake 3.13+ is required to build for Emscripten. Some flags will be missing") else() - set_property( - TARGET pybind11::headers - APPEND - PROPERTY INTERFACE_LINK_OPTIONS -fexceptions) - set_property( - TARGET pybind11::headers - APPEND - PROPERTY INTERFACE_COMPILE_OPTIONS -fexceptions) + if(_pybind11_is_config) + set_property( + TARGET pybind11::pybind11_headers + APPEND + PROPERTY INTERFACE_LINK_OPTIONS -fexceptions) + set_property( + TARGET pybind11::pybind11_headers + APPEND + PROPERTY INTERFACE_COMPILE_OPTIONS -fexceptions) + else() + set_property( + TARGET pybind11_headers + APPEND + PROPERTY INTERFACE_LINK_OPTIONS -fexceptions) + set_property( + TARGET pybind11_headers + APPEND + PROPERTY INTERFACE_COMPILE_OPTIONS -fexceptions) + endif() endif() endif()