2016-12-30 20:31:33 +08:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2017-08-19 02:05:55 +08:00
|
|
|
project(lz4 C)
|
2016-12-30 20:31:33 +08:00
|
|
|
|
2020-04-17 04:42:29 +08:00
|
|
|
if(MSVC AND BUILD_SHARED_LIBS)
|
2016-12-30 20:31:33 +08:00
|
|
|
add_definitions(-DLZ4_DLL_EXPORT)
|
|
|
|
endif()
|
|
|
|
add_definitions(-DXXH_NAMESPACE=LZ4_)
|
|
|
|
|
2019-05-19 13:58:03 +08:00
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix")
|
|
|
|
set(INSTALL_BIN_DIR "bin" CACHE PATH "Path where exe and dll will be installed")
|
|
|
|
set(INSTALL_LIB_DIR "lib" CACHE PATH "Path where lib will be installed")
|
|
|
|
set(INSTALL_INCLUDE_DIR "include" CACHE PATH "Path where headers will be installed")
|
|
|
|
set(INSTALL_CMAKE_DIR "share/lz4" CACHE PATH "Path where cmake configs will be installed")
|
|
|
|
|
|
|
|
file(GLOB LZ4_HEADERS lib/*.h)
|
|
|
|
|
2016-12-30 20:31:33 +08:00
|
|
|
add_library(lz4
|
2019-05-19 13:58:03 +08:00
|
|
|
${LZ4_HEADERS}
|
2016-12-30 20:31:33 +08:00
|
|
|
lib/lz4.c
|
|
|
|
lib/lz4frame.c
|
|
|
|
lib/lz4hc.c
|
2019-05-19 13:58:03 +08:00
|
|
|
lib/xxhash.c
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(lz4 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/lib> $<INSTALL_INTERFACE:include>)
|
|
|
|
set_target_properties(lz4 PROPERTIES PUBLIC_HEADER ${LZ4_HEADERS})
|
2016-12-30 20:31:33 +08:00
|
|
|
|
|
|
|
install(TARGETS lz4
|
2019-05-19 13:58:03 +08:00
|
|
|
EXPORT lz4Config
|
|
|
|
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
|
|
|
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
|
|
|
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
|
|
|
|
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}"
|
|
|
|
PRIVATE_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}"
|
|
|
|
COMPONENT dev
|
|
|
|
)
|
|
|
|
|
|
|
|
FILE(GLOB lz4h "${CMAKE_CURRENT_LIST_DIR}/lib/*.h")
|
2019-06-06 02:15:11 +08:00
|
|
|
list(REMOVE_ITEM lz4h "${CMAKE_CURRENT_LIST_DIR}/lib/xxhash.h")
|
2019-05-19 13:58:03 +08:00
|
|
|
INSTALL(FILES ${lz4h} DESTINATION "${INSTALL_INCLUDE_DIR}")
|
|
|
|
|
|
|
|
install(EXPORT lz4Config
|
2020-05-12 04:39:50 +08:00
|
|
|
FILE lz4-config.cmake
|
2019-05-19 13:58:03 +08:00
|
|
|
NAMESPACE lz4::
|
|
|
|
DESTINATION "${INSTALL_CMAKE_DIR}"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Export the package for use from the build-tree (this registers the build-tree with a global CMake-registry)
|
|
|
|
export(PACKAGE lz4)
|