PythonQt.cmake 3.2 KB

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