GenerateQtHeaders.cmake 1.1 KB

123456789101112131415161718
  1. function(protobuf_generate_qt_headers)
  2. set(options)
  3. set(oneValueArgs COMPONENT)
  4. set(multiValueArgs PUBLIC_HEADER)
  5. cmake_parse_arguments(protobuf_generate_qt_headers "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  6. foreach(PUBLIC_HEADER IN LISTS protobuf_generate_qt_headers_PUBLIC_HEADER)
  7. get_filename_component(PUBLIC_HEADER_BASE_NAME ${PUBLIC_HEADER} NAME FALSE)
  8. file(STRINGS ${PUBLIC_HEADER} CLASS_NAME REGEX "#pragma once //[a-zA-Z]+")
  9. if (NOT "${CLASS_NAME}" STREQUAL "")
  10. string(REPLACE "#pragma once //" "" CLASS_NAME "${CLASS_NAME}")
  11. message(STATUS "Generate Qt header for ${CLASS_NAME}")
  12. configure_file("${QT_PROTOBUF_CMAKE_DIR}/GeneratedHeaderTemplate" "${QT_PROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME}" @ONLY)
  13. set(GENERATED_PUBLIC_HEADER ${GENERATED_PUBLIC_HEADER} ${QT_PROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME})
  14. endif()
  15. endforeach()
  16. set(GENERATED_PUBLIC_HEADER ${GENERATED_PUBLIC_HEADER} PARENT_SCOPE)
  17. endfunction()