From 55c7b7f3806dbabed4176bfd4a68b779fedeb3f7 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Fri, 19 Aug 2022 10:18:11 -0500 Subject: [PATCH] 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 --- CMake/ITKConfig.cmake.in | 2 +- Modules/Bridge/NumPy/CMakeLists.txt | 2 +- Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt | 4 ++-- .../src/itkgoogletest/googletest/cmake/internal_utils.cmake | 6 ------ Utilities/Doxygen/CMakeLists.txt | 2 +- Wrapping/macro_files/itk_end_wrap_module.cmake | 2 +- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CMake/ITKConfig.cmake.in b/CMake/ITKConfig.cmake.in index 6a4a7aab4ce..4457dd9380f 100644 --- a/CMake/ITKConfig.cmake.in +++ b/CMake/ITKConfig.cmake.in @@ -141,4 +141,4 @@ set(ITK_WRAP_complex_double @ITK_WRAP_complex_double@) set(ITK_WRAP_IMAGE_DIMS "@ITK_WRAP_IMAGE_DIMS@") set(ITK_WRAP_VECTOR_COMPONENTS "@ITK_WRAP_VECTOR_COMPONENTS@") -set(ITK_WRAP_PYTHON_VERSION "@PYTHON_VERSION_STRING@") +set(ITK_WRAP_PYTHON_VERSION "@Python3_VERSION@") diff --git a/Modules/Bridge/NumPy/CMakeLists.txt b/Modules/Bridge/NumPy/CMakeLists.txt index 5a01114c844..8807e4b6954 100644 --- a/Modules/Bridge/NumPy/CMakeLists.txt +++ b/Modules/Bridge/NumPy/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16.3) project(ITKBridgeNumPy) -set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +set(ITKBridgeNumPy_SYSTEM_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") if(NOT ITK_SOURCE_DIR) find_package(ITK REQUIRED) diff --git a/Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt b/Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt index 9c3c707b45f..d8d7da3bbc9 100644 --- a/Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt +++ b/Modules/ThirdParty/GDCM/src/gdcm/CMakeLists.txt @@ -455,10 +455,10 @@ endif() #----------------------------------------------------------------------------- # Python install -#find_package(PythonInterp REQUIRED) +#find_package(Python3 COMPONENTS Interpreter REQUIRED) #macro(GET_PYTHON_SITE_PACKAGE dir) # execute_process( -# COMMAND ${PYTHON_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()" +# COMMAND ${Python3_EXECUTABLE} "-c" "from distutils import sysconfig; print sysconfig.get_python_lib()" # #WORKING_DIRECTORY @LIBRARY_OUTPUT_PATH@ # RESULT_VARIABLE import_res # OUTPUT_VARIABLE import_output diff --git a/Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/cmake/internal_utils.cmake b/Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/cmake/internal_utils.cmake index 0cdda064e63..5bd09bfb53d 100644 --- a/Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/cmake/internal_utils.cmake +++ b/Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/cmake/internal_utils.cmake @@ -246,12 +246,6 @@ function(cxx_executable name dir libs) ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN}) endfunction() -# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE. -# ITK The PythonInterp package finding contaminates the cmake cache and -# ITK may find a different version than is use by wrapping or documentation -# ITK generation. DO NOT USE find_package(PythonInterp) -# ITK find_package(PythonInterp) - # cxx_test_with_flags(name cxx_flags libs srcs...) # # creates a named C++ test that depends on the given libs and is built diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 6db6a18382c..6385d64195a 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -97,7 +97,7 @@ if (ITK_BUILD_DOCUMENTATION) file(COPY workbox-cli-config.js serviceWorker.js.in DESTINATION ${ITK_BINARY_DIR}/Utilities/Doxygen/) - execute_process(COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py" + execute_process(COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/datetime.py" RESULT_VARIABLE CMD_RESULT OUTPUT_VARIABLE _DATETIME) diff --git a/Wrapping/macro_files/itk_end_wrap_module.cmake b/Wrapping/macro_files/itk_end_wrap_module.cmake index 1d6e7c5ad42..b754771cbbd 100644 --- a/Wrapping/macro_files/itk_end_wrap_module.cmake +++ b/Wrapping/macro_files/itk_end_wrap_module.cmake @@ -392,7 +392,7 @@ ${DO_NOT_WAIT_FOR_THREADS_CALLS} # Link the modules together target_link_libraries(${lib} LINK_PUBLIC ${WRAPPER_LIBRARY_LINK_LIBRARIES}) - itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${PYTHON_LIBRARY}) + itk_target_link_libraries_with_dynamic_lookup(${lib} LINK_PUBLIC ${Python3_LIBRARIES}) if(USE_COMPILER_HIDDEN_VISIBILITY) # Prefer to use target properties supported by newer cmake