Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve install and using in external projects #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
#
Expand Down
37 changes: 2 additions & 35 deletions QtSOAPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}/@[email protected]")
33 changes: 33 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -36,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}>
)

#-----------------------------------------------------------------------------
#
Expand All @@ -45,3 +68,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}/${PROJECT_NAME})