Skip to content

Commit

Permalink
build(cmake): find homebrew installed LibArchive
Browse files Browse the repository at this point in the history
  • Loading branch information
zchrissirhcz committed Apr 1, 2024
1 parent ffdf387 commit 2dd0de9
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ else()
target_link_libraries(Core Qt5::WebEngine)
endif()

# 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)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(LibArchive_INCLUDE_DIR "/usr/local/opt/libarchive/include")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(LibArchive_INCLUDE_DIR "/opt/homebrew/opt/libarchive/include")
endif()
find_package(LibArchive)
if(NOT LibArchive_FOUND)
find_file(LibArchive_INCLUDE_DIR archive.h
PATHS /opt/homebrew/opt/libarchive/include /usr/local/opt/libarchive/include
PATH_SUFFIXES libarchive
)
find_library(LibArchive NAMES archive REQUIRED)
endif()

find_package(LibArchive REQUIRED)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17.0)
target_link_libraries(Core LibArchive::LibArchive)
else()
Expand Down

0 comments on commit 2dd0de9

Please sign in to comment.