Skip to content

Commit 0fcc3a2

Browse files
committed
COMP: Update Python.h include path, and linkage
Set include directories for Python wrapping from Python3::Module target. Changed Python header inclusion to use angle brackets for consistency. Added include directory properties for `itkPyCommand.cxx` to improve Python wrapping configuration. Add Python linking in ITKCommon when ITK_WRAP_PYTHON - Updated `ITKCommon` to link against appropriate Python libraries when Python wrapping is enabled. - Differentiated linking logic for LIMITED_API and non-LIMITED_API configurations.
1 parent 69b640b commit 0fcc3a2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Modules/Core/Common/include/itkPyCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// The python header defines _POSIX_C_SOURCE without a preceding #undef
2525
#undef _POSIX_C_SOURCE
2626
#undef _XOPEN_SOURCE
27-
#include "Python.h"
27+
#include <Python.h>
2828

2929
namespace itk
3030
{

Modules/Core/Common/src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ set(
160160

161161
if(ITK_WRAP_PYTHON)
162162
list(APPEND ITKCommon_SRCS itkPyCommand.cxx)
163+
set_source_files_properties(
164+
itkPyCommand.cxx
165+
PROPERTIES
166+
INCLUDE_DIRECTORIES
167+
"$<TARGET_PROPERTY:Python3::Module,INTERFACE_INCLUDE_DIRECTORIES>"
168+
)
163169
endif()
164170

165171
if(WIN32)
@@ -248,6 +254,9 @@ if(UNIX)
248254
target_link_libraries(ITKCommon LINK_PUBLIC ${CMAKE_DL_LIBS})
249255
endif()
250256
endif()
257+
if(ITK_WRAP_PYTHON)
258+
target_link_libraries(ITKCommon PRIVATE Python3::Python)
259+
endif()
251260

252261
if(ITK_USE_TBB)
253262
# https://software.intel.com/en-us/node/506139

0 commit comments

Comments
 (0)