From 36307e0b5bc04277891557746a720e02d4b4b6f5 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Tue, 28 May 2024 00:02:00 +0200 Subject: [PATCH] Fail build if libarchive build failed and update linking --- 3rdParty/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index 8a38b18..e819116 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -30,7 +30,12 @@ if (NOT LibArchive_FOUND) ) execute_process( COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps + RESULT_VARIABLE build_result ) + if (NOT ${build_result} EQUAL "0") + message(FATAL_ERROR "Failed to build lib archive!") + endif() + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL) else () message("Using system LibArchive") @@ -46,5 +51,11 @@ function(LinkLibArchive TARGET) find_package(BZip2 QUIET) find_package(LibLZMA QUIET) target_include_directories(${TARGET} PRIVATE ${LibArchive_INCLUDE_DIR}) - target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES} ${LIBLZMA_LIBRARIES} ${BZIP2_LIBRARIES}) + target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES}) + if (BZIP2_LIBRARIES) + target_link_libraries(${TARGET} PRIVATE ${BZIP2_LIBRARIES}) + endif() + if (LIBLZMA_LIBRARIES) + target_link_libraries(${TARGET} PRIVATE ${LIBLZMA_LIBRARIES}) + endif() endfunction() \ No newline at end of file