PythonQt.cmake 3.2 KB

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