Skip to content

Commit

Permalink
libclamav: resolve macOS linker issue with new LHA/LZH feature
Browse files Browse the repository at this point in the history
The delharc crate used to add LZH archive support appears to add
a dependency on macOS CoreFoundation library.

The error is:

[ 78%] Linking C shared library libclamav.dylib
Undefined symbols for architecture x86_64:
  "_CFRelease", referenced from:
      iana_time_zone::platform::get_timezone_inner::hc7da204717a39974 in libclamav_rust.a(iana_time_zone-bc4762a47da73d72.iana_time_zone.1863eb20d202562a-cgu.0.rcgu.o)
...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libclamav/libclamav.12.0.2.dylib] Error 1

We already link with CoreFoundation for libfreshclam and clamsubmit, so
this commit extends that to libclamav as well.
  • Loading branch information
micahsnyder committed Mar 27, 2024
1 parent 4bb684d commit d52242e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,21 +548,21 @@ if(${bytecodeRuntime} STREQUAL "llvm")
endif()
endif()

if(APPLE)
find_library(APPLE_CORE_FOUNDATION CoreFoundation)
if (NOT APPLE_CORE_FOUNDATION)
message(FATAL_ERROR "Apple CoreFoundation framework not found")
endif()
find_library(APPLE_SECURITY Security)
if (NOT APPLE_SECURITY)
message(FATAL_ERROR "Apple Security framework not found")
endif()
endif()

# libfreshclam & application dependencies
if(NOT ENABLE_LIBCLAMAV_ONLY)
find_package(CURL REQUIRED)

if(APPLE)
find_library(APPLE_CORE_FOUNDATION CoreFoundation)
if (NOT APPLE_CORE_FOUNDATION)
message(FATAL_ERROR "Apple CoreFoundation framework not found")
endif()
find_library(APPLE_SECURITY Security)
if (NOT APPLE_SECURITY)
message(FATAL_ERROR "Apple Security framework not found")
endif()
endif()

if(ENABLE_APP)
find_package(CURSES REQUIRED)

Expand Down
15 changes: 15 additions & 0 deletions libclamav/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ if(ENABLE_SHARED_LIB)
${CMAKE_DL_LIBS}
m )
endif()

if(APPLE)
target_link_libraries( clamav
PUBLIC
${APPLE_CORE_FOUNDATION} )
endif()

set_target_properties( clamav PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LIBCLAMAV_VERSION} SOVERSION ${LIBCLAMAV_SOVERSION} )
Expand Down Expand Up @@ -549,6 +556,7 @@ if(ENABLE_STATIC_LIB)
if (ENABLE_UNRAR)
target_link_libraries( clamav_static PUBLIC ClamAV::libunrar_iface_static ClamAV::libunrar_iface_iface)
endif()

if (WIN32)
target_link_libraries( clamav_static
PUBLIC
Expand All @@ -563,6 +571,13 @@ if(ENABLE_STATIC_LIB)
${CMAKE_DL_LIBS}
m )
endif()

if(APPLE)
target_link_libraries( clamav_static
PUBLIC
${APPLE_CORE_FOUNDATION} )
endif()

set_target_properties( clamav_static PROPERTIES
ARCHIVE_OUTPUT_NAME clamav_static
COMPILE_FLAGS "${WARNCFLAGS}"
Expand Down

0 comments on commit d52242e

Please sign in to comment.