CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. project(ctkSimplePythonShell)
  2. #
  3. # See CTK/CMake/ctkMacroBuildApp.cmake for details
  4. #
  5. set(KIT_SRCS
  6. ${CMAKE_CURRENT_BINARY_DIR}/ctkSimplePythonManager.cpp
  7. ctkSimplePythonManager.h
  8. ctkSimplePythonQtDecorators.h
  9. ctkSimplePythonShellMain.cpp
  10. ctkTestWrappedQProperty.h
  11. ctkTestWrappedQInvokable.h
  12. ctkTestWrappedSlot.h
  13. )
  14. if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  15. list(APPEND KIT_SRCS
  16. ctkTestWrappedQListOfVTKObject.h
  17. ctkTestWrappedVTKObserver.h
  18. ctkTestWrappedVTKQInvokable.h
  19. ctkTestWrappedVTKSlot.h
  20. )
  21. endif()
  22. # Headers that should run through moc
  23. set(KIT_MOC_SRCS
  24. ctkSimplePythonManager.h
  25. ctkSimplePythonQtDecorators.h
  26. ctkTestWrappedQProperty.h
  27. ctkTestWrappedQInvokable.h
  28. ctkTestWrappedSlot.h
  29. )
  30. if(CTK_LIB_Scripting/Python/Core AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
  31. list(APPEND KIT_MOC_SRCS
  32. ctkTestWrappedQListOfVTKObject.h
  33. ctkTestWrappedVTKObserver.h
  34. ctkTestWrappedVTKQInvokable.h
  35. ctkTestWrappedVTKSlot.h
  36. )
  37. endif()
  38. # UI files
  39. set(KIT_UI_FORMS
  40. )
  41. # Resources
  42. set(KIT_resources
  43. )
  44. set(VTK_LIBRARIES
  45. )
  46. # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
  47. # The following macro will read the target libraries from the file 'target_libraries.cmake'
  48. ctkFunctionGetTargetLibraries(KIT_target_libraries)
  49. # Configure file will be configured using CTK_WRAP_PYTHONQT_LIGHT and
  50. # CTK_BUILD_SHARED_LIBS variables
  51. configure_file(
  52. ctkSimplePythonShellConfigure.h.in
  53. ${CMAKE_CURRENT_BINARY_DIR}/ctkSimplePythonShellConfigure.h
  54. )
  55. # The following block generate the code required to initialize the wrapper
  56. # when CTK is statically built.
  57. if(NOT CTK_BUILD_SHARED_LIBS AND CTK_WRAP_PYTHONQT_LIGHT)
  58. # Update list of target libraries with the list of available PythonQt libraries
  59. # and set variables holding list of pythonqt initialization method
  60. set(CTK_PYTHONQT_INITIALIZATION_METHOD_DEFINITION)
  61. set(CTK_PYTHONQT_INITIALIZATION_METHOD_CALL)
  62. # To avoid the complex process of resolving the dependencies associated with each
  63. # external project required by each decorator. For now, let's just include the decorator
  64. # associated with CTKCore and CTKWidgets.
  65. set(MY_CTK_WRAPPED_LIBRARIES_PYTHONQT)
  66. if(CTK_LIB_Core)
  67. list(APPEND MY_CTK_WRAPPED_LIBRARIES_PYTHONQT CTKCore)
  68. endif()
  69. if(CTK_LIB_Widgets)
  70. list(APPEND MY_CTK_WRAPPED_LIBRARIES_PYTHONQT CTKWidgets)
  71. endif()
  72. if(CTK_LIB_DICOM/Core)
  73. list(APPEND MY_CTK_WRAPPED_LIBRARIES_PYTHONQT CTKDICOMCore)
  74. endif()
  75. if(CTK_LIB_DICOM/Widgets)
  76. list(APPEND MY_CTK_WRAPPED_LIBRARIES_PYTHONQT CTKDICOMWidgets)
  77. endif()
  78. foreach(lib_name ${MY_CTK_WRAPPED_LIBRARIES_PYTHONQT})
  79. list(APPEND KIT_target_libraries ${lib_name}PythonQt)
  80. set(CTK_PYTHONQT_INITIALIZATION_METHOD_DEFINITION
  81. "${CTK_PYTHONQT_INITIALIZATION_METHOD_DEFINITION}
  82. extern \"C\"{ void init${lib_name}PythonQt(); }")
  83. set(CTK_PYTHONQT_INITIALIZATION_METHOD_CALL
  84. "${CTK_PYTHONQT_INITIALIZATION_METHOD_CALL}
  85. init${lib_name}PythonQt();")
  86. endforeach()
  87. endif()
  88. configure_file(
  89. ctkSimplePythonManager.cpp.in
  90. ${CMAKE_CURRENT_BINARY_DIR}/ctkSimplePythonManager.cpp
  91. )
  92. ctkMacroBuildApp(
  93. NAME ${PROJECT_NAME}
  94. SRCS ${KIT_SRCS}
  95. MOC_SRCS ${KIT_MOC_SRCS}
  96. UI_FORMS ${KIT_UI_FORMS}
  97. TARGET_LIBRARIES ${KIT_target_libraries}
  98. RESOURCES ${KIT_resources}
  99. )
  100. add_subdirectory(Python)
  101. # Testing
  102. if(BUILD_TESTING)
  103. add_subdirectory(Testing)
  104. endif()