CMake: Fix Windows build issue w/ conflicting libraries

At install, the CMake build may fail if it detects the same library
dependency in two locations. This happened for us with the following
error:

  CMake Error at libfreshclam/cmake_install.cmake:157 (file):
    file Multiple conflicting paths found for libcrypto-3-x64.dll:

      C:/Users/clamav_jenkins_svc.TALOS/clam_dependencies/x64/lib/libcrypto-3-x64.dll
      C:/WINDOWS/system32/libcrypto-3-x64.dll
      C:\WINDOWS\system32/libcrypto-3-x64.dll
  Call Stack (most recent call first):
    cmake_install.cmake:96 (include)

This happens when system provided DLL names match exactly with the ones
we provide. ClamAV woudld't prefer that DLL at load time, because it
looks in the EXE directory first. But it does confuse the `file()`
command used to locate build dependencies.

The fix in this commit uses a regex to exclude all libraries found under
C:\Windows
pull/1453/head
Micah Snyder 3 months ago
parent f60e2db3ec
commit 1b504ef30d
No known key found for this signature in database
GPG Key ID: 3449E631914956D0
  1. 2
      clamdtop/CMakeLists.txt
  2. 2
      clamsubmit/CMakeLists.txt
  3. 2
      libclamav/CMakeLists.txt
  4. 2
      libfreshclam/CMakeLists.txt
  5. 4
      unit_tests/CMakeLists.txt

@ -47,6 +47,8 @@ if(WIN32)
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
$<TARGET_FILE_DIR:Curses::curses>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
)
foreach(_file ${_r_deps})
string(TOLOWER ${_file} _file_lower)

@ -57,6 +57,8 @@ if(WIN32)
DIRECTORIES
$<TARGET_FILE_DIR:CURL::libcurl>
$<TARGET_FILE_DIR:JSONC::jsonc>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
)
foreach(_file ${_r_deps})
string(TOLOWER ${_file} _file_lower)

@ -495,6 +495,8 @@ if(ENABLE_SHARED_LIB)
$<TARGET_FILE_DIR:PCRE2::pcre2>
$<TARGET_FILE_DIR:LibXml2::LibXml2>
$<TARGET_FILE_DIR:JSONC::jsonc>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
)
foreach(_file ${_r_deps})
string(TOLOWER ${_file} _file_lower)

@ -83,6 +83,8 @@ if(ENABLE_SHARED_LIB)
$<TARGET_FILE_DIR:CURL::libcurl>
$<TARGET_FILE_DIR:OpenSSL::SSL>
$<TARGET_FILE_DIR:OpenSSL::Crypto>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
)
foreach(_file ${_r_deps})
string(TOLOWER ${_file} _file_lower)

@ -441,6 +441,8 @@ if(WIN32)
$<TARGET_FILE_DIR:LibXml2::LibXml2>
$<TARGET_FILE_DIR:CURL::libcurl>
$<TARGET_FILE_DIR:JSONC::jsonc>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
CONFLICTING_DEPENDENCIES_PREFIX CTEST_CONFLICTING_DEPENDENCIES
)
foreach(_file ${_r_deps})
@ -496,6 +498,8 @@ if(WIN32)
$<TARGET_FILE_DIR:PCRE2::pcre2>
$<TARGET_FILE_DIR:LibXml2::LibXml2>
$<TARGET_FILE_DIR:JSONC::jsonc>
POST_EXCLUDE_REGEXES
"[cC]:[\\/][wW][iI][nN][dD][oO][wW][sS]"
CONFLICTING_DEPENDENCIES_PREFIX CTEST_CONFLICTING_DEPENDENCIES
)
foreach(_file ${_r_deps})

Loading…
Cancel
Save