Переглянути джерело

Fixes for building with namespaced Qt

The generated files also need the defines from QtCore to
get the QT_NAMESPACE define
Mårten Nordheim 3 роки тому
батько
коміт
9e9f7f4fcd

+ 5 - 0
cmake/QtProtobufGen.cmake

@@ -162,6 +162,11 @@ function(qtprotobuf_generate)
         set_property(TARGET ${qtprotobuf_generate_TARGET} APPEND PROPERTY PUBLIC_HEADER ${GENERATED_HEADERS_FULL})
     endif()
     set_target_properties(${GENERATED_TARGET_NAME} PROPERTIES PUBLIC_HEADER "${GENERATED_HEADERS_FULL}")
+    get_target_property(CORE_DEFINITIONS Qt6::Core INTERFACE_COMPILE_DEFINITIONS)
+    target_compile_definitions(${GENERATED_TARGET_NAME} PRIVATE ${CORE_DEFINITIONS})
+    if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
+        target_compile_options(${GENERATED_TARGET_NAME} PRIVATE /Zc:__cplusplus /permissive-)
+    endif()
 
     #Add include directories in case if targets are found by find_project or in source tree
     target_include_directories(${GENERATED_TARGET_NAME} PUBLIC ${OUT_DIR} PRIVATE

+ 1 - 1
src/grpc/qabstractgrpcchannel.h

@@ -34,7 +34,7 @@
 #include "qgrpccredentials.h"
 #include "qtgrpcglobal.h"
 
-class QThread;
+QT_FORWARD_DECLARE_CLASS(QThread);
 
 namespace QtProtobuf {
 

+ 1 - 1
src/grpc/quick/qquickgrpcstream_p.h

@@ -86,7 +86,7 @@
  * \endcode
  */
 
-class QJSValue;
+QT_FORWARD_DECLARE_CLASS(QJSValue);
 
 namespace QtProtobuf {
 

+ 3 - 0
src/protobuf/qprotobufserializationplugininterface.h

@@ -27,6 +27,7 @@
 
 #include <QObject>
 #include <QString>
+#include <QtCore/qglobal.h>
 
 #include <unordered_map>
 #include <memory>
@@ -95,5 +96,7 @@ public:
 };
 
 }
+QT_BEGIN_NAMESPACE
 #define SerializatorInterface_iid "com.qtprotobuf.QProtobufSerializationPluginInterface"
 Q_DECLARE_INTERFACE(QtProtobuf::QProtobufSerializationPluginInterface, SerializatorInterface_iid)
+QT_END_NAMESPACE