GenerateQtHeaders.cmake 1.1 KB

123456789101112131415161718
  1. function(protobuf_generate_qt_headers)
  2. set(options)
  3. set(oneValueArgs COMPONENT)
  4. set(multiValueArgs PUBLIC_HEADERS)
  5. cmake_parse_arguments(protobuf_generate_qt_headers "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  6. foreach(PUBLIC_HEADER IN LISTS protobuf_generate_qt_headers_PUBLIC_HEADERS)
  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("-- Generate Qt header for ${CLASS_NAME}")
  12. configure_file("${QTPROTOBUF_CMAKE_DIR}/GeneratedHeaderTemplate" "${QTPROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME}" @ONLY)
  13. set(GENERATED_PUBLIC_HEADERS ${GENERATED_PUBLIC_HEADERS} ${QTPROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME})
  14. endif()
  15. endforeach()
  16. set(GENERATED_PUBLIC_HEADERS ${GENERATED_PUBLIC_HEADERS} PARENT_SCOPE)
  17. endfunction()