Skip to content

Commit f09d736

Browse files
committed
[acquire/CMakeLists.txt] Fix bug (typo) causing linker errors on curl target ; [acquire/tests/test_checksum.h] Have different checksum for Windows encoding vs non-Windows (UTF-16 with BOM vs UTF-8? - or ASCII?)
1 parent 920ed45 commit f09d736

File tree

8 files changed

+29
-16
lines changed

8 files changed

+29
-16
lines changed

acquire/CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ else ()
160160
set(NETWORK_LIB "acquire_wininet.h")
161161
set(NETWORK_LIB_LINK "wininet")
162162
elseif (LIBACQUIRE_USE_LIBCURL)
163-
set(ARCHIVE_LIB "acquire_libcurl.h")
163+
set(NETWORK_LIB "acquire_libcurl.h")
164164
set(NETWORK_LIB_LINK CURL::libcurl)
165165
elseif (LIBACQUIRE_USE_OPENBSD_FTP)
166166
set(NETWORK_LIB "acquire_openbsd_ftp.h")
@@ -173,6 +173,9 @@ else ()
173173
message(STATUS "header_impls = ${header_impls}")
174174

175175
foreach (header_file IN LISTS header_impls)
176+
if (header_file STREQUAL "")
177+
continue()
178+
endif (header_file STREQUAL "")
176179
get_filename_component(name_no_ext "${header_file}" NAME_WE)
177180
set(gen_header_file "${CMAKE_BINARY_DIR}/gen/gen_${name_no_ext}.h")
178181
set(gen_source_file "${CMAKE_BINARY_DIR}/gen/gen_${name_no_ext}.c")
@@ -221,13 +224,13 @@ else ()
221224
# Checksums #
222225
#############
223226
if (src MATCHES "/gen_acquire_checksums.c$")
224-
# if (NOT ("LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL" IN_LIST impls))
225-
set_source_files_properties(
226-
${src} PROPERTIES
227-
COMPILE_DEFINITIONS "LIBACQUIRE_IMPLEMENTATION=1"
228-
)
229-
# list(APPEND impls "LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL")
230-
# endif (NOT ("LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL" IN_LIST impls))
227+
if (NOT ("LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL" IN_LIST impls))
228+
set_source_files_properties(
229+
${src} PROPERTIES
230+
COMPILE_DEFINITIONS "LIBACQUIRE_IMPLEMENTATION=1;LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL=1"
231+
)
232+
list(APPEND impls "LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL")
233+
endif (NOT ("LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL" IN_LIST impls))
231234
elseif (src MATCHES "/gen_acquire_crc32c.c$")
232235
if (NOT ("LIBACQUIRE_ACQUIRE_CHECKSUMS_IMPL" IN_LIST impls))
233236
set_source_files_properties(

acquire/acquire_libcurl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ extern "C" {
3131

3232
#include <curl/curl.h>
3333

34+
#ifdef LIBACQUIRE_DOWNLOAD_DIR_IMPL
3435
const char *get_download_dir(void) { return ".downloads"; }
36+
#endif /* LIBACQUIRE_DOWNLOAD_DIR_IMPL */
3537

3638
int download_to_stdout(const char *url, const char *checksum,
3739
const char *target_location, bool follow, size_t retry) {

acquire/acquire_wincompressapi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ int extract_archive(enum Archive archive, const char *archive_filepath,
283283
#endif /* __cplusplus */
284284

285285
#endif /* defined(LIBACQUIRE_USE_WINCOMPRESSAPI) && \
286-
LIBACQUIRE_USE_WINCOMPRESSAPI && defined(LIBACQUIRE_IMPLEMENTATION) \
287-
&& defined(LIBACQUIRE_EXTRACT_IMPL) && (defined(_WIN32) || \
286+
LIBACQUIRE_USE_WINCOMPRESSAPI && defined(LIBACQUIRE_IMPLEMENTATION) \
287+
&& defined(LIBACQUIRE_EXTRACT_IMPL) && (defined(_WIN32) || \
288288
defined(__WIN32__) || defined(_MSC_VER) || defined(__MINGW32__)) */
289289

290290
#endif /* !LIBACQUIRE_ACQUIRE_WINCOMPRESSAPI_H */

acquire/acquire_wininet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343

4444
#ifdef LIBACQUIRE_DOWNLOAD_DIR_IMPL
4545
const char *get_download_dir(void) { return TMPDIR "//.downloads"; }
46-
#endif /* !LIBACQUIRE_DOWNLOAD_DIR_IMPL */
46+
#endif /* LIBACQUIRE_DOWNLOAD_DIR_IMPL */
4747

4848
#ifdef LIBACQUIRE_DOWNLOAD_IMPL
4949
int download(const char *url, enum Checksum checksum, const char *hash,

acquire/tests/test_checksum.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ TEST test_crc32c_small_temp_file(void) {
248248
char *const tmpfile = create_temp_file_with_content(content);
249249
/* Precomputed CRC32C checksum of "hello, world\n" is: 0xb8ca70d7 (lowercase
250250
* hex) */
251+
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
251252
const bool result = crc32c(tmpfile, "8f00b46e");
253+
#else
254+
const bool result = crc32c(tmpfile, "f4247453");
255+
#endif /* defined(_MSC_VER) && !defined(__INTEL_COMPILER) */
252256
/* f4247453 */
253257
ASSERT(tmpfile != NULL);
254258
safe_remove_file(tmpfile);
@@ -260,9 +264,13 @@ TEST test_sha256_small_temp_file(void) {
260264
const char *content = "hello, world\n";
261265
char *const tmpfile = create_temp_file_with_content(content);
262266
/* Precomputed SHA256 of "hello, world\n" */
267+
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
263268
const char *const expected_sha256 =
264269
"bbbe3b671e853dfe30a0e60594366f24f02f31ea24ff4651743fd60c73cd6822";
265-
/* 853ff93762a06ddbf722c4ebe9ddd66d8f63ddaea97f521c3ecc20da7c976020 */
270+
#else
271+
const char *const expected_sha256 =
272+
"853ff93762a06ddbf722c4ebe9ddd66d8f63ddaea97f521c3ecc20da7c976020";
273+
#endif /* defined(_MSC_VER) && !defined(__INTEL_COMPILER) */
266274
const bool result = sha256(tmpfile, expected_sha256);
267275
ASSERT(tmpfile != NULL);
268276
safe_remove_file(tmpfile);

cmake/FindCurlCustom.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function(get_curl LINK_LIBRARIES)
2121
if (VCPKG_TOOLCHAIN) # Overly specific, should be same for conan, Buckaroo, Hunter, &etc.
2222
find_package(CURL CONFIG QUIET)
2323
if (CURL_FOUND)
24-
set("${LINK_LIBRARIES}" "CURL::libcurl" PARENT_SCOPE)
24+
set("${LINK_LIBRARIES}" CURL::libcurl PARENT_SCOPE)
2525
return()
2626
endif (CURL_FOUND)
2727
endif (VCPKG_TOOLCHAIN)
@@ -64,7 +64,7 @@ function(get_curl LINK_LIBRARIES)
6464
INTERFACE_LINK_LIBRARIES "${CURL_STATIC_LIBRARIES}"
6565
IMPORTED_LINK_INTERFACE_LANGUAGES C
6666
IMPORTED_LOCATION "${CURL_LINK_LIBRARIES}")
67-
target_link_libraries(CURL::libcurl INTERFACE "${CURL_STATIC_LIBRARY_DIRS}")
67+
# target_link_libraries(CURL::libcurl INTERFACE "${CURL_STATIC_LIBRARY_DIRS}")
6868
else ()
6969
add_library(CURL::libcurl SHARED IMPORTED)
7070
set_target_properties(CURL::libcurl PROPERTIES

cmake/FindExtractLib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function(set_extract_lib)
1818
list(APPEND _Header_Files "acquire_zlib.h")
1919
else ()
2020
set(LIBACQUIRE_USE_MINIZ 1 PARENT_SCOPE)
21-
set(EXTRACT_LIB "MINIZ" PARENT_SCOPE)
21+
set(EXTRACT_LIB "kubazip::kubazip" PARENT_SCOPE)
2222
list(APPEND _Header_Files "acquire_miniz.h")
2323
endif ()
2424
endfunction(set_extract_lib)

cmake/FindLibAcquire.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function(set_networking_lib HTTPS_LIBRARY)
3131
endif ()
3232

3333
if (DEFINED LIBACQUIRE_USE_LIBCURL AND DEFINED CURL_LINK_LIBRARIES)
34-
set(HTTPS_LIBRARY "${CURL_LINK_LIBRARIES}" PARENT_SCOPE)
34+
set(HTTPS_LIBRARY "CURL::libcurl" PARENT_SCOPE)
3535
elseif (DEFINED LIBACQUIRE_USE_WININET)
3636
set(HTTPS_LIBRARY "wininet" PARENT_SCOPE)
3737
if (NOT DEFINED LIBACQUIRE_USE_OPENSSL)

0 commit comments

Comments
 (0)