CMake: Simplify install on Windows

The install BINDIR, SBINDIR, LIBDIR, and INCLUDEDIR may be set in
the top level CMakeLists.txt and does not need to be set for each
target. This also enables a build to customize those so that the
bins COULD go to the "bin" directory.

Also add CMake option "ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES".
- When enabled (default), the install will include required system runtime
  libraries and also a copy of the other third party library dependencies
  (e.g. libpcre2, libxml2, libcrypto, etc.).
- When disabled, those files are not included.
  One situation where this is useful is if vcpkg is being used to build
  ClamAV itself (including its dependencies).
This commit is contained in:
Jonas Zaddach
2025-12-12 18:46:45 -05:00
committed by Valerie Snyder
parent c73755d3fc
commit f738133e8e
19 changed files with 175 additions and 225 deletions
+11 -2
View File
@@ -182,6 +182,13 @@ if(APPLE AND NOT DO_NOT_SET_RPATH)
set(CMAKE_MACOSX_RPATH 1)
endif()
if(WIN32)
set(CMAKE_INSTALL_BINDIR "." CACHE STRING "Installation directory for executables")
set(CMAKE_INSTALL_SBINDIR "." CACHE STRING "Installation directory for system executables")
set(CMAKE_INSTALL_LIBDIR "." CACHE STRING "Installation directory for libraries")
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE STRING "Installation directory for header files")
endif()
include(GNUInstallDirs)
if (NOT DEFINED CMAKE_INSTALL_RPATH AND NOT DO_NOT_SET_RPATH)
@@ -339,7 +346,9 @@ set(CPACK_VERBATIM_VARIABLES YES)
if (WIN32)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
include(InstallRequiredSystemLibraries)
if(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES)
include(InstallRequiredSystemLibraries)
endif()
set(CPACK_GENERATOR "ZIP;WIX")
set(CPACK_PACKAGE_VENDOR "Cisco Systems, Inc.")
@@ -998,7 +1007,7 @@ else()
${CMAKE_CURRENT_BINARY_DIR}/clamav-config
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/clamav-config"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
TYPE BIN
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
+4
View File
@@ -129,3 +129,7 @@ option(RUST_COMPILER_TARGET
option(DO_NOT_SET_RPATH
"Don't set the RPATH on UNIX systems.")
option(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES
"Install dependency and system runtime libraries on Windows"
ON)
+2 -4
View File
@@ -36,9 +36,7 @@ target_link_libraries( clambc
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS clambc COMPONENT programs)
if(WIN32)
install(TARGETS clambc DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clambc> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS clambc DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clambc> TYPE BIN OPTIONAL COMPONENT programs)
endif()
+3 -4
View File
@@ -36,9 +36,8 @@ target_link_libraries( clamconf
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS clamconf COMPONENT programs)
if(WIN32)
install(TARGETS clamconf DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamconf> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS clamconf DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamconf> TYPE BIN OPTIONAL COMPONENT programs)
endif()
+2 -4
View File
@@ -52,11 +52,9 @@ target_link_libraries( clamd
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_SBINDIR} COMPONENT programs)
if(WIN32)
install(TARGETS clamd DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamd> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_SBINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamd> TYPE SBIN OPTIONAL COMPONENT programs)
endif()
if(SYSTEMD_FOUND)
+2 -4
View File
@@ -41,9 +41,7 @@ target_link_libraries( clamdscan
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS clamdscan COMPONENT programs)
if(WIN32)
install(TARGETS clamdscan DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamdscan> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS clamdscan DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamdscan> TYPE BIN OPTIONAL COMPONENT programs)
endif()
+30 -30
View File
@@ -37,35 +37,35 @@ target_link_libraries( clamdtop
ClamAV::libclamav
ClamAV::common
Curses::curses )
install(TARGETS clamdtop COMPONENT programs)
if(WIN32)
install(TARGETS clamdtop DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamdtop> DESTINATION . OPTIONAL COMPONENT programs)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES
$<TARGET_FILE:clamdtop>
RESOLVED_DEPENDENCIES_VAR _r_deps
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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT programs)
else()
install(TARGETS clamdtop DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamdtop> TYPE BIN OPTIONAL COMPONENT programs)
if(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES
$<TARGET_FILE:clamdtop>
RESOLVED_DEPENDENCIES_VAR _r_deps
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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT programs)
endif()
endif()
+2 -4
View File
@@ -40,9 +40,7 @@ target_link_libraries( clamscan
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS clamscan COMPONENT programs)
if(WIN32)
install(TARGETS clamscan DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamscan> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS clamscan DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamscan> TYPE BIN OPTIONAL COMPONENT programs)
endif()
+30 -31
View File
@@ -46,36 +46,35 @@ if(APPLE)
${APPLE_CORE_FOUNDATION}
${APPLE_SECURITY} )
endif()
install(TARGETS clamsubmit COMPONENT programs)
if(WIN32)
install(TARGETS clamsubmit DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamsubmit> DESTINATION . OPTIONAL COMPONENT programs)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES
$<TARGET_FILE:clamsubmit>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT programs)
else()
install(TARGETS clamsubmit DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:clamsubmit> TYPE BIN OPTIONAL COMPONENT programs)
if(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES)
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES
$<TARGET_FILE:clamsubmit>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT programs)
endif()
endif()
+1 -1
View File
@@ -114,7 +114,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/html/index.html)
COMPONENT documentation)
else()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
TYPE DOC
COMPONENT documentation)
endif()
endif()
+4 -20
View File
@@ -14,11 +14,7 @@ if(LLVM_FOUND)
target_link_directories( ex_basic_scandesc PUBLIC ${LLVM_LIBRARY_DIRS} )
target_link_libraries( ex_basic_scandesc PUBLIC ${LLVM_LIBRARIES} )
endif()
if(WIN32)
install(TARGETS ex_basic_scandesc DESTINATION .)
else()
install(TARGETS ex_basic_scandesc DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ex_basic_scandesc)
if(ENABLE_STATIC_LIB)
add_executable(ex_basic_scandesc_static)
@@ -32,11 +28,7 @@ if(ENABLE_STATIC_LIB)
target_link_directories( ex_basic_scandesc_static PUBLIC ${LLVM_LIBRARY_DIRS} )
target_link_libraries( ex_basic_scandesc_static PUBLIC ${LLVM_LIBRARIES} )
endif()
if(WIN32)
install(TARGETS ex_basic_scandesc_static DESTINATION .)
else()
install(TARGETS ex_basic_scandesc_static DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ex_basic_scandesc_static)
endif()
add_executable(ex_prescan_callback)
@@ -50,11 +42,7 @@ if(LLVM_FOUND)
target_link_directories( ex_prescan_callback PUBLIC ${LLVM_LIBRARY_DIRS} )
target_link_libraries( ex_prescan_callback PUBLIC ${LLVM_LIBRARIES} )
endif()
if(WIN32)
install(TARGETS ex_prescan_callback DESTINATION .)
else()
install(TARGETS ex_prescan_callback DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ex_prescan_callback)
add_executable(ex_file_inspection_callback)
target_sources(ex_file_inspection_callback
@@ -67,11 +55,7 @@ if(LLVM_FOUND)
target_link_directories( ex_file_inspection_callback PUBLIC ${LLVM_LIBRARY_DIRS} )
target_link_libraries( ex_file_inspection_callback PUBLIC ${LLVM_LIBRARIES} )
endif()
if(WIN32)
install(TARGETS ex_file_inspection_callback DESTINATION .)
else()
install(TARGETS ex_file_inspection_callback DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ex_file_inspection_callback)
add_executable(ex_scan_callbacks)
target_sources(ex_scan_callbacks
+2 -4
View File
@@ -39,11 +39,9 @@ target_link_libraries(freshclam-bin
ClamAV::libfreshclam
ClamAV::libclamav
ClamAV::common )
install(TARGETS freshclam-bin COMPONENT programs)
if(WIN32)
install(TARGETS freshclam-bin DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:freshclam-bin> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS freshclam-bin DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:freshclam-bin> TYPE BIN OPTIONAL COMPONENT programs)
endif()
# Now we rename freshclam-bin executable to freshclam using target properties
+38 -42
View File
@@ -482,43 +482,43 @@ if(ENABLE_SHARED_LIB)
target_link_options( clamav PRIVATE "-Wl,-z,gnu-version-script-compat")
endif()
endif()
install( TARGETS clamav COMPONENT libraries )
if(WIN32)
install( TARGETS clamav DESTINATION . COMPONENT libraries )
install( FILES $<TARGET_PDB_FILE:clamav> DESTINATION . OPTIONAL COMPONENT libraries )
# Also install shared library (DLL) dependencies
install( CODE [[
file(GET_RUNTIME_DEPENDENCIES
LIBRARIES
$<TARGET_FILE:ClamAV::libclamav>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
$<TARGET_FILE_DIR:OpenSSL::SSL>
$<TARGET_FILE_DIR:OpenSSL::Crypto>
$<TARGET_FILE_DIR:ZLIB::ZLIB>
$<TARGET_FILE_DIR:BZip2::BZip2>
$<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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT libraries )
else()
install( TARGETS clamav DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries )
install( FILES $<TARGET_PDB_FILE:clamav> TYPE BIN OPTIONAL COMPONENT libraries )
if(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES)
# Also install shared library (DLL) dependencies
install( CODE [[
file(GET_RUNTIME_DEPENDENCIES
LIBRARIES
$<TARGET_FILE:ClamAV::libclamav>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
$<TARGET_FILE_DIR:OpenSSL::SSL>
$<TARGET_FILE_DIR:OpenSSL::Crypto>
$<TARGET_FILE_DIR:ZLIB::ZLIB>
$<TARGET_FILE_DIR:BZip2::BZip2>
$<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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT libraries )
endif()
endif()
if(LLVM_FOUND)
@@ -591,11 +591,7 @@ if(ENABLE_STATIC_LIB)
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LIBCLAMAV_VERSION} SOVERSION ${LIBCLAMAV_SOVERSION} )
target_compile_definitions( clamav_static PUBLIC clamav_staticLIB )
if(WIN32)
install( TARGETS clamav_static DESTINATION . COMPONENT libraries )
else()
install( TARGETS clamav_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries )
endif()
install( TARGETS clamav_static COMPONENT libraries )
add_library( ClamAV::libclamav_static ALIAS clamav_static )
if(NOT ENABLE_SHARED_LIB)
@@ -608,5 +604,5 @@ install(
clamav.h
${CMAKE_BINARY_DIR}/clamav-types.h
${CMAKE_BINARY_DIR}/clamav-version.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
TYPE INCLUDE
COMPONENT libraries)
+1 -5
View File
@@ -54,10 +54,6 @@ if (WIN32)
target_link_libraries(clamav_rust PUBLIC INTERFACE Userenv)
endif()
if(WIN32)
install(FILES $<TARGET_FILE:clamav_rust> DESTINATION . COMPONENT libraries)
else()
install(FILES $<TARGET_FILE:clamav_rust> DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(FILES $<TARGET_FILE:clamav_rust> TYPE LIB COMPONENT libraries)
add_library(ClamAV::libclamav_rust ALIAS clamav_rust)
+3 -9
View File
@@ -79,11 +79,9 @@ if(ENABLE_SHARED_LIB)
)
endif()
install(TARGETS clammspack COMPONENT libraries)
if(WIN32)
install(TARGETS clammspack DESTINATION . COMPONENT libraries)
install(FILES $<TARGET_PDB_FILE:clammspack> DESTINATION . OPTIONAL COMPONENT libraries)
else()
install(TARGETS clammspack DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(FILES $<TARGET_PDB_FILE:clammspack> TYPE BIN OPTIONAL COMPONENT libraries)
endif()
add_library( ClamAV::libmspack ALIAS clammspack )
@@ -103,11 +101,7 @@ if(ENABLE_STATIC_LIB)
${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/mspack )
if(WIN32)
install(TARGETS clammspack_static DESTINATION . COMPONENT libraries)
else()
install(TARGETS clammspack_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(TARGETS clammspack_static COMPONENT libraries)
add_library( ClamAV::libmspack_static ALIAS clammspack_static )
if(NOT ENABLE_SHARED_LIB)
+2 -11
View File
@@ -105,12 +105,7 @@ if(ENABLE_SHARED_LIB)
endif()
endif()
if(WIN32)
install(TARGETS clamunrar DESTINATION . COMPONENT libraries)
install(FILES $<TARGET_PDB_FILE:clamunrar> DESTINATION . OPTIONAL COMPONENT libraries)
else()
install(TARGETS clamunrar DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(TARGETS clamunrar COMPONENT libraries)
add_library( ClamAV::libunrar ALIAS clamunrar )
endif()
@@ -136,11 +131,7 @@ if(ENABLE_STATIC_LIB)
COMPILE_FLAGS "-Wno-logical-op-parentheses -Wno-switch -Wno-dangling-else")
endif()
if(WIN32)
install(TARGETS clamunrar_static DESTINATION . COMPONENT libraries)
else()
install(TARGETS clamunrar_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(TARGETS clamunrar_static COMPONENT libraries)
add_library( ClamAV::libunrar_static ALIAS clamunrar_static )
if(NOT ENABLE_SHARED_LIB)
+3 -9
View File
@@ -79,11 +79,9 @@ if(ENABLE_UNRAR)
PUBLIC
ClamAV::libunrar_iface_iface)
install(TARGETS clamunrar_iface COMPONENT libraries)
if(WIN32)
install(TARGETS clamunrar_iface DESTINATION . COMPONENT libraries)
install( FILES $<TARGET_PDB_FILE:clamunrar_iface> DESTINATION . OPTIONAL COMPONENT libraries )
else()
install(TARGETS clamunrar_iface DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install( FILES $<TARGET_PDB_FILE:clamunrar_iface> TYPE BIN OPTIONAL COMPONENT libraries )
endif()
add_library( ClamAV::libunrar_iface ALIAS clamunrar_iface )
@@ -113,11 +111,7 @@ if(ENABLE_UNRAR)
PRIVATE
ClamAV::libunrar_static )
if(WIN32)
install(TARGETS clamunrar_iface_static DESTINATION . COMPONENT libraries)
else()
install(TARGETS clamunrar_iface_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(TARGETS clamunrar_iface_static COMPONENT libraries)
add_library( ClamAV::libunrar_iface_static ALIAS clamunrar_iface_static )
if(NOT ENABLE_SHARED_LIB)
+33 -37
View File
@@ -73,39 +73,39 @@ if(ENABLE_SHARED_LIB)
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LIBFRESHCLAM_VERSION} SOVERSION ${LIBFRESHCLAM_SOVERSION}
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libfreshclam.map)
install(TARGETS freshclam COMPONENT libraries)
if(WIN32)
install(TARGETS freshclam DESTINATION . COMPONENT libraries)
install(FILES $<TARGET_PDB_FILE:freshclam> DESTINATION . OPTIONAL COMPONENT libraries)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
LIBRARIES
$<TARGET_FILE:ClamAV::libfreshclam>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
$<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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT libraries)
else()
install(TARGETS freshclam DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
install(FILES $<TARGET_PDB_FILE:freshclam> TYPE BIN OPTIONAL COMPONENT libraries)
if(ENABLE_WINDOWS_INSTALL_THIRDPARTY_DEPENDENCIES)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
LIBRARIES
$<TARGET_FILE:ClamAV::libfreshclam>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
$<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)
if(NOT ${_file_lower} MATCHES "c:[\\/]windows[\\/]system32.*")
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}"
TYPE SHARED_LIBRARY
FOLLOW_SYMLINK_CHAIN
FILES "${_file}"
)
endif()
endforeach()
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]]
COMPONENT libraries)
endif()
endif()
add_library( ClamAV::libfreshclam ALIAS freshclam )
@@ -156,11 +156,7 @@ if(ENABLE_STATIC_LIB)
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LIBFRESHCLAM_VERSION} SOVERSION ${LIBFRESHCLAM_SOVERSION})
target_compile_definitions(freshclam_static PUBLIC freshclam_staticLIB)
if(WIN32)
install(TARGETS freshclam_static DESTINATION . COMPONENT libraries)
else()
install(TARGETS freshclam_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
install(TARGETS freshclam_static COMPONENT libraries)
add_library( ClamAV::libfreshclam_static ALIAS freshclam_static )
if(NOT ENABLE_SHARED_LIB)
+2 -4
View File
@@ -40,9 +40,7 @@ target_link_libraries( sigtool
PRIVATE
ClamAV::libclamav
ClamAV::common )
install(TARGETS sigtool COMPONENT programs)
if(WIN32)
install(TARGETS sigtool DESTINATION . COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:sigtool> DESTINATION . OPTIONAL COMPONENT programs)
else()
install(TARGETS sigtool DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
install(FILES $<TARGET_PDB_FILE:sigtool> TYPE BIN OPTIONAL COMPONENT programs)
endif()