Generate a better CMake Package Config file
This commit is contained in:
parent
5fcbc484c8
commit
c22551b903
@ -158,3 +158,39 @@ add_custom_target(clean-all
|
||||
COMMAND ${CMAKE_BUILD_TOOL} clean
|
||||
COMMAND rm -rf ${CMAKE_BINARY_DIR}/
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Generate Package Config files
|
||||
#
|
||||
# This section is based on the boiler plate code from:
|
||||
# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
|
||||
#-----------------------------------------------------------------------------
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
VERSION ${zstd_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# A Package Config file that works from the build directory
|
||||
export(EXPORT zstdExports
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/zstdTargets.cmake"
|
||||
NAMESPACE zstd::
|
||||
)
|
||||
configure_file(zstdConfig.cmake
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
# A Package Config file that works from the installation directory
|
||||
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zstd)
|
||||
install(EXPORT zstdExports
|
||||
FILE zstdTargets.cmake
|
||||
NAMESPACE zstd::
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
install(FILES
|
||||
zstdConfig.cmake
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
|
@ -169,21 +169,6 @@ if (ZSTD_BUILD_STATIC)
|
||||
)
|
||||
endif ()
|
||||
|
||||
# export targets + find config
|
||||
configure_file(
|
||||
"config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/zstd"
|
||||
)
|
||||
install(EXPORT zstdExports
|
||||
NAMESPACE zstd::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/zstd"
|
||||
)
|
||||
|
||||
# uninstall target
|
||||
if (NOT TARGET uninstall)
|
||||
configure_file(
|
||||
|
@ -1,7 +0,0 @@
|
||||
include(FindPackageHandleStandardArgs)
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
|
||||
find_package_handle_standard_args(zstd CONFIG_MODE)
|
||||
|
||||
if(NOT TARGET zstd::libzstd_shared)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/zstdExports.cmake")
|
||||
endif()
|
1
build/cmake/zstdConfig.cmake
Normal file
1
build/cmake/zstdConfig.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/zstdTargets.cmake")
|
Loading…
Reference in New Issue
Block a user