PythonQt.cmake 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #
  2. # PythonQt
  3. #
  4. superbuild_include_once()
  5. set(proj PythonQt)
  6. set(${proj}_enabling_variable PYTHONQT_LIBRARIES)
  7. set(${${proj}_enabling_variable}_INCLUDE_DIRS PYTHONQT_INCLUDE_DIR PYTHON_INCLUDE_DIRS)
  8. set(${${proj}_enabling_variable}_FIND_PACKAGE_CMD ${proj})
  9. set(${proj}_DEPENDENCIES "")
  10. superbuild_include_dependencies(${proj})
  11. if(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
  12. message(FATAL_ERROR "Enabling ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj} is not supported !")
  13. endif()
  14. # Sanity checks
  15. if(DEFINED PYTHONQT_INSTALL_DIR AND NOT EXISTS ${PYTHONQT_INSTALL_DIR})
  16. message(FATAL_ERROR "PYTHONQT_INSTALL_DIR variable is defined but corresponds to non-existing directory")
  17. endif()
  18. if(NOT DEFINED PYTHONQT_INSTALL_DIR)
  19. set(ep_PythonQt_args)
  20. # Should PythonQt use VTK
  21. if(CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  22. list(APPEND proj_DEPENDENCIES VTK)
  23. endif()
  24. # Enable Qt libraries PythonQt wrapping if required
  25. set(qtlibs core gui network opengl sql svg uitools webkit xml)
  26. foreach(qtlib All ${qtlibs})
  27. string(TOUPPER ${qtlib} qtlib_uppercase)
  28. list(APPEND ep_PythonQt_args -DPythonQt_Wrap_Qt${qtlib}:BOOL=${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib_uppercase}})
  29. endforeach()
  30. # Force wrap option to ON if WRAP_QTALL was set to ON
  31. if(${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTALL})
  32. foreach(qtlib ${qtlibs})
  33. string(TOUPPER ${qtlib} qtlib_uppercase)
  34. set(CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib_uppercase} ON CACHE BOOL "Enable Scripting/Python/Core Library PYTHONQT_WRAP_QT${qtlib_uppercase} option" FORCE)
  35. endforeach()
  36. endif()
  37. # Python is required
  38. find_package(PythonLibs)
  39. if(NOT PYTHONLIBS_FOUND)
  40. message(FATAL_ERROR "error: Python is required to build ${PROJECT_NAME}")
  41. endif()
  42. set(revision_tag e1f1c77d9675c3c5fb1cba19d2a32ace483eda2c)
  43. if(${proj}_REVISION_TAG)
  44. set(revision_tag ${${proj}_REVISION_TAG})
  45. endif()
  46. set(location_args )
  47. if(${proj}_URL)
  48. set(location_args URL ${${proj}_URL})
  49. elseif(${proj}_GIT_REPOSITORY)
  50. set(location_args GIT_REPOSITORY ${${proj}_GIT_REPOSITORY}
  51. GIT_TAG ${revision_tag})
  52. else()
  53. set(location_args GIT_REPOSITORY "${git_protocol}://github.com/commontk/PythonQt.git"
  54. GIT_TAG ${revision_tag})
  55. endif()
  56. ExternalProject_Add(${proj}
  57. ${${proj}_EXTERNAL_PROJECT_ARGS}
  58. SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
  59. BINARY_DIR ${proj}-build
  60. PREFIX ${proj}${ep_suffix}
  61. ${location_args}
  62. CMAKE_GENERATOR ${gen}
  63. UPDATE_COMMAND ""
  64. BUILD_COMMAND ""
  65. LIST_SEPARATOR ${sep}
  66. CMAKE_CACHE_ARGS
  67. ${ep_common_cache_args}
  68. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  69. -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}
  70. -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
  71. ${ep_PythonQt_args}
  72. DEPENDS
  73. ${${proj}_DEPENDENCIES}
  74. )
  75. set(PYTHONQT_INSTALL_DIR ${ep_install_dir})
  76. # Since the full path of PythonQt library is used, there is not need to add
  77. # its corresponding library output directory to CTK_EXTERNAL_LIBRARY_DIRS
  78. else()
  79. superbuild_add_empty_external_project(${proj} "${${proj}_DEPENDENCIES}")
  80. endif()
  81. mark_as_superbuild(
  82. VARS
  83. PYTHONQT_INSTALL_DIR:PATH
  84. PYTHON_EXECUTABLE:FILEPATH # FindPythonInterp expects PYTHON_EXECUTABLE variable to be defined
  85. PYTHON_INCLUDE_DIR:PATH # FindPythonQt expects PYTHON_INCLUDE_DIR variable to be defined
  86. PYTHON_LIBRARY:FILEPATH # FindPythonQt expects PYTHON_LIBRARY variable to be defined
  87. LABELS "FIND_PACKAGE"
  88. )