modernized cmake installation with IMPORTED target export

This commit is contained in:
Abhijit Kundu
2014-12-02 20:36:53 -05:00
parent c3551d3c2c
commit c0b092d796
5 changed files with 41 additions and 21 deletions

View File

@@ -5,15 +5,14 @@ configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}
PATH_VARS INSTALL_INCLUDE_DIR
)
install(EXPORT ${PROJECT_NAME}Targets
DESTINATION ${INSTALL_CMAKE_DIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT Devel
)
install(EXPORT ${PROJECT_NAME}Targets
DESTINATION ${INSTALL_CMAKE_DIR}
)

View File

@@ -17,7 +17,7 @@ SET(INSTALL_INCLUDE_DIR include/${PROJECT_NAME} CACHE PATH "Install dir for head
IF(WIN32 AND NOT CYGWIN)
SET(DEF_INSTALL_CMAKE_DIR CMake)
ELSE()
SET(DEF_INSTALL_CMAKE_DIR lib/CMake/${PROJECT_NAME})
SET(DEF_INSTALL_CMAKE_DIR lib/cmake/${PROJECT_NAME})
ENDIF()
SET(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Install dir for CMake files")

View File

@@ -1,13 +1,30 @@
# Config file for the QtPropertyBrowser package
# It defines the following variables
# This adds QtPropertyBrowser IMPORTED target
#
# Usage example:
#
# find_package(QtPropertyBrowser)
# add_executable(foo foo.cpp)
# target_link_libraries(foo QtPropertyBrowser)
#
# Additionaly you can use the following varaibles:
#
# QtPropertyBrowser_FOUND - standard CMake Package found indicator
# QtPropertyBrowser_INCLUDE_DIRS - include directories for QtPropertyBrowser
# QtPropertyBrowser_INCLUDE_DIR - include directories for QtPropertyBrowser alone
# QtPropertyBrowser_INCLUDE_DIRS - include directories for QtPropertyBrowser with all dpendencies
# QtPropertyBrowser_DEFINITIONS - Definitions needed to build with QtPropertyBrowser
# QtPropertyBrowser_LIBRARIES - Libraries needed to build with QtPropertyBrowser
set (QtPropertyBrowser_FOUND true)
include(CMakeFindDependencyMacro)
find_dependency(Qt5Widgets)
@PACKAGE_INIT@
set_and_check (QtPropertyBrowser_INCLUDE_DIRS "@PACKAGE_INSTALL_INCLUDE_DIR@")
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET QtPropertyBrowser)
include("${CMAKE_CURRENT_LIST_DIR}/QtPropertyBrowserTargets.cmake")
endif()
# @PACKAGE_INIT@
# check_required_components(QtPropertyBrowser)