Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions ports/libqcow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.12)

project(libqcow C)

find_package(OpenSSL)
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_LIBCAES)
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(ZLIB_DLL)

if(UNIX)
configure_file(common/config.h.in common/config.h)
add_compile_definitions(HAVE_CONFIG_H)
add_compile_definitions(LOCALEDIR="/usr/share/locale")
endif()

if(MSVC)
add_compile_definitions(LIBQCOW_DLL_EXPORT)
set(LIB_RC libqcow/libqcow.rc)
endif()


include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Add CMake find_package() integration
set(PROJECT_TARGET_NAME "${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 "libqcow::")

# Source files
file(GLOB LIB_SRC lib*/*.c)

# Headers
file(GLOB LIB_INST_HEADERS include/libqcow/*.h)

add_library(${PROJECT_NAME} ${LIB_SRC} ${LIB_RC})

target_include_directories(${PROJECT_NAME} PRIVATE ./include ./common)
target_include_directories(${PROJECT_NAME} PRIVATE ./libbfio ./libcaes ./libcdata ./libcerror ./libcfile ./libclocale)
target_include_directories(${PROJECT_NAME} PRIVATE ./libcnotify ./libcpath ./libcsplit ./libcthreads)
target_include_directories(${PROJECT_NAME} PRIVATE ./libfcache ./libfdata ./libuna)

target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB OpenSSL::Crypto)

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/libqcow)
install(FILES include/libqcow.h DESTINATION include)


# Generate and install libqcowConfig.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 libqcowTargets*.cmake
install(EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE ${NAMESPACE}
DESTINATION "${CONFIG_INSTALL_DIR}")
5 changes: 5 additions & 0 deletions ports/libqcow/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Source: libqcow
Version: 2018-12-27
Homepage: https://github.com/libyal/libqcow
Build-Depends: openssl,zlib
Description: Library and tools to access the QEMU Copy-On-Write (QCOW) image format.
4 changes: 4 additions & 0 deletions ports/libqcow/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
35 changes: 35 additions & 0 deletions ports/libqcow/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)

set(LIB_VERSION 20191221)
set(LIB_FILENAME libqcow-alpha-${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/libqcow/releases/download/${LIB_VERSION}/${LIB_FILENAME}"
FILENAME "${LIB_FILENAME}"
SHA512 de0c5cfad84bbccc9a4144b108c7e022a98d130e829385e69ff00a8750709c9de814410eebfa1c0fc89051cf8f596d87b9bbc8228d99efd8be1c3efdc2b52730
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
REF ${LIB_VERSION}
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you usevcpkg_from_github() to replace vcpkg_download_distfile and vcpkg_extract_source_archive_ex() functions?
Also, I noticed that there is another latest release version 20191221.
So would you like to update this to the latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NancyLi1013 Unfortunately we need the use releases published at https://github.com/libyal/libqcow/releases since they contain pre-configured files requires to build libqcow on Windows. Although it should be theoretically possible to do that step ourselves, I haven't figured out a sane and easy way to do so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you don't understand my sense correctly.

vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH 
    REPO libyal/libqcow
    REF  20191221
    SHA512 de0c5cfad84bbccc9a4144b108c7e022a98d130e829385e69ff00a8750709c9de814410eebfa1c0fc89051cf8f596d87b9bbc8228d99efd8be1c3efdc2b52730
)

This can use the same version as that you provided above.
So I don't know why we cannot update it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NancyLi1013 The code you provided downloads the repo as a .zip, not the release that is published here: https://github.com/libyal/libvmdk/releases

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should have the same function. Please refer to this doc.

Copy link
Contributor

@VelocityRa VelocityRa Apr 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I did see the doc and I tried using your code.
They do not have the same function, different files are downloaded.

Nowhere in vcpkg_from_github.cmake is /relases/ mentioned (which is what our URL above contains).

It downloads the source tree as-is (search for /archive/ in the code) instead of the published release that the author manually published, which in this case is different than the source tree.

See the releases's files for an example (using libvmdk here, but same for libqcow):

image

We are interested in the first file, not the third one which vcpkg_from_github downloads (the /archive/ one).

Edit: Same case for

# Don't change to vcpkg_from_github! The sources in the git repository (archives) are missing some files that are distributed inside releases.
# More info: https://github.com/nigels-com/glew/issues/31 and https://github.com/nigels-com/glew/issues/13
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/nigels-com/glew/releases/download/glew-2.1.0/glew-2.1.0.tgz"
FILENAME "glew-2.1.0.tgz"
SHA512 9a9b4d81482ccaac4b476c34ed537585ae754a82ebb51c3efa16d953c25cc3931be46ed2e49e79c730cd8afc6a1b78c97d52cd714044a339c3bc29734cd4d2ab
)

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/libqcow" TARGET_PATH "share/libqcow")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

# License and man
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

vcpkg_copy_pdbs()