From 3b22d3c5b0d4f75b94a41c8842a1dc3b5067ebcd Mon Sep 17 00:00:00 2001 From: Ken Matsui <26405363+ken-matsui@users.noreply.github.com> Date: Sun, 18 Dec 2022 22:59:23 -0800 Subject: [PATCH] Fix the way to find libarchive on macOS (#730) --- cmake/AddLibArchive.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/AddLibArchive.cmake b/cmake/AddLibArchive.cmake index 56942f4bc..a405b8d5d 100644 --- a/cmake/AddLibArchive.cmake +++ b/cmake/AddLibArchive.cmake @@ -5,9 +5,18 @@ list(APPEND CMAKE_MESSAGE_INDENT " ") include(cmake/CPM.cmake) -if (APPLE) - # To support finding LibArchive on macOS - set(LibArchive_INCLUDE_DIR "${POAC_HOMEBREW_ROOT_PATH}/libarchive/include") +if (DEFINED LibArchive_INCLUDE_DIR) + message(STATUS "LibArchive_INCLUDE_DIR has been set manually: ${LibArchive_INCLUDE_DIR}") +else () + set(LIBARCHIVE_INCLUDE_DIR_TMP "${POAC_HOMEBREW_ROOT_PATH}/libarchive/include") + if (APPLE AND EXISTS "${LIBARCHIVE_INCLUDE_DIR_TMP}/archive.h") + # To support finding LibArchive on macOS + set(LibArchive_INCLUDE_DIR ${LIBARCHIVE_INCLUDE_DIR_TMP}) + message(STATUS "LibArchive_INCLUDE_DIR has been set automatically: ${LibArchive_INCLUDE_DIR}") + else () + message(STATUS "LibArchive_INCLUDE_DIR could not be set automatically") + endif () + unset(LIBARCHIVE_INCLUDE_DIR_TMP) endif () set(CMAKE_PROJECT_libarchive_INCLUDE_BEFORE "${CMAKE_SOURCE_DIR}/cmake/LibArchivePoliciesFix.cmake")