You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
CMake
62 lines
2.0 KiB
CMake
|
|
# install
|
|
# add the install targets
|
|
# 根目录路径 CMAKE_INSTALL_PREFIX
|
|
include(InstallRequiredSystemLibraries)
|
|
install(TARGETS ${library_name}
|
|
EXPORT ${library_name}
|
|
RUNTIME DESTINATION bin
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
PUBLIC_HEADER DESTINATION include/${library_name} # 头文件安装路径
|
|
)
|
|
#手动安装头文件目录
|
|
INSTALL(FILES ${inc_files}
|
|
DESTINATION include/${library_name})
|
|
|
|
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc
|
|
# DESTINATION include/${library_name}
|
|
# FILES_MATCHING PATTERN "*.h"
|
|
# PATTERN "*Base.h" EXCLUDE)
|
|
|
|
#添加.cmake 支持find_package
|
|
include(CMakePackageConfigHelpers)
|
|
# install the configuration targets
|
|
install(EXPORT ${library_name}
|
|
FILE ${library_name}Targets.cmake
|
|
NAMESPACE ${packet_export_name}::
|
|
DESTINATION lib/cmake/${library_name}
|
|
)
|
|
|
|
#message("CMAKE_CURRENT_BINARY_DIR:${CMAKE_CURRENT_BINARY_DIR}")
|
|
# generate the config file that is includes the exports
|
|
set(package_config_file "${CMAKE_CURRENT_BINARY_DIR}/${library_name}-config.cmake")
|
|
set(package_config_template_file ${config_utils_path}/config.cmake.in)
|
|
set(package_config_version_file "${CMAKE_CURRENT_BINARY_DIR}/${library_name}-config-version.cmake")
|
|
|
|
set(TARGET_NAME ${library_name})
|
|
# generate the config file that is includes the exports
|
|
configure_package_config_file(${package_config_template_file}
|
|
${package_config_file}
|
|
INSTALL_DESTINATION lib/cmake/${library_name}
|
|
PATH_VARS version_info library_name
|
|
NO_SET_AND_CHECK_MACRO
|
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
)
|
|
# generate the version file for the config file
|
|
write_basic_package_version_file(
|
|
${package_config_version_file}
|
|
VERSION ${version_info}
|
|
COMPATIBILITY AnyNewerVersion
|
|
)
|
|
|
|
# install the configuration file
|
|
install(FILES
|
|
${package_config_file} ${package_config_version_file}
|
|
DESTINATION lib/cmake/${library_name}
|
|
)
|
|
# generate the export targets for the build tree
|
|
# needs to be after the install(TARGETS ) command
|
|
export(EXPORT ${library_name}
|
|
FILE ${library_name}Targets.cmake
|
|
) |