CMake: CPack generate Windows installer with WIX

Also creates a ZIP for non-Admin (per-user) installs.

WIX requires the license file to have a .txt or .rtf extension so I
added the .txt extension. I've taken the opportunity to migrate the 3rd
party licenses to a COPYING subdirectory and have added licensing
details to the README.md file.

To build the installer, install WIX and simply run `cpack -C Release`

Also removed the explicit --config option from the
clamav-clamonacc.service file because it should not be required and
isn't being generated correctly when using autotools anyways, especially
after changes in this commit.
This commit is contained in:
Micah Snyder 2020-11-11 23:36:09 -08:00
parent 451279876e
commit 6b3b8b2e9d
37 changed files with 106 additions and 45 deletions

View file

@ -187,6 +187,19 @@ endif()
# Find Library Dependencies
#
if (WIN32)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "ZIP;WIX")
SET(CPACK_WIX_UPGRADE_GUID D9F136C1-3691-47E3-9079-4FE9C9C5EB32)
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt)
SET(CPACK_WIX_PRODUCT_ICON ${CMAKE_CURRENT_SOURCE_DIR}/win32/res/clam.ico)
SET(CPACK_WIX_UI_BANNER ${CMAKE_CURRENT_SOURCE_DIR}/win32/wix_ui_banner.bmp)
SET(CPACK_WIX_UI_DIALOG ${CMAKE_CURRENT_SOURCE_DIR}/win32/wix_ui_dialog.bmp)
SET(CPACK_WIX_CMAKE_PACKAGE_REGISTRY ClamAV)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ClamAV")
include(CPack)
find_package(PThreadW32)
set(HAVE_PTHREAD_H 1)
set(_REENTRANT 1)
@ -633,7 +646,7 @@ set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set(VERSION "${PACKAGE_VERSION}")
# DBDIR for systemd service.in files
set(DBDIR "${DATABASE_DIRECTORY}")
set(DBDIR "${CMAKE_INSTALL_PREFIX}/${DATABASE_DIRECTORY}")
if(ENABLE_DEBUG)
set(CL_DEBUG 1)

View file

@ -2,17 +2,17 @@
if (WIN32)
set(APP_CONFIG_DIRECTORY
"${CMAKE_INSTALL_PREFIX}" CACHE STRING
"." CACHE STRING
"App Config directory.")
set(DATABASE_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/database" CACHE STRING
"database" CACHE STRING
"Database directory.")
else()
set(APP_CONFIG_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/etc" CACHE STRING
"etc" CACHE STRING
"App Config directory.")
set(DATABASE_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/share/clamav" CACHE STRING
"share/clamav" CACHE STRING
"Database directory.")
endif()

View file

@ -1,7 +1,7 @@
The original lzma.txt license file, a small portion of which is reproduced below,
is available under libclamav/7z/lzma.txt.
LICENSE
-------
LZMA SDK is written and placed in the public domain by Igor Pavlov.
The original lzma.txt license file, a small portion of which is reproduced below,
is available under libclamav/7z/lzma.txt.
LICENSE
-------
LZMA SDK is written and placed in the public domain by Igor Pavlov.

View file

