mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Create and install dlibConfig.cmake and dlibConfigVersion.cmake
This allows external project to include dlib by simply using find_package(dlib REQUIRED) and: include_directories() / target_link_libraries(your_target )
This commit is contained in:
parent
c90b7a0cd0
commit
6ef9c2eee1
@ -13,6 +13,7 @@ project(dlib)
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "18")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "17")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "99")
|
||||
set(VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
|
||||
|
||||
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
||||
# Suppress cmake warnings about changes in new versions.
|
||||
@ -427,7 +428,9 @@ if (NOT TARGET dlib)
|
||||
|
||||
# Install the library
|
||||
if (RELEASE_MODE)
|
||||
set_target_properties(dlib-shared PROPERTIES OUTPUT_NAME dlib)
|
||||
set_target_properties(dlib-shared PROPERTIES
|
||||
OUTPUT_NAME dlib
|
||||
VERSION ${VERSION})
|
||||
install(TARGETS dlib dlib-shared
|
||||
EXPORT dlib
|
||||
LIBRARY DESTINATION lib
|
||||
@ -447,6 +450,27 @@ if (NOT TARGET dlib)
|
||||
|
||||
install(FILES "LICENSE.txt" DESTINATION share/doc/dlib)
|
||||
|
||||
## Config.cmake generation and installation
|
||||
|
||||
set(ConfigPackageLocation lib/cmake/dlib)
|
||||
install(EXPORT dlib
|
||||
NAMESPACE dlib::
|
||||
DESTINATION ${ConfigPackageLocation})
|
||||
|
||||
set(CONF_INSTALL_PATH "\${dlib_CMAKE_DIR}/../../../")
|
||||
configure_file(dlibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/dlibConfig.cmake" @ONLY)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/dlibConfigVersion.cmake"
|
||||
VERSION ${VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/dlibConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/dlibConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation})
|
||||
endif()
|
||||
|
||||
|
||||
|
39
dlib/dlibConfig.cmake.in
Normal file
39
dlib/dlibConfig.cmake.in
Normal file
@ -0,0 +1,39 @@
|
||||
# ===================================================================================
|
||||
# The dlib CMake configuration file
|
||||
#
|
||||
# ** File generated automatically, do not modify **
|
||||
#
|
||||
# Usage from an external project:
|
||||
# In your CMakeLists.txt, add these lines:
|
||||
#
|
||||
# FIND_PACKAGE(dlib REQUIRED)
|
||||
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${dlib_LIBRARIES})
|
||||
#
|
||||
# This file will define the following variables:
|
||||
# - dlib_LIBRARIES : The list of all imported targets for dlib modules.
|
||||
# - dlib_INCLUDE_DIRS : The dlib include directories.
|
||||
# - dlib_VERSION : The version of this dlib build.
|
||||
# - dlib_VERSION_MAJOR : Major version part of this dlib revision.
|
||||
# - dlib_VERSION_MINOR : Minor version part of this dlib revision.
|
||||
#
|
||||
# ===================================================================================
|
||||
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(dlib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8)
|
||||
get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" ABSOLUTE)
|
||||
else()
|
||||
get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" REALPATH)
|
||||
endif()
|
||||
|
||||
set(dlib_INCLUDE_DIRS "${dlib_INSTALL_PATH}/include")
|
||||
|
||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||
if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR)
|
||||
include("${dlib_CMAKE_DIR}/dlib.cmake")
|
||||
endif()
|
||||
|
||||
find_library(dlib_LIBRARIES dlib HINTS ${dlib_INSTALL_PATH}/lib)
|
||||
set(dlib_LIBRARIES ${dlib_LIBRARIES} "@dlib_needed_libraries@")
|
Loading…
Reference in New Issue
Block a user