FileGLOBBER.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # For private plugins, this is a shortcut to add all cpp, h, and ui files without listing them
  2. # in their own CMakeLists.txt files.
  3. #
  4. # It will look in the plugin's top-level directory and in the src, include, and ui directories.
  5. #
  6. # This is provided for convenience, but you should understand GLOB and its benefits and drawbacks.
  7. # See: https://cmake.org/cmake/help/latest/command/file.html#filesystem
  8. #
  9. # To use it, simply add the following line to your plugin's top-level CMakeList.txt file:
  10. # include( FileGLOBBER )
  11. file( GLOB
  12. PLUGIN_HEADERS
  13. ${CMAKE_CURRENT_SOURCE_DIR}/*.h
  14. ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
  15. )
  16. file( GLOB
  17. PLUGIN_SOURCES
  18. ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
  19. ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
  20. )
  21. file( GLOB
  22. PLUGIN_UI_FILES
  23. ${CMAKE_CURRENT_SOURCE_DIR}/*.ui
  24. ${CMAKE_CURRENT_SOURCE_DIR}/ui/*.ui
  25. )
  26. target_include_directories( ${PROJECT_NAME}
  27. PRIVATE
  28. ${CMAKE_CURRENT_SOURCE_DIR}
  29. ${CMAKE_CURRENT_SOURCE_DIR}/include
  30. )
  31. target_sources( ${PROJECT_NAME}
  32. PRIVATE
  33. ${PLUGIN_HEADERS}
  34. ${PLUGIN_SOURCES}
  35. ${PLUGIN_UI_FILES}
  36. )
  37. unset( PLUGIN_HEADERS )
  38. unset( PLUGIN_SOURCES )
  39. unset( PLUGIN_UI_FILES )