File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ else()
109109 set (
110110 _python_find_components
111111 Interpreter
112+ Development.Module
112113 Development.SABIModule
113114 )
114115 else ()
@@ -195,26 +196,11 @@ else()
195196 endif ()
196197
197198 # If a specific Python3_EXECUTABLE is provided by the user, try to infer
198- # the corresponding Python3_ROOT_DIR for Unix/macOS/Linux so CMake's
199- # FindPython3 locates the matching installation or virtual environment.
200- # This is especially important for virtualenv/venv/conda environments.
201- if (
202- DEFINED
203- Python3_EXECUTABLE
204- AND
205- NOT
206- DEFINED
207- Python3_ROOT_DIR
208- AND
209- (
210- UNIX
211- OR
212- APPLE
213- )
214- AND
215- NOT
216- WIN32
217- )
199+ # the corresponding Python3_ROOT_DIR so CMake's FindPython3 locates the
200+ # matching installation or virtual environment.
201+ # This is especially important for virtualenv/venv/conda environments
202+ # and on Windows where FindPython3 may otherwise pick the wrong installation.
203+ if (DEFINED Python3_EXECUTABLE AND NOT DEFINED Python3_ROOT_DIR)
218204 # First, try sys.prefix from the provided interpreter (works for venv/conda)
219205 execute_process (
220206 COMMAND
Original file line number Diff line number Diff line change @@ -159,12 +159,17 @@ set(
159159)
160160
161161if (ITK_WRAP_PYTHON)
162+ if (ITK_USE_PYTHON_LIMITED_API AND TARGET Python3::SABIModule)
163+ set (_itk_python_target Python3::SABIModule)
164+ else ()
165+ set (_itk_python_target Python3::Module)
166+ endif ()
162167 list (APPEND ITKCommon_SRCS itkPyCommand.cxx)
163168 set_source_files_properties (
164169 itkPyCommand.cxx
165170 PROPERTIES
166171 INCLUDE_DIRECTORIES
167- "$<TARGET_PROPERTY :Python3 :: Module ,INTERFACE_INCLUDE_DIRECTORIES >"
172+ "$<TARGET_PROPERTY :${_itk_python_target} ,INTERFACE_INCLUDE_DIRECTORIES >"
168173 )
169174endif ()
170175
@@ -255,7 +260,10 @@ if(UNIX)
255260 endif ()
256261endif ()
257262if (ITK_WRAP_PYTHON)
258- target_link_libraries (ITKCommon PRIVATE Python3::Module )
263+ target_link_libraries (ITKCommon PRIVATE ${_itk_python_target} )
264+ if (MSVC )
265+ target_link_directories (ITKCommon PRIVATE ${Python3_LIBRARY_DIRS} )
266+ endif ()
259267endif ()
260268
261269if (ITK_USE_TBB)
Original file line number Diff line number Diff line change @@ -527,14 +527,16 @@ ${DO_NOT_WAIT_FOR_THREADS_CALLS}
527527 )
528528 else ()
529529 if (MSVC )
530- # Disables 'conversion from 'type1' to 'type2', possible loss of data warnings
530+ # /wd4244: Disables 'conversion from 'type1' to 'type2', possible loss of data warnings
531+ # /wd4996: Disables deprecated declaration warnings in generated wrapper code
531532 set_target_properties (
532533 ${lib}
533534 PROPERTIES
534535 COMPILE_FLAGS
535- "/wd4244"
536+ "/wd4244 /wd4996 "
536537 )
537538 endif ()
539+ target_link_directories (${lib} PUBLIC ${Python3_LIBRARY_DIRS} )
538540 endif ()
539541
540542 # Link the modules together
You can’t perform that action at this time.
0 commit comments