-
Notifications
You must be signed in to change notification settings - Fork 777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1446 #2253
base: master
Are you sure you want to change the base?
Fix #1446 #2253
Conversation
This looks interesting, but I'm not familiar enough with Pkgconfig to judge whether this is a good approach. |
You seem to have started from the outdated https://github.com/dg0yt/vcpkg/blob/issue-template/ports/libarchive/pkgconfig-modules.patch. Some pc files can be missing on windows if not using vcpkg. |
I split out the autoconf part in #2268 so they can be reviewed separately. @dg0yt I thought I did work from the latest version? I skipped the other changes, such as more |
I don't know. I know that the reference you made points to an unrelated and old branch. And my comment even highlighted one of the issues of the old branch. |
Sorry, I failed to find the upper-case |
@dg0yt OK I put most of the things from https://github.com/microsoft/vcpkg/blob/master/ports/libarchive/fix-deps.patch in a second commit, so we can review carefully what goes where. See my comments below on things differing between https://github.com/microsoft/vcpkg/blob/master/ports/libarchive/fix-deps.patch and what I got that are worthy of further attention. |
LIST(APPEND ADDITIONAL_LIBS LibLZMA::LibLZMA) | ||
LIST(APPEND LIBARCHIVE_REQUIRES_PRIVATE liblzma) | ||
CMAKE_PUSH_CHECK_STATE() | ||
SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) | ||
SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) | ||
INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) | ||
LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the relationship between these two ADDITIONAL_LIBS
? @dg0yt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relationship is that vcpkg never uses the second ADDITIONAL_LIBS
. You omitted the third inserted line (which doesn't make sense here).
+elseif(0)
With this trick, the vcpkg patch is intentionally kept short.
For upstreaming the change, you wouldn't insert the code at the beginning but indeed update the code around the original ADDITIONAL_LIBS
line.
@@ -628,13 +631,16 @@ ENDIF(ENABLE_LZ4) | |||
IF(LZ4_FOUND) | |||
SET(HAVE_LIBLZ4 1) | |||
SET(HAVE_LZ4_H 1) | |||
SET(HAVE_LZ4HC_H 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems separate?
LIST(APPEND LIBARCHIVE_REQUIRES_PRIVATE liblz4) | ||
elseif(0) | ||
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables | ||
SET(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) | ||
CHECK_INCLUDE_FILES("lz4hc.h" HAVE_LZ4HC_H) | ||
CMAKE_POP_CHECK_STATE() # Restore the state of the variables | ||
INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIR}) | ||
LIST(APPEND ADDITIONAL_LIBS ${LZ4_LIBRARY}) | ||
LIST(APPEND LIBARCHIVE_REQUIRES_PRIVATE liblz4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does no pkg-config
in the FIND_PACKAGE
not found case make sense?
LIST(APPEND LIBARCHIVE_REQUIRES_PRIVATE libzstd) | ||
elseif(0) | ||
INCLUDE_DIRECTORIES(${ZSTD_INCLUDE_DIR}) | ||
LIST(APPEND ADDITIONAL_LIBS ${ZSTD_LIBRARY}) | ||
LIST(APPEND LIBARCHIVE_REQUIRES_PRIVATE libzstd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does no pkg-config
in the FIND_PACKAGE
not found case make sense?
@@ -977,7 +992,7 @@ main(int argc, char **argv) | |||
IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) | |||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) | |||
LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES}) | |||
LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) | |||
#LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REMOVE_DUPLICATES
has the potential to break static linking with "traditional linkers". Independent libs must come at the end of the list, but that command leaves only the first occurence.
In addition, it will break multi-config keywords (optimized
, debug
).
@@ -851,8 +867,7 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") | |||
FIND_PACKAGE(OpenSSL) | |||
IF(OPENSSL_FOUND) | |||
SET(HAVE_LIBCRYPTO 1) | |||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For building libarchive, OpenSSL::Crypto' will make CMake pass include dirs and link libs to the targets that link to it. So there is no reason to use both variables and targets. For exported CMake config, using targets implies using
find_dependency` (for static linkage).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot copy the vcpkg patch literally. It is for a certain controlled environment.
You really have to check package by package. And the libarchive must check how modern the systems are required to be when relying on system packages.
FIND_PACKAGE(ZSTD NAMES zstd CONFIG REQUIRED) | ||
elseif(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not suitable here.
User may not have zstd CMake config.
@@ -851,8 +867,7 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") | |||
FIND_PACKAGE(OpenSSL) | |||
IF(OPENSSL_FOUND) | |||
SET(HAVE_LIBCRYPTO 1) | |||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For building libarchive, OpenSSL::Crypto' will make CMake pass include dirs and link libs to the targets that link to it. So there is no reason to use both variables and targets. For exported CMake config, using targets implies using
find_dependency` (for static linkage).
@@ -977,7 +992,7 @@ main(int argc, char **argv) | |||
IF ("${IMPLEMENTATION}" MATCHES "^OPENSSL$" AND OPENSSL_FOUND) | |||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) | |||
LIST(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES}) | |||
LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) | |||
#LIST(REMOVE_DUPLICATES ADDITIONAL_LIBS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REMOVE_DUPLICATES
has the potential to break static linking with "traditional linkers". Independent libs must come at the end of the list, but that command leaves only the first occurence.
In addition, it will break multi-config keywords (optimized
, debug
).
Adapted from https://github.com/dg0yt/vcpkg/blob/issue-template/ports/libarchive/pkgconfig-modules.patch
Partially fixes #1446