From f7951b9b5e25551a39db3df8266522eede7481a0 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 12 Aug 2024 14:32:31 -0400 Subject: [PATCH] fix(cmake): go back to ALIAS target Signed-off-by: Henry Schreiner --- CMakeLists.txt | 3 +-- tools/pybind11Common.cmake | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) 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()