Browse Source

Align cmake variable names to unified style

- Cleanup cmake procedures of unused variables
- All global scope variables are QT_PROTOBUF_ prefixed as standard
- Reorganize and update README

Fixes: #72
Alexey Edelev 5 years ago
parent
commit
12598a66fc

+ 25 - 24
CMakeLists.txt

@@ -1,13 +1,15 @@
 cmake_minimum_required(VERSION 3.1)
 
-set(QTPROTOBUF_PROJECT_VERSION 0.1.0)
-project(QtProtobufProject VERSION ${QTPROTOBUF_PROJECT_VERSION} LANGUAGES CXX)
+set(QT_PROTOBUF_VERSION 0.1.0)
+set(QT_PROTOBUF_PROJECT QtProtobufProject)
+
+project(${QT_PROTOBUF_PROJECT} VERSION ${QT_PROTOBUF_VERSION} LANGUAGES CXX)
 
 include(GNUInstallDirs)
 
-set(QTPROTOBUF_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-set(QTPROTOBUF_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
-set(QTPROTOBUF_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(QT_PROTOBUF_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+set(QT_PROTOBUF_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(QT_PROTOBUF_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
 
 find_package(Qt5 COMPONENTS Core Network Qml REQUIRED)
 if(Qt5Core_VERSION VERSION_LESS "5.12.3")
@@ -29,15 +31,14 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/grpc/CMakeLists.txt")
         set(gRPC_FOUND TRUE)
     endif()
 else()
-    include("${QTPROTOBUF_CMAKE_DIR}/ProtobufLookup.cmake")
-    include("${QTPROTOBUF_CMAKE_DIR}/gRPCLookup.cmake")
+    include("${QT_PROTOBUF_CMAKE_DIR}/ProtobufLookup.cmake")
+    include("${QT_PROTOBUF_CMAKE_DIR}/gRPCLookup.cmake")
 endif()
 
 set(gtest_force_shared_crt OFF)
-set(QTPROTOBUF_COMMON_NAMESPACE QtProtobufProject)
 set(GENERATOR_TARGET qtprotobufgen)
-set(QTPROTOBUF_EXECUTABLE_INSTALL ${CMAKE_INSTALL_FULL_BINDIR}/${GENERATOR_TARGET})
-set(QTPROTOBUF_EXECUTABLE $<TARGET_FILE:${GENERATOR_TARGET}> CACHE STRING "QTPROTOBUF_EXECUTABLE is set ${QTPROTOBUF_EXECUTABLE}" FORCE)
+set(QT_PROTOBUF_EXECUTABLE_INSTALL ${CMAKE_INSTALL_FULL_BINDIR}/${GENERATOR_TARGET})
+set(QT_PROTOBUF_EXECUTABLE $<TARGET_FILE:${GENERATOR_TARGET}> CACHE STRING "QT_PROTOBUF_EXECUTABLE is set ${QT_PROTOBUF_EXECUTABLE}" FORCE)
 
 if(UNIX)
     if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
@@ -73,9 +74,9 @@ if(NOT WIN32)#TODO: There are linking issues with windows build of well-known ty
 	add_subdirectory("src/wellknowntypes")
 endif()
 configure_package_config_file(
-    "${CMAKE_CURRENT_SOURCE_DIR}/ProjectConfig.cmake.in" "${QTPROTOBUF_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+    "${CMAKE_CURRENT_SOURCE_DIR}/ProjectConfig.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
     INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")
-install(FILES "${QTPROTOBUF_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
 
 export(PACKAGE ${PROJECT_NAME})
 
@@ -97,29 +98,29 @@ if(DEFINED DOXYGEN_EXECUTABLE)
     )
 endif()
 
-if(DEFINED $ENV{QTPROTOBUF_MAKE_TESTS})
-    set(QTPROTOBUF_MAKE_TESTS $ENV{QTPROTOBUF_MAKE_TESTS})
-elseif(NOT DEFINED QTPROTOBUF_MAKE_TESTS)
-    set(QTPROTOBUF_MAKE_TESTS ON)
+if(DEFINED $ENV{QT_PROTOBUF_MAKE_TESTS})
+    set(QT_PROTOBUF_MAKE_TESTS $ENV{QT_PROTOBUF_MAKE_TESTS})
+elseif(NOT DEFINED QT_PROTOBUF_MAKE_TESTS)
+    set(QT_PROTOBUF_MAKE_TESTS ON)
 endif()
 
-if(DEFINED $ENV{QTPROTOBUF_MAKE_EXAMPLES})
-    set(QTPROTOBUF_MAKE_EXAMPLES $ENV{QTPROTOBUF_MAKE_EXAMPLES})
-elseif(NOT DEFINED QTPROTOBUF_MAKE_EXAMPLES)
-    set(QTPROTOBUF_MAKE_EXAMPLES ON)
+if(DEFINED $ENV{QT_PROTOBUF_MAKE_EXAMPLES})
+    set(QT_PROTOBUF_MAKE_EXAMPLES $ENV{QT_PROTOBUF_MAKE_EXAMPLES})
+elseif(NOT DEFINED QT_PROTOBUF_MAKE_EXAMPLES)
+    set(QT_PROTOBUF_MAKE_EXAMPLES ON)
 endif()
 
 if(NOT gRPC_FOUND)
     message(WARNING "gRPC not found: some tests and examples cannot be built.")
     message(STATUS "-- Force disable test")
-    set(QTPROTOBUF_MAKE_TESTS OFF)
+    set(QT_PROTOBUF_MAKE_TESTS OFF)
     message(STATUS "-- Force disable examples")
-    set(QTPROTOBUF_MAKE_EXAMPLES OFF)
+    set(QT_PROTOBUF_MAKE_EXAMPLES OFF)
 endif()
 
 include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtProtobufCommon.cmake")
 
-if(QTPROTOBUF_MAKE_TESTS)
+if(QT_PROTOBUF_MAKE_TESTS)
     if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/googletest/CMakeLists.txt")
         set(BUILD_GMOCK OFF CACHE BOOL "Disable gmock build functionality" FORCE)
         set(gtest_force_shared_crt ON CACHE BOOL "Enable shared crt" FORCE)
@@ -136,6 +137,6 @@ if(QTPROTOBUF_MAKE_TESTS)
     endif()
 endif()
 
-if(QTPROTOBUF_MAKE_EXAMPLES)
+if(QT_PROTOBUF_MAKE_EXAMPLES)
     add_subdirectory("examples")
 endif()

+ 124 - 106
README.md

@@ -3,6 +3,7 @@
 gRPC and Protobuf generator and bindings for Qt framework
 > see [Protobuf](https://developers.google.com/protocol-buffers) and [gRPC](https://grpc.io/) for more information
 
+
 ### Test results
 
 | Branch | Results |
@@ -10,6 +11,7 @@ gRPC and Protobuf generator and bindings for Qt framework
 | [master](https://github.com/semlanik/qtprotobuf/tree/master) | ![](https://github.com/semlanik/qtprotobuf/workflows/Test%20Verification/badge.svg?branch=master) |
 | [0.1.0](https://github.com/semlanik/qtprotobuf/tree/0.1.0) | ![](https://github.com/semlanik/qtprotobuf/workflows/Test%20Verification/badge.svg?branch=0.1.0) |
 
+
 # Table of contents
 
 [API Reference](https://semlanik.github.io/qtprotobuf)
@@ -20,29 +22,39 @@ gRPC and Protobuf generator and bindings for Qt framework
 
 [Usage](#usage)
 
-[CMake functions reference](#cmake-functions-reference)
+[Integration with CMake project](#integration-with-cmake-project)
+
+[Integration with qmake project](#integration-with-qmake-project)
 
-[qmake integration](#qmake-integration)
+[Generated and QtProtobuf types registation](#generated-and-qtprotobuf-types-registation)
 
-[Running tests](#running-tests)
+[Code exceptions](#code-exceptions)
 
+[QtProtobuf development](#qtprotobuf-development)
+
+
+# Linux Build
+## Prerequesties
 
-## Linux Build
-### Prerequesties
 Check installation of following packages in your system:
 - protobuf 3.6.0 or higher
 - grpc 1.15.0 or higher
 - golang 1.10 or higher (Mandatory dependency for any type of build)
 
-**Note:** Older versions could be supported as well but not officially tested.
+>**Note:** Older versions could be supported as well but not officially tested.
+
+
+### For Ubuntu
 
-#### For Ubuntu
 Install GRPC packages in system:
 
 ```bash
 sudo apt-get install libgrpc++-dev protobuf-compiler-grpc libgrpc++1 libgrpc-dev libgrpc6
 ```
-#### All-in-one build
+
+
+### All-in-one build
+
 If required versions of libraries are not found in your system, you may use all-in-one build procedure for prerequesties
 
 Update submodules to fetch 3rdparty dependencies:
@@ -50,22 +62,19 @@ Update submodules to fetch 3rdparty dependencies:
 ```bash
 git submodule update --init --recursive
 ```
-### Build
+
+
+## Build
 ```bash
 mkdir build
 cd build
-
-#In case Qt installed in system, use:
-cmake ..
-
-#In case you have Qt installed from qt installer, use:
-cmake .. -DCMAKE_PREFIX_PATH="<path/to/qt/installation>/Qt<qt_version>/<qt_version>/gcc_64/lib/cmake"
-
+cmake .. [-DCMAKE_PREFIX_PATH="<path/to/qt/installation>/Qt<qt_version>/<qt_version>/gcc_64/lib/cmake"]
 cmake --build . [--config <RELEASE|DEBUG>] -- -j<N>
 ```
 
-## Windows Build
-### Prerequesties
+
+# Windows Build
+## Prerequesties
 
 Download and install:
 
@@ -76,7 +85,7 @@ Download and install:
 - Yasm 1.3 or higher [5](http://yasm.tortall.net/Download.html)
 - Actual Visual Studio Compiler with cmake support that required by Qt [6](https://visualstudio.microsoft.com/downloads/)
 
-**Note:** All applications should be in PATH
+>**Note:** All applications should be in PATH
 
 Update submodules to fetch 3rdparty dependencies:
 
@@ -84,7 +93,7 @@ Update submodules to fetch 3rdparty dependencies:
 git submodule update --init --recursive
 ```
 
-### Build
+## Build
 Open Qt MSVC command line and follow steps:
 
 ```bash
@@ -96,15 +105,14 @@ cmake ..
 cmake --build . [--config <RELEASE|DEBUG>] -- /m:<N>
 ```
 
-## Usage
+# Usage
+## Direct usage of generator
 
-### Direct usage of generator
-                
 ```bash
 [QT_PROTOBUF_OPTIONS="[SINGLE|MULTI]:QML:COMMENTS"] protoc --plugin=protoc-gen-qtprotobuf=<path/to/bin/>qtprotobufgen --qtprotobuf_out=<output_dir> [-I/extra/proto/include/path] <protofile>.proto
 ```
 
-**QT_PROTOBUF_OPTIONS**
+### QT_PROTOBUF_OPTIONS
 
 For protoc command you also may specify extra options using QT_PROTOBUF_OPTIONS environment variable and colon-separated format:
 
@@ -116,18 +124,17 @@ Following options are supported:
 
 *SINGLE* - enables single-file generation when for each *.proto* file single pair of *.h* *.cpp* files is generated
 
-**Note:** Enabled by default. Excluded by SINGLE
+>**Note:** Enabled by default. Excluded by SINGLE
 
 *MULTI* - enables multi-file generation when for each message separate pair of *.h* *.cpp*
 
-**Note:** Has higher priority than SINGLE
+>**Note:** Has higher priority than SINGLE
 
 *QML* - enables QML code generation in protobuf classes. If is set QML-related code for lists and QML registration to be generated.
 
 *COMMENTS* - enables comments copying from .proto files
 
-
-### Integration with project
+## Integration with CMake project
 
 You can integrate QtProtobuf as submodule in your project or as installed in system package. Add following line in your project CMakeLists.txt:
 
@@ -135,86 +142,43 @@ You can integrate QtProtobuf as submodule in your project or as installed in sys
 ...
 find_package(QtProtobufProject CONFIG REQUIRED COMPONENTS QtProtobuf QtGrpc)
 file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/path/to/protofile1.proto
-                               ${CMAKE_CURRENT_SOURCE_DIR}/path/to/protofile2.proto
-                               ...
-                               ${CMAKE_CURRENT_SOURCE_DIR}/path/to/protofileN.proto)
+ ${CMAKE_CURRENT_SOURCE_DIR}/path/to/protofile2.proto
+ ...
+ ${CMAKE_CURRENT_SOURCE_DIR}/path/to/protofileN.proto)
 # Function below generates source files for specified PROTO_FILES,
 # and link them to the MyTarget as static library 
 add_executable(MyTarget main.cpp) # Add your target here
 qtprotobuf_generate(TARGET MyTarget
-    OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
-    PROTO_FILES ${PROTO_FILES})
+OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
+PROTO_FILES ${PROTO_FILES})
 
 ```
 
-**Optional:**
-
-You also may pre-specify expected generated headers to prevent dummy-parser mistakes
+Another option is to pre-specify expected generated headers to prevent dummy-parser mistakes
 
 ```cmake
 ...
 set(GENERATED_HEADERS
-    # List of artifacts expected after qtprotobufgen job done.
-    # Usually it's full list of messages in all packages with .h header suffix
-    ...
-    )
-...
-qtprotobuf_generate(TARGET MyTarget
-    OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
-    PROTO_FILES ${PROTO_FILES}
-    GENERATED_HEADERS ${GENERATED_HEADERS})
-...
-```
-
-#### Usage
-
-To enable QtProtobuf project you need to register protobuf types. It's good practice to make it in 'main' function.
-
-```cpp
+# List of artifacts expected after qtprotobufgen job done.
+# Usually it's full list of messages in all packages with .h header suffix
 ...
-#include <QtProtobufTypes>
-...
-int main(int argc, char *argv[])
-{
-    QtProtobuf::qRegisterProtobufTypes();
-    ... //Qt application initialization and run
-}
-```
-
-### Code exceptions
-
-If any prohibited Qt/QML keyword is used as field name, generator appends '*Proto*' suffix to generated filed name. It's required to omit overloading for example QML reserved names like '*id*' or '*objectName*'.
-
-E.g. for message:
-```
-message MessageReserved {
-    sint32 import = 1;
-    sint32 property = 2;
-    sint32 id = 3;
-}
-```
-
-Following properties will be generated:
-```cpp
+)
 ...
-    Q_PROPERTY(QtProtobuf::sint32 importProto READ importProto WRITE setImport NOTIFY importProtoChanged)
-    Q_PROPERTY(QtProtobuf::sint32 propertyProto READ propertyProto WRITE setProperty NOTIFY propertyProtoChanged)
-    Q_PROPERTY(QtProtobuf::sint32 idProto READ idProto WRITE setId NOTIFY idProtoChanged)
+qtprotobuf_generate(TARGET MyTarget
+OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
+PROTO_FILES ${PROTO_FILES}
+GENERATED_HEADERS ${GENERATED_HEADERS})
 ...
-
 ```
 
-**Note:** List of exceptions might be extended in future releases.
-
-## CMake functions reference
-
-### qtprotobuf_generate
+### CMake functions reference
+#### qtprotobuf_generate
 
 qtprotobuf_generate is cmake helper function that automatically generates STATIC library target from your .proto files
 
 Due to cmake restrictions it's required to specify resulting artifacts manually as list of header files expected after generator job finished.
 
-**Parameters:**
+***Parameters:***
 
 *TARGET* - name of you target that generated code archive will be linked to
 
@@ -228,50 +192,50 @@ Due to cmake restrictions it's required to specify resulting artifacts manually
 
 *PROTO_FILES* - List of .proto files that will be used in generation procedure
 
-**Options:**
+***Options:***
 
 *MULTI* - Enables multi-files generation mode. If provided in parameter list generator will create pair of header/source files for each message
 
-**Note:** multi-files generation mode is defined as deprecated by QtProtobuf team, and might have poor support in future
+>**Note:** multi-files generation mode is defined as deprecated by QtProtobuf team, and might have poor support in future
 
 *QML* - Enables QML code generation in protobuf classes. If provided in parameter list QML related code for lists and QML registration to be generated.
 
 *COMMENTS* - Enables comments copying from .proto files. If provided in parameter list message and field related comments will be copied to generated header files.
 
-### qtprotobuf_link_archive
+#### qtprotobuf_link_archive
 
 qtprotobuf_link_archive is cmake helper function that links whole archive to your library or executable target. It's useful when you try to link generated target to shared library or/and to executable that doesn't utilize all protobuf generated classes directly from C++ code, but requires them from QML.
 
-**Parameters:**
+***Parameters:***
 
 *TARGET* - name of target to link to
 
 *GENERATED_TARGET* - protobuf generated target name
 
+#### Usefull definitions
 
-### Usefull definitions
+*QT_PROTOBUF_MAKE_COVERAGE* - if **TRUE/ON** for QtProtobuf project build, QtProtobuf will be built with gcov intergration, to collect code coverage reports(usefull for developers). **FALSE** by default
 
-*QTPROTOBUF_MAKE_COVERAGE* - if **TRUE/ON** for QtProtobuf project build, QtProtobuf will be built with gcov intergration, to collect code coverage reports(usefull for developers). **FALSE** by default
+*QT_PROTOBUF_MAKE_TESTS* - if **TRUE/ON** for QtProtobuf project build, tests for QtProtobuf will be built. **TRUE** by default
 
-*QTPROTOBUF_MAKE_TESTS* - if **TRUE/ON** for QtProtobuf project build, tests for QtProtobuf will be built. **TRUE** by default
-
-*QTPROTOBUF_MAKE_EXAMPLES* - if **TRUE/ON** for QtProtobuf project build, built-in examples will be built. **TRUE** by default
+*QT_PROTOBUF_MAKE_EXAMPLES* - if **TRUE/ON** for QtProtobuf project build, built-in examples will be built. **TRUE** by default
 
 *QT_PROTOBUF_STATIC* - if **TRUE/ON** for QtProtobuf project build, static libraries will be produced for all QtProtobuf targets except qml plugin. **FALSE** by default
 
-*QTPROTOBUF_EXECUTABLE* - contains full path to QtProtobuf generator add_executable
+*QT_PROTOBUF_EXECUTABLE* - contains full path to QtProtobuf generator add_executable
 
-## qmake integration
+## Integration with qmake project
 
-**Note:** Available in QtProtobuf version >=0.2.0
+>**Note:** Available in QtProtobuf version >=0.2.0
 
 QtProtobuf has limited qmake build procedures support. It's only available and tested on linux platforms. To use it in your qmake project, first you need build and install QtProtobuf as standalone project in your system paths:
 
 ```bash
 mkdir build
 cd build
-cmake .. [-DCMAKE_PREFIX_PATH="<path/to/qt/installation>/Qt<qt_version>/<qt_version>/gcc_64/lib/cmake"] -DCMAKE_INSTALL_PREFIX=/usr -DQTPROTOBUF_MAKE_TESTS=OFF -DQTPROTOBUF_MAKE_EXAMPLES=OFF
-sudo cmake --build . [--config <RELEASE|DEBUG>] -- -j<N> install
+cmake .. [-DCMAKE_PREFIX_PATH="<path/to/qt/installation>/Qt<qt_version>/<qt_version>/gcc_64/lib/cmake"] -DCMAKE_INSTALL_PREFIX=/usr -DQT_PROTOBUF_MAKE_TESTS=OFF -DQT_PROTOBUF_MAKE_EXAMPLES=OFF
+cmake --build . [--config <RELEASE|DEBUG>] -- -j<N>
+sudo cmake --build . [--config <RELEASE|DEBUG>] --target install
 ```
 
 Commands above will install qt protobuf into you system paths prefixed with */usr* folder.
@@ -284,32 +248,86 @@ QT += grpc #for grpc libraries support
 ```
 To generate source code and link it to you project use predefined *qtprotobuf_generate* function
 
-### qtprotobuf_generate([generate_qml=false])
+### CMake functions reference
+#### qtprotobuf_generate([generate_qml=false])
 
 qtprotobuf_generate is qmake helper [test function](https://doc.qt.io/qt-5/qmake-language.html#test-functions) that generates QtProtobuf source code based on files provided by PROTO_FILES global context variable
 
-**Parameters:**
+***Parameters:***
 
 *generate_qml* - Enables/disables QML code generation in protobuf classes. If set to `true` QML-related code for lists and QML registration to be generated.
 
 
-**Note:** see examples/qmakeexample for details
+>**Note:** see examples/qmakeexample for details
+
+## Generated and QtProtobuf types registation
+
+To enable QtProtobuf project you need to register protobuf types. It's good practice to make it in 'main' function.
+
+```cpp
+...
+#include <QtProtobufTypes>
+...
+int main(int argc, char *argv[])
+{
+QtProtobuf::qRegisterProtobufTypes();
+... //Qt application initialization and run
+}
+```
+
+## Code exceptions
+
+If any prohibited Qt/QML keyword is used as field name, generator appends '*Proto*' suffix to generated filed name. It's required to omit overloading for example QML reserved names like '*id*' or '*objectName*'.
+
+E.g. for message:
+```
+message MessageReserved {
+sint32 import = 1;
+sint32 property = 2;
+sint32 id = 3;
+}
+```
+
+Following properties will be generated:
+```cpp
+...
+Q_PROPERTY(QtProtobuf::sint32 importProto READ importProto WRITE setImport NOTIFY importProtoChanged)
+Q_PROPERTY(QtProtobuf::sint32 propertyProto READ propertyProto WRITE setProperty NOTIFY propertyProtoChanged)
+Q_PROPERTY(QtProtobuf::sint32 idProto READ idProto WRITE setId NOTIFY idProtoChanged)
+...
+
+```
 
+>**Note:** List of exceptions might be extended in future releases.
+
+# QtProtobuf development
 ## Running tests
+
 ```bash
 cd <build directory>
 ctest
 ```
+
 ## Documentation generation
 
 Project uses doxygen for documentation generation.
 
-#### For Windows additionally install:
+### Ubuntu
+
+Install doxygen and graphviz packages:
+```
+sudo apt-get install -y doxygen graphviz
+```
+
+### Windows
+
+Install doxygen and graphviz packages:
 * [doxygen](http://www.doxygen.nl/download.html)
 * [graphviz](https://graphviz.gitlab.io/_pages/Download/Download_windows.html)
 
+### Generation
 
-You can generate documentation:
+You can generate documentation for actual version using following commands:
 
 ```bash
 mkdir build

+ 7 - 7
cmake/Coverage.cmake

@@ -1,10 +1,10 @@
-if(DEFINED $ENV{QTPROTOBUF_MAKE_COVERAGE})
-    set(QTPROTOBUF_MAKE_COVERAGE $ENV{QTPROTOBUF_MAKE_COVERAGE})
-elseif(NOT DEFINED QTPROTOBUF_MAKE_COVERAGE)
-    set(QTPROTOBUF_MAKE_COVERAGE OFF)
+if(DEFINED $ENV{QT_PROTOBUF_MAKE_COVERAGE})
+    set(QT_PROTOBUF_MAKE_COVERAGE $ENV{QT_PROTOBUF_MAKE_COVERAGE})
+elseif(NOT DEFINED QT_PROTOBUF_MAKE_COVERAGE)
+    set(QT_PROTOBUF_MAKE_COVERAGE OFF)
 endif()
 
-if(QTPROTOBUF_MAKE_COVERAGE AND UNIX)
+if(QT_PROTOBUF_MAKE_COVERAGE AND UNIX)
     message(STATUS "-- Enable gcov")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
@@ -15,10 +15,10 @@ function(add_coverage_target)
     set(oneValueArgs TARGET)
     set(multiValueArgs)
     cmake_parse_arguments(add_coverage_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    set(GCOV_OUTPUT_DIR ${QTPROTOBUF_BINARY_DIR}/gcov/${add_coverage_target_TARGET})
+    set(GCOV_OUTPUT_DIR ${QT_PROTOBUF_BINARY_DIR}/gcov/${add_coverage_target_TARGET})
     set(OBJECTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${add_coverage_target_TARGET}.dir)
     set(COVERAGE_TARGET ${add_coverage_target_TARGET}_coverage)
-    if(QTPROTOBUF_MAKE_COVERAGE AND UNIX)
+    if(QT_PROTOBUF_MAKE_COVERAGE AND UNIX)
         find_program(GCOV_EXECUTABLE "gcov")
         if(GCOV_EXECUTABLE STREQUAL GCOV_EXECUTABLE-NOTFOUND)
             message(FATAL_ERROR "Coverage enabled for target ${add_coverage_target_TARGET}, but gcov is not installed")

+ 2 - 2
cmake/GenerateQtHeaders.cmake

@@ -10,8 +10,8 @@ function(protobuf_generate_qt_headers)
         if (NOT "${CLASS_NAME}" STREQUAL "")
             string(REPLACE "#pragma once //" "" CLASS_NAME "${CLASS_NAME}")
             message("-- Generate Qt header for ${CLASS_NAME}")
-            configure_file("${QTPROTOBUF_CMAKE_DIR}/GeneratedHeaderTemplate" "${QTPROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME}" @ONLY)
-            set(GENERATED_PUBLIC_HEADER ${GENERATED_PUBLIC_HEADER} ${QTPROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME})
+            configure_file("${QT_PROTOBUF_CMAKE_DIR}/GeneratedHeaderTemplate" "${QT_PROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME}" @ONLY)
+            set(GENERATED_PUBLIC_HEADER ${GENERATED_PUBLIC_HEADER} ${QT_PROTOBUF_BINARY_DIR}/include/${protobuf_generate_qt_headers_COMPONENT}/${CLASS_NAME})
         endif()
     endforeach()
     set(GENERATED_PUBLIC_HEADER ${GENERATED_PUBLIC_HEADER} PARENT_SCOPE)

+ 53 - 47
cmake/QtProtobufGen.cmake

@@ -18,7 +18,7 @@ endfunction()
 
 function(qtprotobuf_generate)
     set(options MULTI QML COMMENTS)
-    set(oneValueArgs OUT_DIR TARGET GENERATED_TARGET GENERATED_HEADERS_VAR)
+    set(oneValueArgs OUT_DIR TARGET GENERATED_TARGET)
     set(multiValueArgs GENERATED_HEADERS EXCLUDE_HEADERS PROTO_FILES PROTO_INCLUDES)
     cmake_parse_arguments(qtprotobuf_generate "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
@@ -31,20 +31,18 @@ function(qtprotobuf_generate)
     endif()
 
     set(GEN_TARGET ${GENERATED_TARGET_NAME}_generate)
-    set(GENERATED_HEADERS ${qtprotobuf_generate_GENERATED_HEADERS})
 
-    if(NOT DEFINED QTPROTOBUF_EXECUTABLE)
-        set(QTPROTOBUF_EXECUTABLE "${QTPROTOBUF_EXECUTABLE_INSTALL}")
+    if(NOT DEFINED QT_PROTOBUF_EXECUTABLE)
+        set(QT_PROTOBUF_EXECUTABLE "${QT_PROTOBUF_EXECUTABLE_INSTALL}")
     endif()
 
-    set(GENERATION_TYPE "SINGLE")
+    #Options handling
+    set(GENERATION_TYPE "SIGNLE")
     if(qtprotobuf_generate_MULTI)
         set(GENERATION_TYPE "MULTI")
-        #TODO: add globalenums by default. But it's better to verify if proto file contains any global enum
-        set(GENERATED_HEADERS ${GENERATED_HEADERS} globalenums.h)
     endif()
-
     set(GENERATION_OPTIONS ${GENERATION_TYPE})
+
     if(qtprotobuf_generate_QML)
         message(STATUS "Enabled QML generation for ${GENERATED_TARGET_NAME}")
         set(GENERATION_OPTIONS "${GENERATION_OPTIONS}:QML")
@@ -55,25 +53,37 @@ function(qtprotobuf_generate)
         set(GENERATION_OPTIONS "${GENERATION_OPTIONS}:COMMENTS")
     endif()
 
-    find_program(GO_EXECUTABLE "go")
-    if (GO_EXECUTABLE STREQUAL GO_EXECUTABLE-NOTFOUND)
-        message(FATAL_ERROR "Golang is mandatory dependency for QtProtobuf. Please install it and ensure that it's accessible by PATH environment variable")
+    if(WIN32)
+        set(PROTOC_COMMAND set QT_PROTOBUF_OPTIONS=${GENERATION_OPTIONS}&& $<TARGET_FILE:protobuf::protoc>)
+    else()
+        set(PROTOC_COMMAND "QT_PROTOBUF_OPTIONS=${GENERATION_OPTIONS}" $<TARGET_FILE:protobuf::protoc>)
     endif()
 
     set(PROTO_INCLUDES ${qtprotobuf_generate_PROTO_INCLUDES})
-    foreach(PROTO_FILE IN LISTS qtprotobuf_generate_PROTO_FILES)
-        get_filename_component(BASE_DIR ${PROTO_FILE} DIRECTORY)
-        set(PROTO_INCLUDES -I"${BASE_DIR}" ${PROTO_INCLUDES})
-        execute_process(COMMAND ${GO_EXECUTABLE} run ${PROTO_PARSER} ${PROTO_FILE} ${GENERATION_TYPE} OUTPUT_VARIABLE GENERATED_HEADERS_PART ERROR_VARIABLE PARSER_ERROR)
-        set(GENERATED_HEADERS ${GENERATED_HEADERS} ${GENERATED_HEADERS_PART})
-    endforeach()
-
-    if(NOT "${PARSER_ERROR}" STREQUAL "")
-        message(FATAL_ERROR "Go parser error ${PARSER_ERROR}")
-    endif()
 
     if(DEFINED qtprotobuf_generate_GENERATED_HEADERS)
         set(GENERATED_HEADERS ${qtprotobuf_generate_GENERATED_HEADERS})
+    else()
+        find_program(GO_EXECUTABLE "go")
+        if (GO_EXECUTABLE STREQUAL GO_EXECUTABLE-NOTFOUND)
+            message(FATAL_ERROR "Golang is mandatory dependency for QtProtobuf if GENERATED_HEADERS is not specified. Please install it and ensure that it's accessible by PATH environment variable")
+        endif()
+
+        foreach(PROTO_FILE IN LISTS qtprotobuf_generate_PROTO_FILES)
+            get_filename_component(BASE_DIR ${PROTO_FILE} DIRECTORY)
+            set(PROTO_INCLUDES -I"${BASE_DIR}" ${PROTO_INCLUDES})
+            execute_process(COMMAND ${GO_EXECUTABLE} run ${PROTO_PARSER} ${PROTO_FILE} ${GENERATION_TYPE} OUTPUT_VARIABLE GENERATED_HEADERS_PART ERROR_VARIABLE PARSER_ERROR)
+            set(GENERATED_HEADERS ${GENERATED_HEADERS} ${GENERATED_HEADERS_PART})
+        endforeach()
+    endif()
+
+    if(qtprotobuf_generate_MULTI)
+        #TODO: add globalenums by default. But it's better to verify if proto file contains any global enum
+        set(GENERATED_HEADERS ${GENERATED_HEADERS} globalenums.h)
+    endif()
+
+    if(NOT "${PARSER_ERROR}" STREQUAL "")
+        message(FATAL_ERROR "Go parser error ${PARSER_ERROR}")
     endif()
 
     foreach(EXCLUDE_HEADER IN LISTS qtprotobuf_generate_EXCLUDE_HEADERS)
@@ -90,59 +100,55 @@ function(qtprotobuf_generate)
 
     file(MAKE_DIRECTORY ${OUT_DIR})
 
-    unset(QTPROTOBUF_GENERATED_SOURCES)
-    unset(QTPROTOBUF_GENERATED_HEADERS)
+    unset(GENERATED_SOURCES_FULL)
+    unset(GENERATED_HEADERS_FULL)
     foreach(GENERATED_HEADER IN LISTS GENERATED_HEADERS)
         get_filename_component(GENERATED_BASENAME ${GENERATED_HEADER} NAME)
         string(REGEX REPLACE "\\.[^.]*$" "" GENERATED_BASENAME ${GENERATED_BASENAME})
 
-        list(APPEND QTPROTOBUF_GENERATED_SOURCES ${OUT_DIR}/${GENERATED_BASENAME}.cpp)
-        list(APPEND QTPROTOBUF_GENERATED_HEADERS ${OUT_DIR}/${GENERATED_BASENAME}.h)
+        list(APPEND GENERATED_SOURCES_FULL ${OUT_DIR}/${GENERATED_BASENAME}.cpp)
+        list(APPEND GENERATED_HEADERS_FULL ${OUT_DIR}/${GENERATED_BASENAME}.h)
         set_property(SOURCE ${OUT_DIR}/${GENERATED_BASENAME}.cpp PROPERTY SKIP_AUTOMOC ON)
     endforeach()
 
-    if(WIN32)
-        set(PROTOC_COMMAND set QT_PROTOBUF_OPTIONS=${GENERATION_OPTIONS}&& $<TARGET_FILE:protobuf::protoc>)
-    else()
-        set(PROTOC_COMMAND "QT_PROTOBUF_OPTIONS=${GENERATION_OPTIONS}" $<TARGET_FILE:protobuf::protoc>)
-    endif()
+    set_source_files_properties(${GENERATED_SOURCES_FULL} PROPERTIES GENERATED TRUE)
+    qt5_wrap_cpp(MOC_SOURCES ${GENERATED_HEADERS_FULL})
 
     add_custom_command(
-            OUTPUT ${QTPROTOBUF_GENERATED_SOURCES} ${QTPROTOBUF_GENERATED_HEADERS}
+            OUTPUT ${GENERATED_SOURCES_FULL} ${GENERATED_HEADERS_FULL}
             COMMAND ${PROTOC_COMMAND}
-                --plugin=protoc-gen-${GENERATOR_TARGET}=${QTPROTOBUF_EXECUTABLE}
+                --plugin=protoc-gen-${GENERATOR_TARGET}=${QT_PROTOBUF_EXECUTABLE}
                 --${GENERATOR_TARGET}_out=${OUT_DIR}
                 ${PROTO_INCLUDES}
                 ${qtprotobuf_generate_PROTO_FILES}
             WORKING_DIRECTORY ${OUT_DIR}
-            DEPENDS ${qtprotobuf_generate_PROTO_FILES} ${QTPROTOBUF_EXECUTABLE}
+            DEPENDS ${qtprotobuf_generate_PROTO_FILES} ${QT_PROTOBUF_EXECUTABLE}
             COMMENT "Generating QtProtobuf ${GENERATED_TARGET_NAME} sources..."
     )
 
-    add_custom_target(${GEN_TARGET} DEPENDS ${QTPROTOBUF_GENERATED_SOURCES} ${QTPROTOBUF_GENERATED_HEADERS} ${qtprotobuf_generate_PROTO_FILES})
-    if(NOT "${qtprotobuf_generate_GENERATED_HEADERS_VAR}" STREQUAL "")
-        set(${qtprotobuf_generate_GENERATED_HEADERS_VAR} ${QTPROTOBUF_GENERATED_HEADERS} PARENT_SCOPE)
-    endif()
-    qt5_wrap_cpp(MOC_SOURCES ${QTPROTOBUF_GENERATED_HEADERS})
-    list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
-    set_source_files_properties(${QTPROTOBUF_GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
-    add_library(${GENERATED_TARGET_NAME} ${QTPROTOBUF_GENERATED_SOURCES} ${MOC_SOURCES})
-    set_target_properties(${GENERATED_TARGET_NAME} PROPERTIES PUBLIC_HEADER "${QTPROTOBUF_GENERATED_HEADERS}")
+    add_custom_target(${GEN_TARGET} DEPENDS ${GENERATED_SOURCES_FULL} ${GENERATED_HEADERS_FULL} ${qtprotobuf_generate_PROTO_FILES})
+
+    add_library(${GENERATED_TARGET_NAME} ${GENERATED_SOURCES_FULL} ${MOC_SOURCES})
     add_dependencies(${GENERATED_TARGET_NAME} ${GEN_TARGET})
+    set_target_properties(${GENERATED_TARGET_NAME} PROPERTIES PUBLIC_HEADER "${GENERATED_HEADERS_FULL}")
+
+    #Add include directories in case if projects are enabled by find_project
     target_include_directories(${GENERATED_TARGET_NAME} PUBLIC ${OUT_DIR} PRIVATE ${Qt5Core_INCLUDE_DIRS}
-        $<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf,INTERFACE_INCLUDE_DIRECTORIES>)
+        $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobuf,INTERFACE_INCLUDE_DIRECTORIES>)
 
-    if(TARGET ${QTPROTOBUF_COMMON_NAMESPACE}::QtGrpc)
+    if(TARGET ${QT_PROTOBUF_PROJECT}::QtGrpc)
         target_include_directories(${GENERATED_TARGET_NAME} PRIVATE
-            $<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtGrpc,INTERFACE_INCLUDE_DIRECTORIES>)
+            $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtGrpc,INTERFACE_INCLUDE_DIRECTORIES>)
     endif()
 
     if(NOT WIN32)
-        if(TARGET ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobufWellKnownTypes)
+        if(TARGET ${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes)
             target_include_directories(${GENERATED_TARGET_NAME} PRIVATE
-                $<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
+                $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
         endif()
     endif()
+
+    #Automatically link whole static library to specified in parameters target
     if(DEFINED qtprotobuf_generate_TARGET)
         qtprotobuf_link_archive(${qtprotobuf_generate_TARGET} ${GENERATED_TARGET_NAME})
     endif()

+ 2 - 2
cmake/QtProtobufTest.cmake

@@ -1,6 +1,6 @@
 find_package(QtProtobufProject COMPONENTS QtProtobuf QtGrpc REQUIRED)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 function(add_test_target)
     set(options MULTI QML)
@@ -46,7 +46,7 @@ function(add_test_target)
         set_target_properties(${add_test_target_TARGET} PROPERTIES POSITION_INDEPENDENT_CODE FALSE)
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
     endif()
-    target_link_libraries(${add_test_target_TARGET} PUBLIC gtest_main gtest ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf ${QTPROTOBUF_COMMON_NAMESPACE}::QtGrpc Qt5::Core Qt5::Test Qt5::Network ${CMAKE_THREAD_LIBS_INIT})
+    target_link_libraries(${add_test_target_TARGET} PUBLIC gtest_main gtest ${QT_PROTOBUF_PROJECT}::QtProtobuf ${QT_PROTOBUF_PROJECT}::QtGrpc Qt5::Core Qt5::Test Qt5::Network ${CMAKE_THREAD_LIBS_INIT})
     if (${add_test_target_QML})
         target_link_libraries(${add_test_target_TARGET} PUBLIC Qt5::Qml)
     endif()

+ 1 - 1
doxygen/Doxyfile.in

@@ -38,7 +38,7 @@ PROJECT_NAME           = "QtProtobuf"
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = @QTPROTOBUF_PROJECT_VERSION@
+PROJECT_NUMBER         = @QT_PROTOBUF_VERSION@
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a

+ 1 - 1
examples/addressbookserver/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET addressbookserver)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 set(GENERATED_SOURCES
     ${CMAKE_CURRENT_BINARY_DIR}/addressbook.pb.cc

+ 1 - 1
examples/simplechatserver/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET simplechatserver)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 set(GENERATED_SOURCES
     ${CMAKE_CURRENT_BINARY_DIR}/simplechat.pb.cc

+ 3 - 3
src/generator/CMakeLists.txt

@@ -1,8 +1,8 @@
-project(qtprotobufgen VERSION ${QTPROTOBUF_PROJECT_VERSION} LANGUAGES CXX)
+project(qtprotobufgen VERSION ${QT_PROTOBUF_VERSION} LANGUAGES CXX)
 
 set(TARGET ${PROJECT_NAME})
 set(TARGET_EXPORT ${TARGET}Targets)
-set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
 
 file(GLOB SOURCES main.cpp
     generator.cpp
@@ -47,4 +47,4 @@ endif()
 target_link_libraries(${TARGET} protobuf::libprotobuf protobuf::libprotoc)
 
 install(TARGETS ${TARGET}
-    RUNTIME DESTINATION ${TARGET_BIN_DIR})
+    RUNTIME DESTINATION ${TARGET_BINDIR})

+ 17 - 17
src/grpc/CMakeLists.txt

@@ -6,14 +6,14 @@ set(TARGET_CONFIG ${TARGET}Config)
 set(TARGET_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET})
 set(TARGET_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
 set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
-set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
-include(${QTPROTOBUF_CMAKE_DIR}/Coverage.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/Coverage.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 file(GLOB SOURCES qgrpcasyncoperationbase.cpp
     qgrpcasyncreply.cpp
@@ -56,10 +56,10 @@ target_compile_definitions(${TARGET} PRIVATE QT_BUILD_GRPC_LIB)
 set_target_properties(${TARGET} PROPERTIES VERSION ${PROJECT_VERSION} PUBLIC_HEADER "${HEADERS};${GENERATED_PUBLIC_HEADER}" OUTPUT_NAME ${TARGET})
 target_include_directories(${TARGET} PUBLIC 
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-    $<BUILD_INTERFACE:${QTPROTOBUF_BINARY_DIR}/include/${TARGET}>
+    $<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/${TARGET}>
     $<INSTALL_INTERFACE:${TARGET_INCLUDE_DIR}>
 )
-target_link_libraries(${TARGET} PUBLIC ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf Qt5::Core Qt5::Network)
+target_link_libraries(${TARGET} PUBLIC ${QT_PROTOBUF_PROJECT}::QtProtobuf Qt5::Core Qt5::Network)
 target_compile_features(${TARGET} PUBLIC cxx_std_14
                                          cxx_auto_type
                                          cxx_decltype
@@ -69,33 +69,33 @@ target_compile_features(${TARGET} PUBLIC cxx_std_14
                                          cxx_lambdas
                                          cxx_func_identifier)
 
-add_library(${QTPROTOBUF_COMMON_NAMESPACE}::${TARGET} ALIAS ${TARGET})
+add_library(${QT_PROTOBUF_PROJECT}::${TARGET} ALIAS ${TARGET})
 
 install(TARGETS ${TARGET}
     EXPORT ${TARGET_EXPORT}
     ARCHIVE DESTINATION ${TARGET_LIB_DIR}
     PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR}
     LIBRARY DESTINATION ${TARGET_LIB_DIR}
-    RUNTIME DESTINATION ${TARGET_BIN_DIR})
+    RUNTIME DESTINATION ${TARGET_BINDIR})
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
-    "${TARGET_CONFIG}.cmake.in" "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
+    "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
-export(TARGETS ${TARGET} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake)
+export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)
 
-configure_file("${QTPROTOBUF_CMAKE_DIR}/gRPCLookup.cmake" "${QTPROTOBUF_BINARY_DIR}/gRPCLookup.cmake" COPYONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/gRPCLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+configure_file("${QT_PROTOBUF_CMAKE_DIR}/gRPCLookup.cmake" "${QT_PROTOBUF_BINARY_DIR}/gRPCLookup.cmake" COPYONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/gRPCLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
 if(QT_PROTOBUF_STATIC) #extra config for .pri file in case if static build enabled
-    set(QTPROTOBUF_EXTRA_CONFIG "staticlib")
+    set(QT_PROTOBUF_EXTRA_CONFIG "staticlib")
 endif()
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qt_lib_grpc.pri.in" "${QTPROTOBUF_BINARY_DIR}/qt_lib_grpc.pri" @ONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/qt_lib_grpc.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qt_lib_grpc.pri.in" "${QT_PROTOBUF_BINARY_DIR}/qt_lib_grpc.pri" @ONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/qt_lib_grpc.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules")
 
 add_coverage_target(TARGET ${TARGET})

+ 2 - 2
src/grpc/qt_lib_grpc.pri.in

@@ -1,10 +1,10 @@
-QT.grpc.VERSION = @QTPROTOBUF_PROJECT_VERSION@
+QT.grpc.VERSION = @QT_PROTOBUF_VERSION@
 QT.grpc.name = QtGrpc
 QT.grpc.module = QtGrpc
 QT.grpc.includes = @CMAKE_INSTALL_PREFIX@/@TARGET_INCLUDE_DIR@
 QT.grpc.private_includes =
 QT.grpc.libs = @CMAKE_INSTALL_PREFIX@/@TARGET_LIB_DIR@
 QT.grpc.depends = core network protobuf
-QT.grpc.module_config = @QTPROTOBUF_EXTRA_CONFIG@
+QT.grpc.module_config = @QT_PROTOBUF_EXTRA_CONFIG@
 
 CONFIG += c++14

+ 22 - 22
src/protobuf/CMakeLists.txt

@@ -6,16 +6,16 @@ set(TARGET_CONFIG ${TARGET}Config)
 set(TARGET_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET})
 set(TARGET_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
 set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
-set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
 find_package(Qt5 COMPONENTS Core Qml REQUIRED)
 
-include(${QTPROTOBUF_CMAKE_DIR}/Coverage.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/Coverage.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 file(GLOB SOURCES
     qtprotobuf.cpp
@@ -80,13 +80,13 @@ extract_qt_variable(QT_HOST_DATA)
 set_target_properties(${TARGET} PROPERTIES QT_PROTOBUF_PLUGIN_PATH "${QT_INSTALL_PLUGINS}/protobuf")
 target_compile_definitions(${TARGET} PUBLIC QT_PROTOBUF_PLUGIN_PATH="${QT_INSTALL_PLUGINS}/protobuf")
 
-target_compile_definitions(${TARGET} PRIVATE QT_BUILD_PROTOBUF_LIB PUBLIC QTPROTOBUF_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
-    QTPROTOBUF_VERSION_MINOR=${PROJECT_VERSION_MINOR})
+target_compile_definitions(${TARGET} PRIVATE QT_BUILD_PROTOBUF_LIB PUBLIC QT_PROTOBUF_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
+    QT_PROTOBUF_VERSION_MINOR=${PROJECT_VERSION_MINOR})
 
 set_target_properties(${TARGET} PROPERTIES VERSION ${PROJECT_VERSION} PUBLIC_HEADER "${PUBLIC_HEADER};${GENERATED_PUBLIC_HEADER}" OUTPUT_NAME ${TARGET})
 target_include_directories(${TARGET} PUBLIC
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
-    $<BUILD_INTERFACE:${QTPROTOBUF_BINARY_DIR}/include/${TARGET}>
+    $<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/${TARGET}>
     $<INSTALL_INTERFACE:${TARGET_INCLUDE_DIR}>
 )
 
@@ -101,40 +101,40 @@ target_compile_features(${TARGET} PUBLIC cxx_std_14
 
 target_link_libraries(${TARGET} PUBLIC Qt5::Core Qt5::Qml)
 
-add_library(${QTPROTOBUF_COMMON_NAMESPACE}::${TARGET} ALIAS ${TARGET})
+add_library(${QT_PROTOBUF_PROJECT}::${TARGET} ALIAS ${TARGET})
 
 install(TARGETS ${TARGET}
     EXPORT ${TARGET_EXPORT}
     ARCHIVE DESTINATION ${TARGET_LIB_DIR}
     PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR}
     LIBRARY DESTINATION ${TARGET_LIB_DIR}
-    RUNTIME DESTINATION ${TARGET_BIN_DIR})
+    RUNTIME DESTINATION ${TARGET_BINDIR})
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
-    "${TARGET_CONFIG}.cmake.in" "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
+    "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
-export(TARGETS ${TARGET} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake)
+export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)
 
-configure_file("${QTPROTOBUF_CMAKE_DIR}/QtProtobufGen.cmake" "${QTPROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" COPYONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+configure_file("${QT_PROTOBUF_CMAKE_DIR}/QtProtobufGen.cmake" "${QT_PROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" COPYONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/parsemessages.go" "${QTPROTOBUF_BINARY_DIR}/parsemessages.go" COPYONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/parsemessages.go" DESTINATION "${TARGET_CMAKE_DIR}")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/parsemessages.go" "${QT_PROTOBUF_BINARY_DIR}/parsemessages.go" COPYONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/parsemessages.go" DESTINATION "${TARGET_CMAKE_DIR}")
 
-configure_file("${QTPROTOBUF_CMAKE_DIR}/ProtobufLookup.cmake" "${QTPROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" COPYONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+configure_file("${QT_PROTOBUF_CMAKE_DIR}/ProtobufLookup.cmake" "${QT_PROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" COPYONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
 if(QT_PROTOBUF_STATIC) #extra config for .pri file in case if static build enabled
-    set(QTPROTOBUF_EXTRA_CONFIG "staticlib")
+    set(QT_PROTOBUF_EXTRA_CONFIG "staticlib")
 endif()
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qt_lib_protobuf.pri.in" "${QTPROTOBUF_BINARY_DIR}/qt_lib_protobuf.pri" @ONLY)
-install(FILES "${QTPROTOBUF_BINARY_DIR}/qt_lib_protobuf.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qt_lib_protobuf.pri.in" "${QT_PROTOBUF_BINARY_DIR}/qt_lib_protobuf.pri" @ONLY)
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/qt_lib_protobuf.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules")
 
 add_subdirectory("quick")
 

+ 2 - 2
src/protobuf/QtProtobufConfig.cmake.in

@@ -7,6 +7,6 @@ endif()
 @PACKAGE_INIT@
 set(PROTO_PARSER "${CMAKE_CURRENT_LIST_DIR}/parsemessages.go")
 set(GENERATOR_TARGET "@GENERATOR_TARGET@")
-set(QTPROTOBUF_COMMON_NAMESPACE "@QTPROTOBUF_COMMON_NAMESPACE@")
-set(QTPROTOBUF_EXECUTABLE_INSTALL "@QTPROTOBUF_EXECUTABLE_INSTALL@")
+set(QT_PROTOBUF_PROJECT "@QT_PROTOBUF_PROJECT@")
+set(QT_PROTOBUF_EXECUTABLE_INSTALL "@QT_PROTOBUF_EXECUTABLE_INSTALL@")
 include("${CMAKE_CURRENT_LIST_DIR}/QtProtobufGen.cmake")

+ 4 - 4
src/protobuf/qt_lib_protobuf.pri.in

@@ -1,11 +1,11 @@
-QT.protobuf.VERSION = @QTPROTOBUF_PROJECT_VERSION@
+QT.protobuf.VERSION = @QT_PROTOBUF_VERSION@
 QT.protobuf.name = QtProtobuf
 QT.protobuf.module = QtProtobuf
 QT.protobuf.includes = @CMAKE_INSTALL_PREFIX@/@TARGET_INCLUDE_DIR@
 QT.protobuf.private_includes =
 QT.protobuf.libs = @CMAKE_INSTALL_PREFIX@/@TARGET_LIB_DIR@
 QT.protobuf.depends = core qml
-QT.protobuf.module_config = @QTPROTOBUF_EXTRA_CONFIG@
+QT.protobuf.module_config = @QT_PROTOBUF_EXTRA_CONFIG@
 
 CONFIG += c++14
 
@@ -23,8 +23,8 @@ defineTest(qtprotobuf_generate) {
 
     GENERATED_OUT_DIR = $$OUT_PWD/generated
     system("mkdir $$GENERATED_OUT_DIR")
-    message("QT_PROTOBUF_OPTIONS=$$GENERATOR_OPTIONS protoc --plugin=protoc-gen-@GENERATOR_TARGET@=@QTPROTOBUF_EXECUTABLE_INSTALL@ --@GENERATOR_TARGET@_out=$$GENERATED_OUT_DIR $$PROTO_INCLUDES_PRIV $$PROTO_FILES_PRIV")
-    system("QT_PROTOBUF_OPTIONS=$$GENERATOR_OPTIONS protoc --plugin=protoc-gen-@GENERATOR_TARGET@=@QTPROTOBUF_EXECUTABLE_INSTALL@ --@GENERATOR_TARGET@_out=$$GENERATED_OUT_DIR $$PROTO_INCLUDES_PRIV $$PROTO_FILES_PRIV"):OK=true
+    message("QT_PROTOBUF_OPTIONS=$$GENERATOR_OPTIONS protoc --plugin=protoc-gen-@GENERATOR_TARGET@=@QT_PROTOBUF_EXECUTABLE_INSTALL@ --@GENERATOR_TARGET@_out=$$GENERATED_OUT_DIR $$PROTO_INCLUDES_PRIV $$PROTO_FILES_PRIV")
+    system("QT_PROTOBUF_OPTIONS=$$GENERATOR_OPTIONS protoc --plugin=protoc-gen-@GENERATOR_TARGET@=@QT_PROTOBUF_EXECUTABLE_INSTALL@ --@GENERATOR_TARGET@_out=$$GENERATED_OUT_DIR $$PROTO_INCLUDES_PRIV $$PROTO_FILES_PRIV"):OK=true
     SOURCES += $$files($$GENERATED_OUT_DIR/*.cpp)
     HEADERS += $$files($$GENERATED_OUT_DIR/*.h)
     INCLUDEPATH += $$GENERATED_OUT_DIR

+ 3 - 3
src/protobuf/quick/CMakeLists.txt

@@ -7,7 +7,7 @@ set(CMAKE_AUTORCC ON)
 
 find_package(Qt5 COMPONENTS Core Qml REQUIRED)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufCommon.cmake)
 
 extract_qt_variable(QT_INSTALL_QML)
 
@@ -21,13 +21,13 @@ file(GLOB HEADERS
     qtprotobufquick_global.h)
 
 add_library(${TARGET} SHARED ${SOURCES})
-target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf)
+target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml ${QT_PROTOBUF_PROJECT}::QtProtobuf)
 set_target_properties(${TARGET} PROPERTIES
     LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/QtProtobuf"
     RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/QtProtobuf"
     RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}/QtProtobuf"
     RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/QtProtobuf")
-target_compile_definitions(${TARGET} PRIVATE QTPROTOBUFQUICK_LIB)
+target_compile_definitions(${TARGET} PRIVATE QT_PROTOBUF_QUICK_LIB)
 
 #Check for QML private headers
 if(NOT DEFINED Qt5Qml_PRIVATE_INCLUDE_DIRS OR Qt5Qml_PRIVATE_INCLUDE_DIRS STREQUAL "")

+ 3 - 3
src/protobuf/quick/qtprotobufquick_global.h

@@ -27,8 +27,8 @@
 
 #include <QtCore/QtGlobal>
 
-#ifdef QTPROTOBUFQUICK_LIB
-    #define QTPROTOBUFQUICKSHARED_EXPORT Q_DECL_EXPORT
+#ifdef QT_PROTOBUF_QUICK_LIB
+    #define QT_PROTOBUF_QUICK_SHARED_EXPORT Q_DECL_EXPORT
 #else
-    #define QTPROTOBUFQUICKSHARED_EXPORT Q_DECL_IMPORT
+    #define QT_PROTOBUF_QUICK_SHARED_EXPORT Q_DECL_IMPORT
 #endif

+ 1 - 1
src/protobuf/quick/qtprotobufquickplugin.cpp

@@ -38,7 +38,7 @@ static QVariant coverter(const QString &str) {
 void QtProtobufQuickPlugin::registerTypes(const char *uri)
 {
     Q_ASSERT(uri == QLatin1String("QtProtobuf"));
-    qmlRegisterModule(uri, QTPROTOBUF_VERSION_MAJOR, QTPROTOBUF_VERSION_MINOR);
+    qmlRegisterModule(uri, QT_PROTOBUF_VERSION_MAJOR, QT_PROTOBUF_VERSION_MINOR);
     QQmlMetaType::registerCustomStringConverter(qMetaTypeId<QtProtobuf::int32>(), coverter<QtProtobuf::int32>);
     QQmlMetaType::registerCustomStringConverter(qMetaTypeId<QtProtobuf::fixed32>(), coverter<QtProtobuf::fixed32>);
     QQmlMetaType::registerCustomStringConverter(qMetaTypeId<QtProtobuf::sfixed32>(), coverter<QtProtobuf::sfixed32>);

+ 1 - 1
src/protobuf/quick/qtprotobufquickplugin.h

@@ -32,7 +32,7 @@
  * \private
  * \brief The QtProtobufQuickPlugin class
  */
-class QTPROTOBUFQUICKSHARED_EXPORT QtProtobufQuickPlugin : public QQmlExtensionPlugin
+class QT_PROTOBUF_QUICK_SHARED_EXPORT QtProtobufQuickPlugin : public QQmlExtensionPlugin
 {
     Q_OBJECT
     Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)

+ 18 - 18
src/wellknowntypes/CMakeLists.txt

@@ -6,7 +6,7 @@ set(TARGET_CONFIG ${TARGET}Config)
 set(TARGET_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/QtProtobuf/google/protobuf)
 set(TARGET_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
 set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
-set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
@@ -14,11 +14,11 @@ set(CMAKE_AUTORCC ON)
 find_package(Qt5 COMPONENTS Core Qml REQUIRED)
 find_package(Protobuf QUIET)
 
-set(PROTO_PARSER ${QTPROTOBUF_BINARY_DIR}/parsemessages.go)
+set(PROTO_PARSER ${QT_PROTOBUF_BINARY_DIR}/parsemessages.go)
 
-include(${QTPROTOBUF_CMAKE_DIR}/Coverage.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufGen.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/Coverage.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/GenerateQtHeaders.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufGen.cmake)
 
 file(GLOB SOURCES
     timestamp.qpb.cpp)
@@ -30,7 +30,7 @@ file(GLOB PUBLIC_HEADER
     qtprotobufwellknowntypes_global.qbp.h)
 
 function(add_wellknowntype TYPENAME)
-    list(APPEND LOOKUP_DIRS ${QTPROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src)
+    list(APPEND LOOKUP_DIRS ${QT_PROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src)
     list(APPEND LOOKUP_DIRS ${Protobuf_INCLUDE_DIRS})
     foreach(INCLUDE_DIR ${LOOKUP_DIRS})
         file(GLOB PROTO_FILE ${INCLUDE_DIR}/google/protobuf/${TYPENAME}.proto)
@@ -42,7 +42,7 @@ function(add_wellknowntype TYPENAME)
                 PROTO_INCLUDES -I${INCLUDE_DIR}
                 QML)
             target_include_directories(${TYPENAME} PRIVATE
-                $<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
+                $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes,INTERFACE_INCLUDE_DIRECTORIES>)
             get_target_property(GENERATED_PUBLIC_HEADER_PRIVATE ${TYPENAME} PUBLIC_HEADER)
             set(GENERATED_PUBLIC_HEADER "${GENERATED_PUBLIC_HEADER};${GENERATED_PUBLIC_HEADER_PRIVATE}" PARENT_SCOPE)
             break()
@@ -73,11 +73,11 @@ add_dependencies(api type source_context)
 
 protobuf_generate_qt_headers(PUBLIC_HEADER ${PUBLIC_HEADER} COMPONENT ${TARGET})
 
-target_compile_definitions(${TARGET} PRIVATE QT_BUILD_PROTOBUF_WELLKNOWNTYPES_LIB PUBLIC QTPROTOBUF_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
-    QTPROTOBUF_VERSION_MINOR=${PROJECT_VERSION_MINOR})
+target_compile_definitions(${TARGET} PRIVATE QT_BUILD_PROTOBUF_WELLKNOWNTYPES_LIB PUBLIC QT_PROTOBUF_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
+    QT_PROTOBUF_VERSION_MINOR=${PROJECT_VERSION_MINOR})
 
 set_target_properties(${TARGET} PROPERTIES VERSION ${PROJECT_VERSION} PUBLIC_HEADER "${PUBLIC_HEADER};${GENERATED_PUBLIC_HEADER}" OUTPUT_NAME ${TARGET}
-    PROTO_INCLUDES -I${QTPROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src)
+    PROTO_INCLUDES -I${QT_PROTOBUF_SOURCE_DIR}/3rdparty/grpc/third_party/protobuf/src)
 
 target_compile_features(${TARGET} PUBLIC cxx_std_14
     cxx_auto_type
@@ -91,30 +91,30 @@ target_compile_features(${TARGET} PUBLIC cxx_std_14
 target_include_directories(${TARGET} PUBLIC
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
     $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
-    $<BUILD_INTERFACE:${QTPROTOBUF_BINARY_DIR}/include/${TARGET}>
+    $<BUILD_INTERFACE:${QT_PROTOBUF_BINARY_DIR}/include/${TARGET}>
     $<INSTALL_INTERFACE:${TARGET_INCLUDE_DIR}>
     )
 
-add_library(${QTPROTOBUF_COMMON_NAMESPACE}::${TARGET} ALIAS ${TARGET})
+add_library(${QT_PROTOBUF_PROJECT}::${TARGET} ALIAS ${TARGET})
 
-target_link_libraries(${TARGET} PUBLIC Qt5::Core Qt5::Qml ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf)
+target_link_libraries(${TARGET} PUBLIC Qt5::Core Qt5::Qml ${QT_PROTOBUF_PROJECT}::QtProtobuf)
 
 install(TARGETS ${TARGET}
     EXPORT ${TARGET_EXPORT}
     ARCHIVE DESTINATION ${TARGET_LIB_DIR}
     PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR}
     LIBRARY DESTINATION ${TARGET_LIB_DIR}
-    RUNTIME DESTINATION ${TARGET_BIN_DIR})
+    RUNTIME DESTINATION ${TARGET_BINDIR})
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
-    "${TARGET_CONFIG}.cmake.in" "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
+    "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QTPROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
 
-export(TARGETS ${TARGET} NAMESPACE ${QTPROTOBUF_COMMON_NAMESPACE}:: FILE ${TARGET_EXPORT}.cmake)
+export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)
 
 add_coverage_target(TARGET ${TARGET})

+ 1 - 1
tests/test_grpc/CMakeLists.txt

@@ -1,4 +1,4 @@
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 
 # clients
 add_test_target(TARGET qtgrpc_test

+ 1 - 1
tests/test_protobuf/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET qtprotobuf_test)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 
 file(GLOB SOURCES
     simpletest.cpp

+ 1 - 1
tests/test_protobuf_multifile/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET qtprotobuf_test_multifile)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 
 file(GLOB SOURCES
     simpletest.cpp)

+ 2 - 4
tests/test_qml/CMakeLists.txt

@@ -3,7 +3,7 @@ set(TARGET qtprotobuf_qml_test)
 find_package(Qt5 COMPONENTS Core Quick Network Test QuickTest REQUIRED)
 find_package(QtProtobufProject COMPONENTS QtProtobuf REQUIRED)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 
 file(GLOB SOURCES main.cpp)
 file(GLOB QML_FILES qml/tst_simple.qml)
@@ -17,7 +17,5 @@ add_target_windeployqt(TARGET ${TARGET} QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
 
 add_test(NAME ${TARGET} COMMAND ${TARGET})
 
-set(QTPROTOBUF_QML2_IMPORT_PATH $<TARGET_FILE_DIR:protobufquickplugin>/..)
-
 set_tests_properties(${TARGET} PROPERTIES
-    ENVIRONMENT QML2_IMPORT_PATH=${QTPROTOBUF_QML2_IMPORT_PATH})
+    ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:protobufquickplugin>/..)

+ 2 - 2
tests/test_qprotobuf_serializer_plugin/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET qtprotobuf_plugin_test)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 
 find_package(Threads REQUIRED)
 find_package(Qt5 COMPONENTS Test REQUIRED)
@@ -16,7 +16,7 @@ set(CMAKE_CXX_STANDARD 14)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 add_executable(${TARGET} ${SOURCES})
-target_link_libraries(${TARGET} PRIVATE gtest_main gtest ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf ${QTPROTOBUF_COMMON_NAMESPACE}::QtGrpc Qt5::Core Qt5::Test Qt5::Network ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${TARGET} PRIVATE gtest_main gtest ${QT_PROTOBUF_PROJECT}::QtProtobuf ${QT_PROTOBUF_PROJECT}::QtGrpc Qt5::Core Qt5::Test Qt5::Network ${CMAKE_THREAD_LIBS_INIT})
 qtprotobuf_link_archive(${TARGET} qtprotobuf_test_qtprotobuf_gen)
 add_target_windeployqt(TARGET ${TARGET}
     QML_DIR ${CMAKE_CURRENT_SOURCE_DIR})

+ 2 - 2
tests/test_qprotobuf_serializer_plugin/serialization/CMakeLists.txt

@@ -3,7 +3,7 @@ set(TARGET serializationplugin)
 set(TARGET_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET})
 set(TARGET_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
 set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
-set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
@@ -20,7 +20,7 @@ file(GLOB HEADERS
     qtserialization_global.h)
 
 add_library(${TARGET} SHARED ${SOURCES})
-target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf)
+target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml ${QT_PROTOBUF_PROJECT}::QtProtobuf)
 target_compile_definitions(${TARGET} PRIVATE SERIALIZATION_LIB)
 
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/serializeinfo.json" "${CMAKE_CURRENT_BINARY_DIR}/serializeinfo.json" COPYONLY)

+ 3 - 3
tests/test_wellknowntypes/CMakeLists.txt

@@ -1,6 +1,6 @@
 set(TARGET wellknowntypes_test)
 
-include(${QTPROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
+include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
 find_package(QtProtobufProject CONFIG COMPONENTS QtProtobuf QtGrpc QtProtobufWellKnownTypes REQUIRED)
 
 file(GLOB SOURCES
@@ -8,10 +8,10 @@ file(GLOB SOURCES
 
 add_test_target(TARGET ${TARGET}
     SOURCES ${SOURCES}
-    PROTO_INCLUDES $<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobufWellKnownTypes,PROTO_INCLUDES>
+    PROTO_INCLUDES $<TARGET_PROPERTY:${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes,PROTO_INCLUDES>
     QML)
 add_target_windeployqt(TARGET ${TARGET}
     QML_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
-target_link_libraries(${TARGET} PRIVATE ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobufWellKnownTypes)
+target_link_libraries(${TARGET} PRIVATE ${QT_PROTOBUF_PROJECT}::QtProtobufWellKnownTypes)
 add_test(NAME ${TARGET} COMMAND ${TARGET})