Fail build if libarchive build failed and update linking

This commit is contained in:
Georg Hagen
2024-05-28 00:02:00 +02:00
parent 10f91ca464
commit 36307e0b5b

View File

@@ -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()