Move libarchive build code and use mirrors

This commit is contained in:
Georg Hagen
2024-06-02 20:51:10 +02:00
parent f9909277cb
commit e3e8b3d2d8
6 changed files with 134 additions and 135 deletions

View File

@@ -18,45 +18,5 @@ add_subdirectory(imgui)
add_subdirectory(tracy)
add_subdirectory(libstud-uuid)
add_subdirectory(rapidyaml)
add_subdirectory(libarchive)
add_subdirectory(libjpeg-turbo)
#TODO move into a different file
find_package(LibArchive QUIET)
if (NOT DEFINED LibArchive_LIBRARIES)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps)
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DTOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/libarchive
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps
)
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")
set(USING_SYSTEM_LIBARCHIVE ON PARENT_SCOPE)
endif ()
function(LinkLibArchive TARGET)
find_package(LibArchive REQUIRED)
set(ZLIB_USE_STATIC_LIBS ON)
find_package(ZLIB REQUIRED)
find_package(LZ4 QUIET)
find_package(zstd QUIET)
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})
if (BZIP2_LIBRARIES)
target_link_libraries(${TARGET} PRIVATE ${BZIP2_LIBRARIES})
endif()
if (LIBLZMA_LIBRARIES)
target_link_libraries(${TARGET} PRIVATE ${LIBLZMA_LIBRARIES})
endif()
endfunction()