Warning, /sdk/pology/cmake/FindPython3.cmake is written in an unsupported language. File is not indexed.

0001 # TODO: Add doc comments.
0002 
0003 include(FindPackageHandleStandardArgs)
0004 
0005 set(py_version_script ${CMAKE_BINARY_DIR}/python3_version.py)
0006 file(WRITE ${py_version_script} "
0007 import sys
0008 sys.stdout.write('.'.join(map(str, sys.version_info[:3])))
0009 ")
0010 
0011 set(py_pkgdir_script ${CMAKE_BINARY_DIR}/python3_pkgdir.py)
0012 file(WRITE ${py_pkgdir_script} "
0013 import sys, distutils.sysconfig
0014 sys.stdout.write(distutils.sysconfig.get_python_lib())
0015 ")
0016 
0017 if(NOT PYTHON3_EXECUTABLE)
0018     find_program(PYTHON3_EXECUTABLE NAMES python3 python)
0019     message(STATUS
0020         "Looking for Python 3 executable "
0021         "(use -DPYTHON3_EXECUTABLE= to set manually)...")
0022 else()
0023     if(NOT EXISTS ${PYTHON3_EXECUTABLE})
0024         set(PYTHON3_EXECUTABLE no)
0025     endif()
0026 endif()
0027 
0028 if(PYTHON3_EXECUTABLE)
0029     execute_process(COMMAND ${PYTHON3_EXECUTABLE} ${py_version_script}
0030                     OUTPUT_VARIABLE PYTHON3_VERSION)
0031 
0032     if(NOT PYTHON3_PACKAGES_DIR)
0033         set(foo ${CMAKE_CURRENT_LIST_DIR})
0034         message(STATUS
0035             "Looking for Python 3 packages directory "
0036             "(use -DPYTHON3_PACKAGES_DIR= to set manually)...")
0037         execute_process(COMMAND ${PYTHON3_EXECUTABLE} ${py_pkgdir_script}
0038                         OUTPUT_VARIABLE PYTHON3_PACKAGES_DIR)
0039         if(PYTHON3_PACKAGES_DIR)
0040             message(STATUS
0041                 "Found Python 3 packages directory: ${PYTHON3_PACKAGES_DIR}")
0042         endif()
0043     else()
0044         if(NOT IS_DIRECTORY ${PYTHON3_PACKAGES_DIR})
0045             set(PYTHON3_PACKAGES_DIR no)
0046         endif()
0047     endif()
0048 
0049     set(PYTHON3_PACKAGES_DIR ${PYTHON3_PACKAGES_DIR}
0050         CACHE PATH "Python 3 packages directory.")
0051 endif()
0052 
0053 find_package_handle_standard_args(Python3
0054     REQUIRED_VARS PYTHON3_EXECUTABLE PYTHON3_PACKAGES_DIR
0055     VERSION_VAR PYTHON3_VERSION
0056 )