PythonQt.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #
  2. # PythonQt
  3. #
  4. superbuild_include_once()
  5. set(PythonQt_enabling_variable PYTHONQT_LIBRARIES)
  6. set(${PythonQt_enabling_variable}_INCLUDE_DIRS PYTHONQT_INCLUDE_DIR PYTHON_INCLUDE_DIRS)
  7. set(${PythonQt_enabling_variable}_FIND_PACKAGE_CMD PythonQt)
  8. set(PythonQt_DEPENDENCIES "")
  9. ctkMacroCheckExternalProjectDependency(PythonQt)
  10. set(proj PythonQt)
  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. SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
  58. BINARY_DIR ${proj}-build
  59. PREFIX ${proj}${ep_suffix}
  60. ${location_args}
  61. CMAKE_GENERATOR ${gen}
  62. UPDATE_COMMAND ""
  63. BUILD_COMMAND ""
  64. LIST_SEPARATOR ${sep}
  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. # Since the full path of PythonQt library is used, there is not need to add
  76. # its corresponding library output directory to CTK_EXTERNAL_LIBRARY_DIRS
  77. else()
  78. ctkMacroEmptyExternalproject(${proj} "${${proj}_DEPENDENCIES}")
  79. endif()
  80. list(APPEND CTK_SUPERBUILD_EP_VARS
  81. PYTHONQT_INSTALL_DIR:PATH
  82. PYTHON_EXECUTABLE:FILEPATH # FindPythonInterp expects PYTHON_EXECUTABLE variable to be defined
  83. PYTHON_INCLUDE_DIR:PATH # FindPythonQt expects PYTHON_INCLUDE_DIR variable to be defined
  84. PYTHON_LIBRARY:FILEPATH # FindPythonQt expects PYTHON_LIBRARY variable to be defined
  85. )