From 6a08938521c8258c52147af8bcf14399c8f7a827 Mon Sep 17 00:00:00 2001
From: Tobias Kraehling <Tobias.Kraehling@SemiByte.de>
Date: Wed, 21 Oct 2020 06:47:39 +0200
Subject: [PATCH 1/2] COMP: Support install of QtSOAP headers and library

---
 src/CMakeLists.txt | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0641667..b529cf9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,6 +9,23 @@ SET(KIT_MOC_SRCS
   qtsoap.h
   )
 
+set(KIT_HEADERS
+    qtsoap.h
+    QtSoapTypeFactory
+    QtSoapTypeConstructorBase
+    QtSoapTypeConstructor
+    QtSoapType
+    QtSoapStructIterator
+    QtSoapStruct
+    QtSoapSimpleType
+    QtSoapQName
+    QtSoapNamespaces
+    QtSoapMessage
+    QtSoapHttpTransport
+    QtSoapArrayIterator
+    QtSoapArray 
+   )
+
 INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
@@ -45,3 +62,13 @@ TARGET_LINK_LIBRARIES(
 IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
   SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")
 ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
+
+install(
+  TARGETS ${PROJECT_NAME}
+  EXPORT ${targets_export_name}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+  )
+
+install(FILES ${KIT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

From 76174831e035a2464849893f0a6309e609a62e06 Mon Sep 17 00:00:00 2001
From: Tobias Kraehling <Tobias.Kraehling@SemiByte.de>
Date: Sat, 24 Oct 2020 13:59:51 +0200
Subject: [PATCH 2/2] COMP: Support building against QtSOAP install tree

---
 CMakeLists.txt        | 51 ++++++++++++++++++++++++++++++++++++++++++-
 QtSOAPConfig.cmake.in | 37 ++-----------------------------
 src/CMakeLists.txt    | 12 +++++++---
 3 files changed, 61 insertions(+), 39 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbe7f73..e530625 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,9 @@ else()
   cmake_minimum_required(VERSION 2.8.2)
 endif()
 
-PROJECT(QtSOAP)
+cmake_policy(SET CMP0048 NEW)
+project(QtSOAP VERSION 2.7.1)
+
 
 include(CTestUseLaunchers OPTIONAL)
 
@@ -47,6 +49,53 @@ else()
   include(${QT_USE_FILE})
 endif()
 
+#-----------------------------------------------------------------------------
+# Installation (https://github.com/forexample/package-example)
+include(GNUInstallDirs)
+set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
+install(DIRECTORY doc/html/ DESTINATION ${CMAKE_INSTALL_DOCDIR})
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/UseQtSOAP.cmake DESTINATION ${config_install_dir})
+
+set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
+set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
+set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
+set(targets_export_name "${PROJECT_NAME}Targets")
+set(namespace "${PROJECT_NAME}::")
+
+# Include module with function 'write_basic_package_version_file'
+include(CMakePackageConfigHelpers)
+
+# Configure '<PROJECT-NAME>ConfigVersion.cmake'
+# Use:
+#   * PROJECT_VERSION
+write_basic_package_version_file(
+  "${version_config}" COMPATIBILITY SameMajorVersion
+)
+
+# Configure '<PROJECT-NAME>Config.cmake'
+# Use variables:
+#   * targets_export_name
+#   * PROJECT_NAME
+configure_package_config_file(
+  "QtSOAPConfig.cmake.in"
+  "${project_config}"
+  INSTALL_DESTINATION "${config_install_dir}"
+  NO_CHECK_REQUIRED_COMPONENTS_MACRO
+)
+
+
+
+install(
+  FILES "${project_config}" "${version_config}"
+  DESTINATION "${config_install_dir}"
+)
+
+install(
+  EXPORT "${targets_export_name}"
+  NAMESPACE "${namespace}"
+  DESTINATION "${config_install_dir}"
+)
+
 #-----------------------------------------------------------------------------
 # Subdirectories
 #
diff --git a/QtSOAPConfig.cmake.in b/QtSOAPConfig.cmake.in
index 20118aa..fc4eaba 100644
--- a/QtSOAPConfig.cmake.in
+++ b/QtSOAPConfig.cmake.in
@@ -21,39 +21,6 @@
 #
 # QtSOAPConfig.cmake - QtSOAP CMake configuration file for external projects.
 #
+@PACKAGE_INIT@
 
-SET(QtSOAP_LIBRARIES @PROJECT_NAME@)
-
-# The QtSOAP include file directories.
-SET(QtSOAP_INCLUDE_DIRS "@QtSOAP_INCLUDE_DIRS_CONFIG@")
-
-# The QtSOAP library directories. Note that if
-# QtSOAP_CONFIGURATION_TYPES is set (see below) then these directories
-# will be the parent directories under which there will be a directory
-# of runtime binaries for each configuration type.
-SET(QtSOAP_LIBRARY_DIRS "@QtSOAP_LIBRARY_DIRS_CONFIG@")
-
-# The QtSOAP runtime library directories. Note that if
-# QtSOAP_CONFIGURATION_TYPES is set (see below) then these directories
-# will be the parent directories under which there will be a directory
-# of runtime libraries for each configuration type.
-SET(QtSOAP_RUNTIME_LIBRARY_DIRS "@QtSOAP_RUNTIME_LIBRARY_DIRS_CONFIG@")
-
-# The location of the UseQtSOAP.cmake file.
-SET(QtSOAP_USE_FILE "@QtSOAP_USE_FILE@")
-
-
-# A QtSOAP install tree always provides one build configuration.
-# A QtSOAP build tree may provide either one or multiple build
-# configurations depending on the CMake generator used.
-# Since QtSOAP can be used either from a build tree or an install
-# tree it is useful for outside projects to know the configurations available.
-# If this QtSOAPConfig.cmake is in a QtSOAP install
-# tree QtSOAP_CONFIGURATION_TYPES will be empty and
-# QtSOAP_BUILD_TYPE will be set to the value of
-# CMAKE_BUILD_TYPE used to build QtSOAP. If QtSOAPConfig.cmake
-# is in a QtSOAP build tree then QtSOAP_CONFIGURATION_TYPES
-# and QtSOAP_BUILD_TYPE will have values matching CMAKE_CONFIGURATION_TYPES
-# and CMAKE_BUILD_TYPE for that build tree (only one will ever be set).
-SET(QtSOAP_CONFIGURATION_TYPES @QtSOAP_CONFIGURATION_TYPES_CONFIG@)
-SET(QtSOAP_BUILD_TYPE @QtSOAP_BUILD_TYPE_CONFIG@)
+include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b529cf9..7aeee1b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -25,7 +25,7 @@ set(KIT_HEADERS
     QtSoapArrayIterator
     QtSoapArray 
    )
-
+  
 INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
@@ -53,6 +53,12 @@ TARGET_LINK_LIBRARIES(
   ${libname}
   ${${PROJECT_NAME}_LINK_LIBRARIES}
   )
+target_include_directories(
+  ${libname}
+  PUBLIC
+    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
+    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+  )
 
 #-----------------------------------------------------------------------------
 #
@@ -69,6 +75,6 @@ install(
   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
   ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
   RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-  )
+)
 
-install(FILES ${KIT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES ${KIT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})