Skip to content

Commit

Permalink
build(cmake): find libarchive from brew on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
zchrissirhcz committed Apr 1, 2024
1 parent db781ed commit c5a4e58
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,24 @@ else()
target_link_libraries(Core Qt5::WebEngine)
endif()

find_package(LibArchive REQUIRED)

# Set LibArchive_INCLUDE_DIR on macOS when LibArchive is installed with Homebrew.
# See https://github.com/Homebrew/legacy-homebrew/issues/21415.
if(APPLE AND NOT LibArchive_INCLUDE_DIR)
set(LibArchive_INCLUDE_DIR "/usr/local/opt/libarchive/include")
find_package(LibArchive QUIET)
if(NOT LibArchive_FOUND)
find_path(LibArchive_INCLUDE_DIRS archive.h
PATHS /opt/homebrew/opt/libarchive/include /usr/local/opt/libarchive/include
REQUIRED
)
message(STATUS "LibArchive_INCLUDE_DIRS: ${LibArchive_INCLUDE_DIRS}")

find_library(LibArchive_LIBRARIES
NAMES archive libarchive
PATHS /opt/homebrew/opt/libarchive/lib /usr/local/opt/libarchive/lib
REQUIRED
NO_DEFAULT_PATH
)
message(STATUS "LibArchive_LIBRARIES: ${LibArchive_LIBRARIES}")
endif()

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17.0)
if((CMAKE_VERSION VERSION_GREATER_EQUAL 3.17.0) AND (TARGET LibArchive::LibArchive))
target_link_libraries(Core LibArchive::LibArchive)
else()
include_directories(${LibArchive_INCLUDE_DIRS})
Expand Down

0 comments on commit c5a4e58

Please sign in to comment.