diff --git a/Modules/Bridge/NumPy/CMakeLists.txt b/Modules/Bridge/NumPy/CMakeLists.txt index 8807e4b6954..8f734fb8c67 100644 --- a/Modules/Bridge/NumPy/CMakeLists.txt +++ b/Modules/Bridge/NumPy/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.16.3) project(ITKBridgeNumPy) -set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") +# Don't set SYSTEM_INCLUDE_DIRS for Python - handle includes separately +# to avoid CMake errors about source-prefixed paths in INTERFACE properties +set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "") if(NOT ITK_SOURCE_DIR) find_package(ITK REQUIRED) @@ -10,3 +12,13 @@ if(NOT ITK_SOURCE_DIR) else() itk_module_impl() endif() + +# Add Python includes using BUILD_INTERFACE generator expression +# This ensures they're only used during build, not in exports +if(Python3_INCLUDE_DIRS AND TARGET ITKBridgeNumPyModule) + target_include_directories(ITKBridgeNumPyModule + SYSTEM + INTERFACE + $ + ) +endif()