Commit f738133e8 for clamav.net
commit f738133e8ed5b206d55753c28ba5fca55f7997fb
Author: Jonas Zaddach <5988756+zaddach@users.noreply.github.com>
Date: Thu Jun 19 15:31:58 2025 +0200
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).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 089a0418f..1d4863928 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/CMakeOptions.cmake b/CMakeOptions.cmake
index 8b80b4dbf..dbdf696ac 100644
--- a/CMakeOptions.cmake
+++ b/CMakeOptions.cmake
@@ -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)
diff --git a/clambc/CMakeLists.txt b/clambc/CMakeLists.txt
index 445c6849b..7c60f677c 100644
--- a/clambc/CMakeLists.txt
+++ b/clambc/CMakeLists.txt
@@ -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()
diff --git a/clamconf/CMakeLists.txt b/clamconf/CMakeLists.txt
index 19873ab43..f0629b739 100644
--- a/clamconf/CMakeLists.txt
+++ b/clamconf/CMakeLists.txt
@@ -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()
diff --git a/clamd/CMakeLists.txt b/clamd/CMakeLists.txt
index 0ad105065..74b6cf446 100644
--- a/clamd/CMakeLists.txt
+++ b/clamd/CMakeLists.txt
@@ -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)
diff --git a/clamdscan/CMakeLists.txt b/clamdscan/CMakeLists.txt
index 048bb16c5..7a22eb079 100644
--- a/clamdscan/CMakeLists.txt
+++ b/clamdscan/CMakeLists.txt
@@ -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()
diff --git a/clamdtop/CMakeLists.txt b/clamdtop/CMakeLists.txt
index fafc2bfe5..cf2f3d647 100644
--- a/clamdtop/CMakeLists.txt
+++ b/clamdtop/CMakeLists.txt
@@ -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()
diff --git a/clamscan/CMakeLists.txt b/clamscan/CMakeLists.txt
index 64608c0df..76c4217a0 100644
--- a/clamscan/CMakeLists.txt
+++ b/clamscan/CMakeLists.txt
@@ -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()
diff --git a/clamsubmit/CMakeLists.txt b/clamsubmit/CMakeLists.txt
index 62b263077..5ce14887b 100644
--- a/clamsubmit/CMakeLists.txt
+++ b/clamsubmit/CMakeLists.txt
@@ -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()
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index cabfc0d0f..6d39ef4bc 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -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()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 10226a173..98c1b27a5 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -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
diff --git a/freshclam/CMakeLists.txt b/freshclam/CMakeLists.txt
index 1aad53091..b331ec51c 100644
--- a/freshclam/CMakeLists.txt
+++ b/freshclam/CMakeLists.txt
@@ -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
diff --git a/libclamav/CMakeLists.txt b/libclamav/CMakeLists.txt
index 16b78a4af..4a08651f6 100644
--- a/libclamav/CMakeLists.txt
+++ b/libclamav/CMakeLists.txt
@@ -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)
diff --git a/libclamav_rust/CMakeLists.txt b/libclamav_rust/CMakeLists.txt
index 79cc2460a..6652a9702 100644
--- a/libclamav_rust/CMakeLists.txt
+++ b/libclamav_rust/CMakeLists.txt
@@ -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)
diff --git a/libclammspack/CMakeLists.txt b/libclammspack/CMakeLists.txt
index e09b0cfb5..12f18cb10 100644
--- a/libclammspack/CMakeLists.txt
+++ b/libclammspack/CMakeLists.txt
@@ -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)
diff --git a/libclamunrar/CMakeLists.txt b/libclamunrar/CMakeLists.txt
index 1e097a7db..a5828fe9e 100644
--- a/libclamunrar/CMakeLists.txt
+++ b/libclamunrar/CMakeLists.txt
@@ -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)
diff --git a/libclamunrar_iface/CMakeLists.txt b/libclamunrar_iface/CMakeLists.txt
index fd6d5ee81..8580bae9d 100644
--- a/libclamunrar_iface/CMakeLists.txt
+++ b/libclamunrar_iface/CMakeLists.txt
@@ -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)
diff --git a/libfreshclam/CMakeLists.txt b/libfreshclam/CMakeLists.txt
index 8f52e0966..c60345fdb 100644
--- a/libfreshclam/CMakeLists.txt
+++ b/libfreshclam/CMakeLists.txt
@@ -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)
diff --git a/sigtool/CMakeLists.txt b/sigtool/CMakeLists.txt
index 496fa2ce7..7ff2019be 100644
--- a/sigtool/CMakeLists.txt
+++ b/sigtool/CMakeLists.txt
@@ -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()