Skip to content

Commit 4733798

Browse files
committed
ENH: Update for ITK 5.1rc02
1 parent 468ce74 commit 4733798

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,62 @@ if(PYTHON_EXECUTABLE AND NOT ITK_WRAP_PYTHON)
154154
set(ITK_WRAP_PYTHON 1)
155155
endif()
156156
endif()
157+
if(BUILD_TESTING OR ITK_BUILD_DOCUMENTATION OR ITK_WRAP_PYTHON)
158+
# Prefer to use more robust FindPython3 module if greater than cmake 3.12.0
159+
if("${CMAKE_VERSION}" VERSION_LESS_EQUAL "3.12.0")
160+
# Use of PythonInterp and PythonLibs is deprecated since cmake version 3.12.0
161+
# Only use deprecated mechanisms for older versions of cmake
162+
set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5)
163+
find_package(PythonInterp)
164+
if(ITK_WRAP_PYTHON)
165+
find_package(PythonLibs REQUIRED)
166+
# check for version mismatch.
167+
if(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
168+
AND NOT(PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING))
169+
message(FATAL_ERROR "Python executable (\"${PYTHON_VERSION_STRING}\") and library (\"${PYTHONLIBS_VERSION_STRING}\") version mismatch.")
170+
endif()
171+
endif()
172+
if(PYTHON_VERSION_STRING VERSION_LESS 3.5)
173+
# if python version is less than 3.5, unset so that it appears that no python version is found.
174+
# to emulate the same behavior as find(Python3 ..) from cmake 3.12.0+
175+
unset(PYTHON_EXECUTABLE)
176+
unset(PYTHONINTERP_FOUND)
177+
unset(PYTHON_VERSION_STRING)
178+
unset(PYTHON_INCLUDE_DIRS)
179+
else()
180+
## For forward compatibility with cmake 3.12.0 or greater, emulate variable names from FindPython3.cmake
181+
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
182+
set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND})
183+
set(Python3_VERSION ${PYTHON_VERSION_STRING})
184+
185+
set(Python3_Development_FOUND ${PYTHONLIBS_FOUND})
186+
set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
187+
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
188+
endif()
189+
else()
190+
if(ITK_WRAP_PYTHON)
191+
if(DEFINED Python3_EXECUTABLE)
192+
set(_specified_Python3_EXECUTABLE ${Python3_EXECUTABLE})
193+
endif()
194+
find_package(Python3 COMPONENTS Interpreter Development)
195+
set(Python3_EXECUTABLE ${_specified_Python3_EXECUTABLE} CACHE INTERNAL
196+
"Path to the Python interpreter" FORCE)
197+
else()
198+
find_package(Python3 COMPONENTS Interpreter)
199+
endif()
200+
if(NOT Python3_EXECUTABLE AND _Python3_EXECUTABLE)
201+
set(Python3_EXECUTABLE ${_Python3_EXECUTABLE} CACHE INTERNAL
202+
"Path to the Python interpreter" FORCE)
203+
endif()
204+
endif()
205+
206+
if(ITK_WRAP_PYTHON AND Python3_VERSION VERSION_LESS 3.5)
207+
message(FATAL_ERROR "Python versions less than 3.5 are not supported for wrapping. Python version: \"${Python3_VERSION}\".")
208+
endif()
209+
if(ITK_WRAP_PYTHON AND NOT Python3_INCLUDE_DIRS)
210+
message(FATAL_ERROR "Python version ${Python3_VERSION} development environment not found for wrapping.")
211+
endif()
212+
endif()
157213

158214
# Build the documentation?
159215
option(BUILD_DOCUMENTATION "Build the examples documentation." OFF)

Superbuild/External-ITK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ endif()
3030
set(_wrap_python_args )
3131
if(ITKExamples_USE_WRAP_PYTHON)
3232
set(_python_depends)
33-
if(NOT EXISTS PYTHON_EXECUTABLE)
33+
if(NOT EXISTS Python3_EXECUTABLE)
3434
set(_python_depends ITKPython)
3535
endif()
3636
set(_wrap_python_args
37-
"-DPYTHON_EXECUTABLE:FILEPATH=${ITKPYTHON_EXECUTABLE}"
37+
"-DPython3_EXECUTABLE:FILEPATH=${ITKPython3_EXECUTABLE}"
3838
)
3939
endif()
4040

itk-module.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set(DOCUMENTATION "This module builds the examples found at https://github.com/I
33
itk_module(SphinxExamples
44
DEPENDS
55
ITKCommon
6-
EXCLUDE_FROM_DEFAULT
76
DESCRIPTION
87
"${DOCUMENTATION}"
9-
)
8+
EXCLUDE_FROM_DEFAULT
9+
)

0 commit comments

Comments
 (0)