Missing registry paths in FindPythonLibs.cmake as well as FindPython/Support.cmake
FindPython/Support.cmake used by FindPython2 and FindPython3 is missing a couple of registry entry paths to search in.
The -{_
{_PYTHON_PREFIX}_ARCH} suffix used to find python libs in the Anaconda registry paths should be added for the PythonCore entries as well.
Attached are FindPythonLibs.cmake and Support.cmake with the additional fixes for registry paths. The fix for FindPythonLibs.cmake is created by basically copying from Support.cmake to add additional logic to find the -32 and -64 suffix registry entries. FindPythonLibs.cmake
If anyone reads this and needs a workaround (hack) this is what we did when using FindPythonLibs:
find_package( PythonLibs 3 )
if( PYTHONLIBS_FOUND )
set( PYTHON_VER ${PYTHONLIBS_VERSION_STRING} CACHE STRING "Located python version" FORCE )
else ()
if( WIN32 )
# For all windows distributions: define which architectures can be used
if (CMAKE_SIZEOF_VOID_P)
# In this case, search only for 64bit or 32bit
math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
set (_${_PYTHON_PREFIX}_ARCH2 ${_${_PYTHON_PREFIX}_ARCH})
else()
# architecture unknown, search for both 64bit and 32bit
set (_${_PYTHON_PREFIX}_ARCH 64)
set (_${_PYTHON_PREFIX}_ARCH2 32)
endif()
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
find_library(PYTHON_LIBRARY
NAMES
python${_CURRENT_VERSION_NO_DOTS}
python${_CURRENT_VERSION}mu
python${_CURRENT_VERSION}m
python${_CURRENT_VERSION}u
python${_CURRENT_VERSION}
NAMES_PER_DIR
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]/libs
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]/libs
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]/libs
)
endforeach()
find_package( PythonLibs 3 )
endif()
if( PYTHONLIBS_FOUND )
set( PYTHON_VER ${PYTHONLIBS_VERSION_STRING} CACHE STRING "Located python version" FORCE )
else()
set( PYTHON_VER "UNDEFINED" CACHE STRING "Located python version" FORCE )
message( WARNING "Unable to locate Python3")
endif()
endif()