[libpff] Initial port. (#6458)

* [libpff] Initial port.

* [libpff] Add unofficial CMake find_package() integration support
This commit is contained in:
Vitaliy Didik 2019-05-16 02:21:05 +03:00 committed by Victor Romero
parent 88b882057a
commit 0e417f773d
4 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,81 @@
cmake_minimum_required(VERSION 3.12)
project(libpff C)
find_package(zlib REQUIRED)
if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_DEPRECATE)
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
endif()
add_compile_definitions(HAVE_LOCAL_LIBCERROR)
add_compile_definitions(HAVE_LOCAL_LIBCTHREADS)
add_compile_definitions(HAVE_LOCAL_LIBCDATA)
add_compile_definitions(HAVE_LOCAL_LIBCLOCALE)
add_compile_definitions(HAVE_LOCAL_LIBCNOTIFY)
add_compile_definitions(HAVE_LOCAL_LIBCSPLIT)
add_compile_definitions(HAVE_LOCAL_LIBCFILE)
add_compile_definitions(HAVE_LOCAL_LIBCPATH)
add_compile_definitions(HAVE_LOCAL_LIBUNA)
add_compile_definitions(HAVE_LOCAL_LIBBFIO)
add_compile_definitions(HAVE_LOCAL_LIBFCACHE)
add_compile_definitions(HAVE_LOCAL_LIBFDATA)
add_compile_definitions(HAVE_LOCAL_LIBFDATETIME)
add_compile_definitions(HAVE_LOCAL_LIBFGUID)
add_compile_definitions(HAVE_LOCAL_LIBFWNT)
add_compile_definitions(HAVE_LOCAL_LIBFMAPI)
add_compile_definitions(HAVE_LOCAL_LIBFVALUE)
add_compile_definitions(ZLIB_DLL)
add_compile_definitions(LIBPFF_DLL_EXPORT)
if(MSVC)
set(LIB_RC libpff/libpff.rc)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Add CMake find_package() integration
set(PROJECT_TARGET_NAME "unofficial-${PROJECT_NAME}")
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(PROJECT_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_TARGET_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_TARGET_NAME}Targets")
set(NAMESPACE "unofficial-libpff::")
# Source files
file(GLOB LIB_SRC lib*/*.c)
# Headers
file(GLOB LIB_INST_HEADERS include/libpff/*.h)
add_library(${PROJECT_NAME} ${LIB_SRC} ${LIB_RC})
target_include_directories(${PROJECT_NAME} PRIVATE ./include ./common)
target_include_directories(${PROJECT_NAME} PRIVATE ./libbfio ./libcdata ./libcerror ./libcfile ./libclocale ./libcnotify)
target_include_directories(${PROJECT_NAME} PRIVATE ./libcpath ./libcsplit ./libcthreads ./libfcache ./libfdata ./libfdatetime)
target_include_directories(${PROJECT_NAME} PRIVATE ./libfguid ./libfmapi ./libfvalue ./libfwnt ./libuna)
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
install(TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include)
install(FILES ${LIB_INST_HEADERS} DESTINATION include/libpff)
install(FILES include/libpff.h DESTINATION include)
# Generate and install unofficial-libpffConfig.cmake
configure_package_config_file("Config.cmake.in" "${PROJECT_CONFIG}" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}")
install(FILES "${PROJECT_CONFIG}" DESTINATION "${CONFIG_INSTALL_DIR}")
# Generate and install unofficial-libpffTargets*.cmake
install(EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE ${NAMESPACE}
DESTINATION "${CONFIG_INSTALL_DIR}")

4
ports/libpff/CONTROL Normal file
View File

@ -0,0 +1,4 @@
Source: libpff
Version: 2018-07-14
Build-Depends: zlib
Description: Library and tools to access the Personal Folder File (PFF) and the Offline Folder File (OFF) format.

View File

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")

View File

@ -0,0 +1,39 @@
include(vcpkg_common_functions)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
set(LIB_VERSION 20180714)
set(LIB_FILENAME libpff-experimental-${LIB_VERSION}.tar.gz)
# Release distribution file contains configured sources, while the source code in the repository does not.
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/libyal/libpff/releases/download/${LIB_VERSION}/${LIB_FILENAME}"
FILENAME "${LIB_FILENAME}"
SHA512 7207ba87607ea2fd4609a081c2f4b061344a783e188605e88df99fd473f2a8da1269b065e57b054f4622888d40aa8f2b8272dc4748334ddfe358b28d443d6ad1
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REF ${LIB_VERSION}
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in" DESTINATION "${SOURCE_PATH}")
vcpkg_configure_cmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/libpff" TARGET_PATH "share/unofficial-libpff")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
# License and man
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libpff" RENAME copyright)
vcpkg_copy_pdbs()