summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostas Dizas <kdizas@gmail.com>2021-10-20 12:17:00 (GMT)
committerKostas Dizas <kdizas@gmail.com>2021-10-20 12:17:00 (GMT)
commitf9378137ed306ea71d1d9cd60e1acf7b8e57f0df (patch)
treeb623746560ba91883ae939754e33225cacd2d8bb
parente2009622dd19556d31de498b68d8e555b7261251 (diff)
downloadlz4-f9378137ed306ea71d1d9cd60e1acf7b8e57f0df.zip
lz4-f9378137ed306ea71d1d9cd60e1acf7b8e57f0df.tar.gz
lz4-f9378137ed306ea71d1d9cd60e1acf7b8e57f0df.tar.bz2
Create cmake package when installing
-rw-r--r--build/cmake/CMakeLists.txt31
-rw-r--r--build/cmake/lz4Config.cmake.in2
2 files changed, 33 insertions, 0 deletions
diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt
index 4b7b379..dacc213 100644
--- a/build/cmake/CMakeLists.txt
+++ b/build/cmake/CMakeLists.txt
@@ -103,6 +103,9 @@ option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static li
set(LZ4_LIBRARIES_BUILT)
if(BUILD_SHARED_LIBS)
add_library(lz4_shared SHARED ${LZ4_SOURCES})
+ target_include_directories(lz4_shared
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(lz4_shared PROPERTIES
OUTPUT_NAME lz4
SOVERSION "${LZ4_VERSION_MAJOR}"
@@ -119,6 +122,9 @@ if(BUILD_STATIC_LIBS)
set(STATIC_LIB_NAME lz4_static)
endif()
add_library(lz4_static STATIC ${LZ4_SOURCES})
+ target_include_directories(lz4_static
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(lz4_static PROPERTIES
OUTPUT_NAME ${STATIC_LIB_NAME}
POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
@@ -189,6 +195,7 @@ if(NOT LZ4_BUNDLED_MODE)
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS ${LZ4_LIBRARIES_BUILT}
+ EXPORT lz4Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
@@ -202,6 +209,30 @@ if(NOT LZ4_BUNDLED_MODE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ include(CMakePackageConfigHelpers)
+ write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake"
+ VERSION ${LZ4_VERSION_STRING}
+ COMPATIBILITY SameMajorVersion)
+
+ set(LZ4_PKG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/cmake/lz4")
+ configure_package_config_file(
+ "${CMAKE_CURRENT_LIST_DIR}/lz4Config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake"
+ INSTALL_DESTINATION ${LZ4_PKG_INSTALLDIR})
+ export(EXPORT lz4Targets
+ FILE ${CMAKE_CURRENT_BINARY_DIR}/lz4Targets.cmake
+ NAMESPACE LZ4::)
+
+ install(EXPORT lz4Targets
+ FILE lz4Targets.cmake
+ NAMESPACE LZ4::
+ DESTINATION ${LZ4_PKG_INSTALLDIR})
+ install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake
+ DESTINATION ${LZ4_PKG_INSTALLDIR})
+
# install lz4cat and unlz4 symlinks on *nix
if(UNIX AND LZ4_BUILD_CLI)
install(CODE "
diff --git a/build/cmake/lz4Config.cmake.in b/build/cmake/lz4Config.cmake.in
new file mode 100644
index 0000000..e9c9473
--- /dev/null
+++ b/build/cmake/lz4Config.cmake.in
@@ -0,0 +1,2 @@
+@PACKAGE_INIT@
+include( "${CMAKE_CURRENT_LIST_DIR}/lz4Targets.cmake" ) \ No newline at end of file