PythonQtGenerator.cmake 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # PythonQtGenerator
  3. #
  4. SET(PythonQtGenerator_DEPENDS)
  5. IF(CTK_WRAP_PYTHONQT_FULL)
  6. # Sanity checks
  7. IF(DEFINED PYTHONQTGENERATOR_EXECUTABLE AND NOT EXISTS ${PYTHONQTGENERATOR_EXECUTABLE})
  8. MESSAGE(FATAL_ERROR "PYTHONQTGENERATOR_EXECUTABLE variable is defined but corresponds to non-existing executable")
  9. ENDIF()
  10. IF(NOT DEFINED PYTHONQTGENERATOR_EXECUTABLE)
  11. # Set CMake OSX variable to pass down the external project
  12. set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS)
  13. if(APPLE)
  14. list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS
  15. -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
  16. -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
  17. -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
  18. endif()
  19. #
  20. # PythonQtGenerator is the tool allowing to generate the PythonQt decorators using
  21. # typesystem xml files. If called without any option, it will generate the bindings for Qt.
  22. #
  23. # See http://www.pyside.org/docs/apiextractor/typesystem.html
  24. # See http://doc.trolltech.com/qtjambi-4.5.2_01/com/trolltech/qt/qtjambi-typesystem.html
  25. # See http://qt.gitorious.org/qt-labs/qtscriptgenerator
  26. #
  27. SET(proj PythonQtGenerator)
  28. # MESSAGE(STATUS "Adding project:${proj}")
  29. SET(PythonQtGenerator_DEPENDS ${proj})
  30. #
  31. # If directory PythonQt already exists, the corresponding project will
  32. # be cloned. Since PythonQt and PythonQtGenerator source code are hosted
  33. # on the same repository, we will assume that if the directory PythonQt
  34. # exists, the generator code will also be available.
  35. #
  36. IF(EXISTS ${CMAKE_BINARY_DIR}/PythonQt)
  37. #MESSAGE(STATUS "ExternalProject/PythonQtGenerator: PythonQt already added as ExternalProject")
  38. ExternalProject_Add(${proj}
  39. SOURCE_DIR ${CMAKE_BINARY_DIR}/PythonQt/generator
  40. BINARY_DIR ${proj}-build
  41. PREFIX ${proj}${ep_suffix}
  42. DOWNLOAD_COMMAND ""
  43. CMAKE_GENERATOR ${gen}
  44. INSTALL_COMMAND ""
  45. CMAKE_CACHE_ARGS
  46. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  47. -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
  48. -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
  49. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  50. ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS}
  51. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  52. DEPENDS
  53. "PythonQt" # To make sure the generator code is checked out, let's depend on PythonQt
  54. )
  55. ELSE()
  56. SET(revision_tag 3171a94e16ba9bfee137)
  57. IF(${proj}_REVISION_TAG)
  58. SET(revision_tag ${${proj}_REVISION_TAG})
  59. ENDIF()
  60. #MESSAGE(STATUS "ExternalProject/PythonQtGenerator: PythonQt is NOT an ExternalProject")
  61. ExternalProject_Add(${proj}
  62. SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
  63. BINARY_DIR ${proj}-build
  64. PREFIX ${proj}${ep_suffix}
  65. GIT_REPOSITORY "${git_protocol}://github.com/commontk/PythonQt.git"
  66. GIT_TAG 3171a94e16ba9bfee137
  67. CMAKE_GENERATOR ${gen}
  68. UPDATE_COMMAND ""
  69. INSTALL_COMMAND ""
  70. CMAKE_CACHE_ARGS
  71. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  72. -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags}
  73. -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags}
  74. -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir}
  75. ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS}
  76. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  77. )
  78. ENDIF()
  79. SET(PYTHONQTGENERATOR_EXECUTABLE ${CMAKE_BINARY_DIR}/PythonQtGenerator-build/PythonQtGenerator)
  80. # Since PythonQtGenerator is an executable, there is no need to add its corresponding
  81. # library output directory to CTK_EXTERNAL_LIBRARY_DIRS
  82. ENDIF()
  83. LIST(APPEND CTK_SUPERBUILD_EP_VARS PYTHONQTGENERATOR_EXECUTABLE:FILEPATH)
  84. ENDIF()