Browse Source

Add cpack based debian package generation

- Increase minimum required cmake version to 3.6 for CPack support
- Add packaging README section
- Add component install separation

Fixes: #46
Alexey Edelev 4 years ago
parent
commit
08c6bb50c6

+ 6 - 2
CMakeLists.txt

@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.6)
 
 set(QT_PROTOBUF_VERSION 0.1.1)
 set(QT_PROTOBUF_PROJECT QtProtobufProject)
@@ -76,7 +76,8 @@ endif()
 configure_package_config_file(
     "${CMAKE_CURRENT_SOURCE_DIR}/ProjectConfig.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
     INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")
-install(FILES "${QT_PROTOBUF_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}"
+    COMPONENT dev)
 
 export(PACKAGE ${PROJECT_NAME})
 
@@ -141,3 +142,6 @@ endif()
 if(QT_PROTOBUF_MAKE_EXAMPLES)
     add_subdirectory("examples")
 endif()
+
+include("${QT_PROTOBUF_CMAKE_DIR}/packaging.cmake")
+

+ 20 - 5
README.md

@@ -37,6 +37,8 @@ gRPC and Protobuf generator and bindings for Qt framework
 ## Prerequesties
 
 Check installation of following packages in your system:
+- cmake 3.6 or higher
+- Qt 5.12.4 or higher
 - protobuf 3.6.0 or higher
 - grpc 1.15.0 or higher
 - golang 1.10 or higher (Mandatory dependency for any type of build)
@@ -44,18 +46,18 @@ Check installation of following packages in your system:
 >**Note:** Older versions could be supported as well but not officially tested.
 
 
-### For Ubuntu
+### For Ubuntu 19.04 or higher
 
-Install GRPC packages in system:
+Install dependencies:
 
 ```bash
-sudo apt-get install libgrpc++-dev protobuf-compiler-grpc libgrpc++1 libgrpc-dev libgrpc6
+sudo apt-get install qtdeclarative5-private-dev qtbase5-private-dev protobuf-compiler libprotoc-dev protobuf-compiler-grpc libgrpc++-dev libgrpc-dev libgtest-dev
 ```
 
 
 ### 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
+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:
 
@@ -72,10 +74,23 @@ cmake .. [-DCMAKE_PREFIX_PATH="<path/to/qt/installation>/Qt<qt_version>/<qt_vers
 cmake --build . [--config <RELEASE|DEBUG>] -- -j<N>
 ```
 
+## Packaging
+QtProtobuf has packaging support based on CPack.
+
+### .deb
+You can create .deb package for debian-like operating systems, using commands below:
+
+```bash
+mkdir build
+cd build
+cmake .. -DQT_PROTOBUF_MAKE_TESTS=FALSE -DQT_PROTOBUF_MAKE_EXAMPLES=FALSE
+cpack -G DEB ..
+```
+
+>**Note:** Only tested on Ubuntu 19.04
 
 # Windows Build
 ## Prerequesties
-
 Download and install:
 
 - Qt 5.12.3 or higher [1](https://download.qt.io/official_releases/qt/)

+ 10 - 0
cmake/deb.cmake

@@ -0,0 +1,10 @@
+set(CPACK_DEB_COMPONENT_INSTALL ON)
+
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "protobuf-compiler (>= 3.6.0), libprotoc17 (>= 3.6.0), golang (>= 1.10.0), libqt5core5a (>= 5.12.4), libqt5qml5 (>= 5.12.4), libqt5network5 (>= 5.12.4), libqt5quick5 (>= 5.12.4)")
+set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "lib${CPACK_PACKAGE_NAME} (= ${PROJECT_VERSION}), qtdeclarative5-dev (>= 5.12.4), qtbase5-dev (>= 5.12.4), libgrpc-dev (>= 1.15.0), libgrpc++-dev (>= 1.15.0), libprotoc-dev (>= 3.6.0)")
+set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
+set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://semlanik.github.io/qtprotobuf/")
+set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+set(CPACK_DEBIAN_LIB_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}")
+set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${CPACK_PACKAGE_NAME}-dev")

+ 7 - 0
cmake/packaging.cmake

@@ -0,0 +1,7 @@
+set(CPACK_PACKAGE_CONTACT "Alexey Edelev <semlanik@gmail.com>")
+set(CPACK_PACKAGE_DESCRIPTION "gRPC and Protobuf generator and bindings for Qt framework")
+set(CPACK_PACKAGE_NAME "qtprotobuf")
+
+include("${QT_PROTOBUF_CMAKE_DIR}/deb.cmake")
+include("${QT_PROTOBUF_CMAKE_DIR}/rpm.cmake")
+include(CPack)

+ 1 - 0
cmake/rpm.cmake

@@ -0,0 +1 @@
+#TODO: implement rpm packaging

+ 1 - 1
src/generator/CMakeLists.txt

@@ -47,4 +47,4 @@ endif()
 target_link_libraries(${TARGET} protobuf::libprotobuf protobuf::libprotoc)
 
 install(TARGETS ${TARGET}
-    RUNTIME DESTINATION ${TARGET_BINDIR})
+    RUNTIME DESTINATION ${TARGET_BINDIR} COMPONENT lib)

+ 9 - 9
src/grpc/CMakeLists.txt

@@ -72,30 +72,30 @@ target_compile_features(${TARGET} PUBLIC cxx_std_14
 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_BINDIR})
+    EXPORT ${TARGET_EXPORT} COMPONENT dev
+    ARCHIVE DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR} COMPONENT dev
+    LIBRARY DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    RUNTIME DESTINATION ${TARGET_BINDIR} COMPONENT lib)
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR} COMPONENT dev)
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
     "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)
 
 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}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/gRPCLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 if(QT_PROTOBUF_STATIC) #extra config for .pri file in case if static build enabled
     set(QT_PROTOBUF_EXTRA_CONFIG "staticlib")
 endif()
 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")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/qt_lib_grpc.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules" COMPONENT dev)
 
 add_coverage_target(TARGET ${TARGET})

+ 11 - 11
src/protobuf/CMakeLists.txt

@@ -104,37 +104,37 @@ target_link_libraries(${TARGET} PUBLIC Qt5::Core Qt5::Qml)
 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_BINDIR})
+    EXPORT ${TARGET_EXPORT} COMPONENT dev
+    ARCHIVE DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR} COMPONENT dev
+    LIBRARY DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    RUNTIME DESTINATION ${TARGET_BINDIR} COMPONENT lib)
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR} COMPONENT dev)
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
     "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)
 
 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}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 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}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/parsemessages.go" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 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}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 if(QT_PROTOBUF_STATIC) #extra config for .pri file in case if static build enabled
     set(QT_PROTOBUF_EXTRA_CONFIG "staticlib")
 endif()
 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")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/qt_lib_protobuf.pri" DESTINATION "${QT_HOST_DATA}/mkspecs/modules" COMPONENT dev)
 
 add_subdirectory("quick")
 

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

@@ -42,13 +42,13 @@ foreach(QML_PRIVATE_HEADER IN LISTS Qt5Qml_PRIVATE_INCLUDE_DIRS)
 endforeach()
 
 target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
-install(TARGETS ${TARGET}
-    PUBLIC_HEADER DESTINATION "${TARGET_INCLUDE_DIR}"
-    RUNTIME DESTINATION "${TARGET_IMPORTS_DIR}"
-    LIBRARY DESTINATION "${TARGET_IMPORTS_DIR}")
+install(TARGETS ${TARGET} COMPONENT lib
+    PUBLIC_HEADER DESTINATION "${TARGET_INCLUDE_DIR}" COMPONENT dev
+    RUNTIME DESTINATION "${TARGET_IMPORTS_DIR}" COMPONENT lib
+    LIBRARY DESTINATION "${TARGET_IMPORTS_DIR}" COMPONENT lib)
 
 add_custom_command(TARGET ${TARGET}
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir $<TARGET_FILE_DIR:${TARGET}>/qmldir
     COMMENT "Copying qmldir to binary directory")
 
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION "${TARGET_IMPORTS_DIR}")
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION "${TARGET_IMPORTS_DIR}" COMPONENT lib)

+ 7 - 7
src/wellknowntypes/CMakeLists.txt

@@ -100,20 +100,20 @@ add_library(${QT_PROTOBUF_PROJECT}::${TARGET} ALIAS ${TARGET})
 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_BINDIR})
+    EXPORT ${TARGET_EXPORT} COMPONENT dev
+    ARCHIVE DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    PUBLIC_HEADER DESTINATION ${TARGET_INCLUDE_DIR} COMPONENT dev
+    LIBRARY DESTINATION ${TARGET_LIB_DIR} COMPONENT lib
+    RUNTIME DESTINATION ${TARGET_BINDIR} COMPONENT lib)
 
-install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR})
+install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR} COMPONENT dev)
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(
     "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
     INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
 
-install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}")
+install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake" DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
 
 export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)