Skip to content

Commit 4784176

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. Update Python linking and remove unused development component Ensure `ITKCommon` links to `Python3::Module` instead of `Python3::Python`. Adjust Python3 component configuration to exclude unused `Development`, addressing limitations in dockcross build environments.
1 parent 8ca847f commit 4784176

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CMake/ITKSetPython3Vars.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ else()
4949
${PYTHON_VERSION_MIN}...${PYTHON_VERSION_MAX}
5050
COMPONENTS
5151
Interpreter
52-
Development # Needed for Modules/Core/Common/src/itkPyCommand.cxx
52+
# NOTE: dockcross build environments do not supply
53+
# `Development` python-dev resources
5354
Development.Module
5455
Development.SABIModule
5556
NumPy
@@ -108,14 +109,12 @@ else()
108109
set(
109110
_python_find_components
110111
Interpreter
111-
Development # Needed for Modules/Core/Common/src/itkPyCommand.cxx
112112
Development.SABIModule
113113
)
114114
else()
115115
set(
116116
_python_find_components
117117
Interpreter
118-
Development # Needed for Modules/Core/Common/src/itkPyCommand.cxx
119118
Development.Module
120119
)
121120
endif()

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::Module)
259+
endif()
251260

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

0 commit comments

Comments
 (0)