Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionInstallPython.cmake
Go to the documentation of this file.
1 #! This CMake macro installs the python runtime with
2 #! all python related libraries and toolkits. Py files are
3 #! searched one by one with a globbing expression to generate a list used
4 #! by the mac and NSIS installer.
5 #!
6 #! params:
7 #! _python_libs Returns a list of the installed libraries. Used to fixup the bundle.
8 #! _app_bundle App bundle name in case of a Apple bundle.
9 #!
10 function(mitkFunctionInstallPython _python_libs_out _search_path_out _app_bundle)
11 
12  # install the python runtime from the superbuild
13  if(NOT MITK_USE_SYSTEM_PYTHON)
14 
15  # find package sets the python version numbers
16  find_package(PythonLibs REQUIRED)
17  find_package(PythonInterp REQUIRED)
18 
19  set(_python_libs )
20  set(_search_path )
21 
22  # set the destination bundle
23  set(_destination bin)
24  if(APPLE)
25  set(_destination ${_app_bundle})
26  endif()
27 
28  if(UNIX)
29  list(APPEND _python_dirs "${MITK_EXTERNAL_PROJECT_PREFIX}/lib")
30  set(PYTHON_LIB_SUFFIX ".so")
31  set(_py_include_postfix python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/) # add the slash here so windows and unix will work with same code
32  set(_python_runtime_dir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/)
33  else() #WIN32
34  list(APPEND _python_dirs "${MITK_EXTERNAL_PROJECT_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/Lib")
35  #list(APPEND _python_dirs "${Python_DIR}/bin")
36  set(PYTHON_LIB_SUFFIX .pyd)
37  set(_py_include_postfix )
38  set(_python_runtime_dir )
39  set(_search_path "${MITK_EXTERNAL_PROJECT_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/bin")
40  endif()
41 
42  file(GLOB_RECURSE item RELATIVE "${_python_dirs}/${_python_runtime_dir}" "${_python_dirs}/${_python_runtime_dir}*")
43  foreach(f ${item})
44  get_filename_component(_filepath "${f}" PATH)
45  #message("f: " ${f})
46  #message("filepath: " ${_filepath})
47  install(FILES "${_python_dirs}/${_python_runtime_dir}${f}" DESTINATION "${_destination}/Python/lib/${_python_runtime_dir}${_filepath}")
48 
49  #MESSAGE("in: " "${_python_dirs}/${_python_runtime_dir}${f}")
50  #MESSAGE("out: " "${_destination}/Python/lib/${_python_runtime_dir}${_filepath}")
51  if(${f} MATCHES "(${PYTHON_LIB_SUFFIX})$")
52  #MESSAGE("F: " "Python/lib/${_python_runtime_dir}${f}")
53  list(APPEND _python_libs "Python/lib/${_python_runtime_dir}${f}")
54  if(UNIX AND NOT APPLE)
55  install(CODE "file(RPATH_REMOVE
56  FILE \"\${CMAKE_INSTALL_PREFIX}/bin/Python/lib/${_python_runtime_dir}${f}\")")
57  endif()
58  endif()
59  endforeach()
60 
61  # config will by read out at runtime
62  install(FILES "${PYTHON_INCLUDE_DIR}/pyconfig.h" DESTINATION ${_destination}/Python/include/${_py_include_postfix})
63 
64  set(${_python_libs_out} ${_python_libs} PARENT_SCOPE)
65  set(${_search_path_out} ${_search_path} PARENT_SCOPE)
66  endif()
67 endfunction()
68 
mitkFunctionInstallPython(_python_libs_out, _search_path_out, _app_bundle)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244