CMakeLists.txt 3.4 KB

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