3 @@ -448,7 +448,7 @@ endif()
5 # libclamav feature dependencies
7 - find_package(Iconv REQUIRED)
9 # Set variable required by libclamav to use iconv
12 --- a/libclamav/CMakeLists.txt
13 +++ b/libclamav/CMakeLists.txt
14 @@ -536,10 +536,39 @@ if(ENABLE_SHARED_LIB)
19 + if(NOT Iconv_IS_BUILT_IN)
20 + target_link_libraries(clamav PRIVATE Iconv::Iconv)
21 + set(CMAKE_REQUIRED_LIBRARIES "Iconv::Iconv")
24 + # Sometime the build environment is not setup
25 + # in a way CMake can find Iconv on its own by default.
26 + # But if we simply link against iconv (-liconv), the build may succeed
27 + # due to other compiler/link flags.
28 + set(CMAKE_REQUIRED_LIBRARIES "iconv")
29 + check_c_source_compiles("
36 + ic = iconv_open(\"to\", \"from\");
37 + iconv(ic, &a, &i, &b, &j);
41 + Iconv_EXPLICITLY_AT_ENV)
42 + if(Iconv_EXPLICITLY_AT_ENV)
43 + target_link_libraries(clamav PRIVATE iconv)
45 + message(FATAL_ERROR "Iconv is not found, make sure to provide it in the build environment")
48 target_link_libraries( clamav
55 @@ -556,8 +585,6 @@ if(ENABLE_SHARED_LIB)
58 set_target_properties( clamav PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
60 - target_link_libraries( clamav PUBLIC Iconv::Iconv )
63 install( TARGETS clamav DESTINATION . COMPONENT libraries )