Skip to content

Commit d2f0968

Browse files
committed
Support using QtSOAP in external projects and setup dependencies using CMake modules
1 parent 8fb8bde commit d2f0968

File tree

3 files changed

+60
-37
lines changed

3 files changed

+60
-37
lines changed

CMakeLists.txt

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ else()
1515
cmake_minimum_required(VERSION 2.8.2)
1616
endif()
1717

18-
PROJECT(QtSOAP)
18+
cmake_policy(SET CMP0048 NEW)
19+
PROJECT(QtSOAP VERSION 2.7.1)
20+
1921

2022
include(CTestUseLaunchers OPTIONAL)
2123

@@ -47,6 +49,54 @@ else()
4749
include(${QT_USE_FILE})
4850
endif()
4951

52+
53+
#-----------------------------------------------------------------------------
54+
# Installation (https://github.com/forexample/package-example)
55+
include( GNUInstallDirs )
56+
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
57+
install( DIRECTORY doc/html/ DESTINATION ${CMAKE_INSTALL_DOCDIR} )
58+
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/UseQtSOAP.cmake DESTINATION ${config_install_dir} )
59+
60+
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
61+
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
62+
set(project_config "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
63+
set(targets_export_name "${PROJECT_NAME}Targets")
64+
set(namespace "${PROJECT_NAME}::")
65+
66+
# Include module with function 'write_basic_package_version_file'
67+
include(CMakePackageConfigHelpers)
68+
69+
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
70+
# Use:
71+
# * PROJECT_VERSION
72+
write_basic_package_version_file(
73+
"${version_config}" COMPATIBILITY SameMajorVersion
74+
)
75+
76+
# Configure '<PROJECT-NAME>Config.cmake'
77+
# Use variables:
78+
# * targets_export_name
79+
# * PROJECT_NAME
80+
configure_package_config_file(
81+
"QtSOAPConfig.cmake.in"
82+
"${project_config}"
83+
INSTALL_DESTINATION "${config_install_dir}"
84+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
85+
)
86+
87+
88+
89+
install(
90+
FILES "${project_config}" "${version_config}"
91+
DESTINATION "${config_install_dir}"
92+
)
93+
94+
install(
95+
EXPORT "${targets_export_name}"
96+
NAMESPACE "${namespace}"
97+
DESTINATION "${config_install_dir}"
98+
)
99+
50100
#-----------------------------------------------------------------------------
51101
# Subdirectories
52102
#

QtSOAPConfig.cmake.in

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,6 @@
2121
#
2222
# QtSOAPConfig.cmake - QtSOAP CMake configuration file for external projects.
2323
#
24+
@PACKAGE_INIT@
2425

25-
SET(QtSOAP_LIBRARIES @PROJECT_NAME@)
26-
27-
# The QtSOAP include file directories.
28-
SET(QtSOAP_INCLUDE_DIRS "@QtSOAP_INCLUDE_DIRS_CONFIG@")
29-
30-
# The QtSOAP library directories. Note that if
31-
# QtSOAP_CONFIGURATION_TYPES is set (see below) then these directories
32-
# will be the parent directories under which there will be a directory
33-
# of runtime binaries for each configuration type.
34-
SET(QtSOAP_LIBRARY_DIRS "@QtSOAP_LIBRARY_DIRS_CONFIG@")
35-
36-
# The QtSOAP runtime library directories. Note that if
37-
# QtSOAP_CONFIGURATION_TYPES is set (see below) then these directories
38-
# will be the parent directories under which there will be a directory
39-
# of runtime libraries for each configuration type.
40-
SET(QtSOAP_RUNTIME_LIBRARY_DIRS "@QtSOAP_RUNTIME_LIBRARY_DIRS_CONFIG@")
41-
42-
# The location of the UseQtSOAP.cmake file.
43-
SET(QtSOAP_USE_FILE "@QtSOAP_USE_FILE@")
44-
45-
46-
# A QtSOAP install tree always provides one build configuration.
47-
# A QtSOAP build tree may provide either one or multiple build
48-
# configurations depending on the CMake generator used.
49-
# Since QtSOAP can be used either from a build tree or an install
50-
# tree it is useful for outside projects to know the configurations available.
51-
# If this QtSOAPConfig.cmake is in a QtSOAP install
52-
# tree QtSOAP_CONFIGURATION_TYPES will be empty and
53-
# QtSOAP_BUILD_TYPE will be set to the value of
54-
# CMAKE_BUILD_TYPE used to build QtSOAP. If QtSOAPConfig.cmake
55-
# is in a QtSOAP build tree then QtSOAP_CONFIGURATION_TYPES
56-
# and QtSOAP_BUILD_TYPE will have values matching CMAKE_CONFIGURATION_TYPES
57-
# and CMAKE_BUILD_TYPE for that build tree (only one will ever be set).
58-
SET(QtSOAP_CONFIGURATION_TYPES @QtSOAP_CONFIGURATION_TYPES_CONFIG@)
59-
SET(QtSOAP_BUILD_TYPE @QtSOAP_BUILD_TYPE_CONFIG@)
26+
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

src/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ TARGET_LINK_LIBRARIES(
5252
${libname}
5353
${${PROJECT_NAME}_LINK_LIBRARIES}
5454
)
55+
TARGET_INCLUDE_DIRECTORIES(
56+
${libname}
57+
PUBLIC
58+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
59+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
60+
)
5561

5662
#-----------------------------------------------------------------------------
5763
#
@@ -70,4 +76,4 @@ install(
7076
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
7177
)
7278

73-
install( FILES ${KIT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
79+
install( FILES ${KIT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} )

0 commit comments

Comments
 (0)