Skip to content

Commit 55c7b7f

Browse files
hjmjohnsondzenanz
authored andcommitted
ENH: Run script for Python3 find_package upgrade
Now that cmake FindPython3 can be universally used, prefer to only use that set of variable names for identifying the python executables. Intial procesing with manual cleanup by: ITK/Utilities/Maintenance/FindPython3_ModernizeCMake.sh
1 parent bfa85dd commit 55c7b7f

6 files changed

Lines changed: 6 additions & 12 deletions

File tree

CMake/ITKConfig.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ set(ITK_WRAP_complex_double @ITK_WRAP_complex_double@)
141141
set(ITK_WRAP_IMAGE_DIMS "@ITK_WRAP_IMAGE_DIMS@")
142142
set(ITK_WRAP_VECTOR_COMPONENTS "@ITK_WRAP_VECTOR_COMPONENTS@")
143143

144-
set(ITK_WRAP_PYTHON_VERSION "@PYTHON_VERSION_STRING@")
144+
set(ITK_WRAP_PYTHON_VERSION "@Python3_VERSION@")

Modules/Bridge/NumPy/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.16.3)
22
project(ITKBridgeNumPy)
33

4-
set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
4+
set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
55

66
if(NOT ITK_SOURCE_DIR)
77
find_package(ITK REQUIRED)

Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ endif()
455455

456456
#-----------------------------------------------------------------------------
457457
# Python install
458-
#find_package(PythonInterp REQUIRED)
458+
#find_package(Python3 COMPONENTS Interpreter REQUIRED)
459459
#macro(GET_PYTHON_SITE_PACKAGE dir)
460460
# execute_process(
461-
# COMMAND ${PYTHON_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()"
461+
# COMMAND ${Python3_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()"
462462
# #WORKING_DIRECTORY @LIBRARY_OUTPUT_PATH@
463463
# RESULT_VARIABLE import_res
464464
# OUTPUT_VARIABLE import_output

Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/cmake/internal_utils.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ function(cxx_executable name dir libs)
246246
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
247247
endfunction()
248248

249-
# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
250-
# ITK The PythonInterp package finding contaminates the cmake cache and
251-
# ITK may find a different version than is use by wrapping or documentation
252-
# ITK generation. DO NOT USE find_package(PythonInterp)
253-
# ITK find_package(PythonInterp)
254-
255249
# cxx_test_with_flags(name cxx_flags libs srcs...)
256250
#
257251
# creates a named C++ test that depends on the given libs and is built

Utilities/Doxygen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if (ITK_BUILD_DOCUMENTATION)
9797
file(COPY workbox-cli-config.js serviceWorker.js.in
9898
DESTINATION ${ITK_BINARY_DIR}/Utilities/Doxygen/)
9999

100-
execute_process(COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py"
100+
execute_process(COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py"
101101
RESULT_VARIABLE CMD_RESULT
102102
OUTPUT_VARIABLE _DATETIME)
103103

Wrapping/macro_files/itk_end_wrap_module.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ ${DO_NOT_WAIT_FOR_THREADS_CALLS}
392392

393393
# Link the modules together
394394
target_link_libraries(${lib} LINK_PUBLIC ${WRAPPER_LIBRARY_LINK_LIBRARIES})
395-
itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${PYTHON_LIBRARY})
395+
itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${Python3_LIBRARIES})
396396

397397
if(USE_COMPILER_HIDDEN_VISIBILITY)
398398
# Prefer to use target properties supported by newer cmake

0 commit comments

Comments
 (0)