@ -430,6 +430,14 @@ _Tip_: If you're having include-path issues, try building with detailed verbosit
cmake --build . --config Release --target install -- /verbosity:detailed
```
To build the installer, you must have WIX Toolset installed. If you're using
Chocolatey, you can install it simply with `choco install wixtoolset` and then
open a new terminal so that WIX will be in your PATH.
```ps1
cpack -C Release
```
### External Depedencies
The CMake tooling is good about finding installed dependencies on POSIX systems.

View file

@ -26,7 +26,7 @@ bin_SCRIPTS=clamav-config
else
SUBDIRS = libltdl libclamav shared libfreshclam clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test clamdtop clambc unit_tests
EXTRA_DIST = examples shared libclamav.pc.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in libclamunrar libclamunrar_iface libclammspack clamdscan/clamdscan.map win32 ChangeLog.md INSTALL.cmake.md INSTALL.autotools.md NEWS.md README.md cmake CMakeLists.txt CMakeOptions.cmake $(top_srcdir)/**/CMakeLists.txt libclammspack/config.h.in.cmake clamav-config.h.cmake.in target.h.cmake.in autogen.sh
EXTRA_DIST = examples shared libclamav.pc.in COPYING.txt COPYING platform.h.in libclamunrar libclamunrar_iface libclammspack clamdscan/clamdscan.map win32 ChangeLog.md INSTALL.cmake.md INSTALL.autotools.md NEWS.md README.md cmake CMakeLists.txt CMakeOptions.cmake $(top_srcdir)/**/CMakeLists.txt libclammspack/config.h.in.cmake clamav-config.h.cmake.in target.h.cmake.in autogen.sh
bin_SCRIPTS=clamav-config

View file

@ -88,6 +88,46 @@ The ClamAV development team welcomes
improvements to [our documentation](https://github.com/Cisco-Talos/clamav-faq),
and also [bug reports](https://bugzilla.clamav.net/). Thanks for joining us!
## Licensing
ClamAV is licensed for public/open source use under the GNU General Public
License, Version 2 (GPLv2).
See `COPYING.txt` for a copy of the license.
### 3rd Party Code
ClamAV contains a number of components that include code copied in part or in
whole from 3rd party projects and whose code is not owned by Cisco and which
are licensed differently than ClamAV. These include:
- tomsfastmath: public domain
- LLVM: Illinois Open Source License (BSD-like)
- Yara: Apache 2.0 license
- Yara has since switched to the BSD 3-Clause License;
Our source is out-of-date and needs to be updated.
- 7z / lzma: public domain
- libclamav's NSIS/NulSoft parser includes:
- zlib: permissive free software license
- bzip2 / libbzip2: BSD-like license
- OpenBSD's libc/regex: BSD license
- file: BSD license
- str.c: Contains BSD licensed modified-implementations of strtol(), stroul()
functions, Copyright (c) 1990 The Regents of the University of California.
- pngcheck (png.c): MIT/X11-style license
- getopt.c: MIT license
- Curl: license inspired by MIT/X, but not identical
- libmspack: LGPL license
- UnRAR (libclamunrar): a non-free/restricted open source license
- Note: The UnRAR license is incompatible with GPLv2 because it contains a
clause that prohibits reverse engineering a RAR compression algorithm from
the UnRAR decompression code.
For this reason, libclamunrar/libclamunrar_iface is not linked at all with
libclamav. It is instead loaded at run-time. If it fails to load, ClamAV
will continue running without RAR support.
See the `COPYING` directory for a copy of the 3rd party project licenses.
## Credits
[The ClamAV Team](https://www.clamav.net/about.html#credits)

View file

@ -74,10 +74,10 @@
#ifndef _WIN32
/* Path to virus database directory. */
#define DATADIR "@DATABASE_DIRECTORY@"
#define DATADIR "@CMAKE_INSTALL_PREFIX@/@DATABASE_DIRECTORY@"
/* where to look for the config file */
#define CONFDIR "@APP_CONFIG_DIRECTORY@"
#define CONFDIR "@CMAKE_INSTALL_PREFIX@/@APP_CONFIG_DIRECTORY@"
#endif
/* Have sys/fanotify.h */

View file

@ -28,7 +28,7 @@ target_link_libraries( clambc
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS clambc DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clambc DESTINATION .)
else()
install(TARGETS clambc DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

View file

@ -28,7 +28,7 @@ target_link_libraries( clamconf
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS clamconf DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamconf DESTINATION .)
else()
install(TARGETS clamconf DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

View file

@ -43,9 +43,9 @@ target_link_libraries( clamd
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamd DESTINATION .)
else()
install(TARGETS clamd DESTINATION ${CMAKE_INSTALL_SBINDIR})
install(TARGETS clamd DESTINATION sbin)
endif()
if(SYSTEMD_FOUND)

View file

@ -32,7 +32,7 @@ target_link_libraries( clamdscan
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS clamdscan DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamdscan DESTINATION .)
else()
install(TARGETS clamdscan DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS clamdscan DESTINATION bin)
endif()

View file

@ -29,7 +29,7 @@ target_link_libraries( clamdtop
ClamAV::shared
Curses::curses )
if(WIN32)
install(TARGETS clamdtop DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamdtop DESTINATION .)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
@ -54,5 +54,5 @@ if(WIN32)
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]])
else()
install(TARGETS clamdtop DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS clamdtop DESTINATION bin)
endif()

View file

@ -49,7 +49,7 @@ target_link_libraries( clamonacc
ClamAV::libclamav
ClamAV::shared
CURL::libcurl )
install(TARGETS clamonacc DESTINATION ${CMAKE_INSTALL_SBINDIR})
install(TARGETS clamonacc DESTINATION sbin)
if(SYSTEMD_FOUND)
configure_file(

View file

@ -11,7 +11,7 @@ After=clamav-daemon.service syslog.target network.target
Type=simple
User=root
ExecStartPre=/bin/bash -c "while [ ! -S /run/clamav/clamd.ctl ]; do sleep 1; done"
ExecStart=@prefix@/sbin/clamonacc -F --config-file=@APP_CONFIG_DIRECTORY@/clamd.conf --log=/var/log/clamav/clamonacc.log --move=/root/quarantine
ExecStart=@prefix@/sbin/clamonacc -F --log=/var/log/clamav/clamonacc.log --move=/root/quarantine
[Install]
WantedBy=multi-user.target

View file

@ -31,7 +31,7 @@ target_link_libraries( clamscan
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS clamscan DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamscan DESTINATION .)
else()
install(TARGETS clamscan DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS clamscan DESTINATION bin)
endif()

View file

@ -36,7 +36,7 @@ if(APPLE)
${APPLE_SECURITY} )
endif()
if(WIN32)
install(TARGETS clamsubmit DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamsubmit DESTINATION .)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
@ -62,5 +62,5 @@ if(WIN32)
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]])
else()
install(TARGETS clamsubmit DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS clamsubmit DESTINATION bin)
endif()

View file

@ -30,9 +30,9 @@ target_link_libraries(freshclam-bin
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS freshclam-bin DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS freshclam-bin DESTINATION .)
else()
install(TARGETS freshclam-bin DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS freshclam-bin DESTINATION bin)
endif()
# Install an empty database directory

View file

@ -566,7 +566,7 @@ if(ENABLE_SHARED_LIB)
target_link_libraries( clamav PUBLIC ICONV::Iconv )
endif()
if(WIN32)
install( TARGETS clamav DESTINATION ${CMAKE_INSTALL_PREFIX} )
install( TARGETS clamav DESTINATION . )
# Also install shared library (DLL) dependencies
install( CODE [[
@ -641,7 +641,7 @@ if(ENABLE_STATIC_LIB)
VERSION ${LIBCLAMAV_VERSION} SOVERSION ${LIBCLAMAV_SOVERSION} )
target_compile_definitions( clamav_static PUBLIC clamav_staticLIB )
if(WIN32)
install( TARGETS clamav_static DESTINATION ${CMAKE_INSTALL_PREFIX} )
install( TARGETS clamav_static DESTINATION . )
else()
install( TARGETS clamav_static DESTINATION ${CMAKE_INSTALL_LIBDIR} )
endif()

View file

@ -74,9 +74,9 @@ if(ENABLE_SHARED_LIB)
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/mspack/mspack.h )
if(WIN32)
install(TARGETS mspack DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS mspack DESTINATION .)
else()
install(TARGETS mspack DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS mspack DESTINATION lib)
endif()
# Public (forwarded) dependencies.

View file

@ -90,9 +90,9 @@ if(ENABLE_SHARED_LIB)
unrar_obj )
if(WIN32)
install(TARGETS clamunrar DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamunrar DESTINATION .)
else()
install(TARGETS clamunrar DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS clamunrar DESTINATION lib)
endif()
add_library( ClamAV::libunrar ALIAS clamunrar )

View file

@ -64,9 +64,9 @@ if(ENABLE_UNRAR)
ClamAV::libunrar_iface_iface)
if(WIN32)
install(TARGETS clamunrar_iface DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS clamunrar_iface DESTINATION .)
else()
install(TARGETS clamunrar_iface DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS clamunrar_iface DESTINATION lib)
endif()
add_library( ClamAV::libunrar_iface ALIAS clamunrar_iface )

View file

@ -67,7 +67,7 @@ if(ENABLE_SHARED_LIB)
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LIBFRESHCLAM_VERSION} SOVERSION ${LIBFRESHCLAM_SOVERSION})
if(WIN32)
install(TARGETS freshclam DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS freshclam DESTINATION .)
# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
@ -94,7 +94,7 @@ if(ENABLE_SHARED_LIB)
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]])
else()
install(TARGETS freshclam DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS freshclam DESTINATION lib)
endif()
add_library( ClamAV::libfreshclam ALIAS freshclam )
@ -115,9 +115,9 @@ if(ENABLE_STATIC_LIB)
VERSION ${LIBFRESHCLAM_VERSION} SOVERSION ${LIBFRESHCLAM_SOVERSION})
target_compile_definitions(freshclam_static PUBLIC freshclam_staticLIB)
if(WIN32)
install(TARGETS freshclam_static DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS freshclam_static DESTINATION .)
else()
install(TARGETS freshclam_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS freshclam_static DESTINATION lib)
endif()
add_library( ClamAV::libfreshclam_static ALIAS freshclam_static )

View file

@ -30,7 +30,7 @@ target_link_libraries( sigtool
ClamAV::libclamav
ClamAV::shared )
if(WIN32)
install(TARGETS sigtool DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS sigtool DESTINATION .)
else()
install(TARGETS sigtool DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS sigtool DESTINATION bin)
endif()

BIN
win32/wix_ui_banner.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
win32/wix_ui_dialog.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB