Commit 5cf97d4d authored by Luigi Toscano's avatar Luigi Toscano
Browse files

Dynamically generate the config file for CMake

This is the more modern way. INCLUDE_DIR and LIBRARY are not exported, but
the information required are exported through targets and they will be
used by the application through target_link_libraries.
parent 9cf1978b
......@@ -8,12 +8,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_D
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMOptionalAddSubdirectory)
include(ECMPackageConfigHelpers)
include(ECMSetupVersion)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
find_package(Qt5 5.4 CONFIG REQUIRED Core Gui)
set(REQUIRED_QT_VERSION 5.4.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui)
ecm_setup_version("2.0.0"
VARIABLE_PREFIX QMOBIPOCKET
......@@ -34,10 +36,23 @@ if(STRIGI_STREAMS_LIBRARY)
ecm_optional_add_subdirectory(strigi)
endif()
set(CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/QMobipocket")
ecm_configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/QMobipocketConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/QMobipocketConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(EXPORT QMobipocketTargets
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
FILE QMobipocketTargets.cmake
)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/QMobipocketConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/QMobipocketConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/QMobipocketConfigVersion.cmake
DESTINATION ${LIB_INSTALL_DIR}/cmake/QMobipocket
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
......
get_filename_component( _currentDir ${CMAKE_CURRENT_LIST_FILE} PATH)
get_filename_component( _currentDir ${_currentDir} PATH)
get_filename_component( _currentDir ${_currentDir} PATH)
get_filename_component( _currentDir ${_currentDir} PATH)
# find the full paths to the library and the includes:
find_path(QMOBIPOCKET_INCLUDE_DIR qmobipocket/mobipocket.h
HINTS ${_currentDir}/include
NO_DEFAULT_PATH)
find_library(QMOBIPOCKET_LIBRARY qmobipocket
HINTS ${_currentDir}/lib
NO_DEFAULT_PATH)
set(QMOBIPOCKET_LIBRARIES ${QMOBIPOCKET_LIBRARY})
if(QMOBIPOCKET_INCLUDE_DIR AND QMOBIPOCKET_LIBRARY)
set(QMOBIPOCKET_FOUND TRUE)
endif()
@PACKAGE_INIT@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
find_dependency(Qt5Core "@REQUIRED_QT_VERSION@")
find_dependency(Qt5Gui "@REQUIRED_QT_VERSION@")
find_dependency(KF5I18n)
include("${CMAKE_CURRENT_LIST_DIR}/QMobipocketTargets.cmake")
......@@ -20,5 +20,5 @@ install(FILES
DESTINATION ${INCLUDE_INSTALL_DIR}/qmobipocket/ COMPONENT Devel
)
install(TARGETS qmobipocket ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS qmobipocket EXPORT QMobipocketTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
set_target_properties(qmobipocket PROPERTIES VERSION ${QMOBIPOCKET_VERSION} SOVERSION ${QMOBIPOCKET_SOVERSION})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment