Commit graph

63 commits

Author SHA1 Message Date
Val Snyder
af6d3e85ec
CMake: improve ncurses detection; separate TINFO_LIBRARY input
I found that on macOS, setting the libncurses.a and libtinfo.a into the
same CURSES_LIBRARY variable does not find or link with libtinfo.a.

To fix this, this commit adds a separate TINFO_LIBRARY variable.
In the end, CURSES_LIBRARIES and the Curses::curses CMake TARGET will
still have both libraries set, if both are provided.

This fix is necessary if the ncurses was built with `--with-terminfo`.
I think we got away without it on Linux because of pkg-config.

I also found that Apple's ncurses is prioritized by PkgConfig over one
specified by using variables. To this end, we'll skip PkgConfig if
the include path was provided.
2025-08-27 14:24:27 -04:00
Valerie Snyder
544fb9fef2
Codesign: fix test files & upgrade clamav-signature-util for related fix
The .sign test files have the min flevel set to 220.
It should be 230.

Also upgrade clamav-signature-util to v1.2.4 for fix so new .sign
files will have the correct min flevel.
2025-05-05 16:54:07 -04:00
Val Snyder
8d485b9bfd
FIPS-compliant CVD signing and verification
Add X509 certificate chain based signing with PKCS7-PEM external
signatures distributed alongside CVD's in a custom .cvd.sign format.
This new signing and verification mechanism is primarily in support
of FIPS compliance.

Fixes: https://github.com/Cisco-Talos/clamav/issues/564

Add a Rust implementation for parsing, verifying, and unpacking CVD
files.

Now installs a 'certs' directory in the app config directory
(e.g. <prefix>/etc/certs). The install location is configurable.
The CMake option to configure the CVD certs directory is:
  `-D CVD_CERTS_DIRECTORY=PATH`

New options to set an alternative CVD certs directory:
- Commandline for freshclam, clamd, clamscan, and sigtool is:
  `--cvdcertsdir PATH`
- Env variable for freshclam, clamd, clamscan, and sigtool is:
  `CVD_CERTS_DIR`
- Config option for freshclam and clamd is:
  `CVDCertsDirectory PATH`

Sigtool:
- Add sign/verify commands.
- Also verify CDIFF external digital signatures when applying CDIFFs.
- Place commonly used commands at the top of --help string.
- Fix up manpage.

Freshclam:
- Will try to download .sign files to verify CVDs and CDIFFs.
- Fix an issue where making a CLD would only include the CFG file for
daily and not if patching any other database.

libclamav.so:
- Bump version to 13:0:1 (aka 12.1.0).
- Also remove libclamav.map versioning.
  Resolves: https://github.com/Cisco-Talos/clamav/issues/1304
- Add two new API's to the public clamav.h header:
  ```c
  extern cl_error_t cl_cvdverify_ex(const char *file,
                                    const char *certs_directory);

  extern cl_error_t cl_cvdunpack_ex(const char *file,
                                    const char *dir,
                                    bool dont_verify,
                                    const char *certs_directory);
  ```
  The original `cl_cvdverify` and `cl_cvdunpack` are deprecated.
- Add `cl_engine_field` enum option `CL_ENGINE_CVDCERTSDIR`.
  You may set this option with `cl_engine_set_str` and get it
  with `cl_engine_get_str`, to override the compiled in default
  CVD certs directory.

libfreshclam.so: Bump version to 4:0:0 (aka 4.0.0).

Add sigtool sign/verify tests and test certs.

Make it so downloadFile doesn't throw a warning if the server
doesn't have the .sign file.

Replace use of md5-based FP signatures in the unit tests with
sha256-based FP signatures because the md5 implementation used
by Python may be disabled in FIPS mode.
Fixes: https://github.com/Cisco-Talos/clamav/issues/1411

CMake: Add logic to enable the Rust openssl-sys / openssl-rs crates
to build against the same OpenSSL library as is used for the C build.
The Rust unit test application must also link directly with libcrypto
and libssl.

Fix some log messages with missing new lines.

Fix missing environment variable notes in --help messages and manpages.

Deconflict CONFDIR/DATADIR/CERTSDIR variable names that are defined in
clamav-config.h.in for libclamav from variable that had the same name
for use in clamav applications that use the optparser.

The 'clamav-test' certs for the unit tests will live for 10 years.
The 'clamav-beta.crt' public cert will only live for 120 days and will
be replaced before the stable release with a production 'clamav.crt'.
2025-03-26 19:33:25 -04:00
John Humlick
18120a0ef0
clamd: Fix bug reporting memory stats, used by clamdtop
ClamD's STATS API reports process memory stats on systems that
provide the `mallinfo()` system call.
This feature is used by ClamDTOP to show process memory usage.
When we switched to the CMake build system, we neglected to add the
check for the `mallinfo()` system call and so broke ClamD memory
usage reporting.

This commit adds the CMake check for `mallinfo()` and sets
HAVE_MALLINFO, if found.

Fixes: https://github.com/Cisco-Talos/clamav/issues/706

Jira: CLAM-2742
2025-03-13 10:38:49 -07:00
Val Snyder
7ff29b8c37
Bump copyright dates for 2025 2025-02-14 10:24:30 -05:00
liushuyu
bef8451ad2
cmake/FindRust.cmake: inherit RUSTFLAGS from the environment 2024-07-23 10:05:40 +08:00
liushuyu
f65b95edeb
cmake/FindRust.cmake: strip MSVC linker flags ...
... from native libraries array. Otherwise Ninja will get very confused.
2024-07-22 09:17:31 -04:00
Micah Snyder
17c9f5b64f CMake: Fix small typo in vendored source URL 2024-01-23 23:26:09 -05:00
Micah Snyder
9cb28e51e6 Bump copyright dates for 2024 2024-01-22 11:27:17 -05:00
RainRat
1b17e20571
Fix typos (no functional changes) 2024-01-19 09:08:36 -08:00
Micah Snyder
c48146a792 Cargo+Rust: add git repo source as vendored source 2024-01-12 11:33:52 -05:00
Micah Snyder
5cc3243136 CMake+Rust: Fix offline builds w. vendored git repos
Some builds using the tarball with the vendored Rust dependencies are
failing.

The onenote-rs dependency is presently tied to a git branch from github
rather than using a release from crates.io. This is the differing factor
though I'm unsure why it is causing the build to try to update the repo
rather than just building the vendored source.

This commit adds a `--offline` parameter to the build options if the
vendored source is detected, in an attempt to force Cargo to use what it
has and stay offline.
2024-01-12 11:33:52 -05:00
Micah Snyder
9adde39b80 CMake: Rust bindgen w/ C libs outside std include path
In order to generate Rust bindings for C code, Rust's bindgen module
needs to know where to find all headers included by the API.
If they're all inside the project or inside the standard include path
(e.g. /usr/include and /usr/local/include) that's fine. But for third-
party C library headers from outside the standard include path, that's
a problem.
We didn't really notice this problem when generating on Unix systems
until we switched to use OpenSSL 3.1 and tested on systems that have
the OpenSSL 1.1.1 dev package installed.

The ability to find headers outside the project path is also needed to
generate bindings on Windows, if desired.

This commit solves the problem by passing include directories for the
ClamAV::libclamav CMake build target to the Rust build via the
CARGO_INCLUDE_DIRECTORIES environment variable.
Then, in the `libclamav_rust/build.rs` script, where we run bindgen,
we split that `;` separated string into invididual paths and add each
to the bindgen builder.
2023-12-11 15:18:41 -05:00
RainRat
caf324e544
Fix typos (no functional changes) 2023-11-26 18:01:19 -05:00
Micah Snyder
c961189308 CMake-Rust [Windows]: Fix issue detecting native static libs
Some change in Cargo/Rust version 1.70 or 1.71 appears to have broken
the build on Windows because we are incorrectly attempting to check the
native static libraries by compiling an empty file (/dev/null) which
does not exist on Windows.

A simple fix is to make an empty file of our own and use that instead.

Fixes: https://github.com/Cisco-Talos/clamav/issues/990
2023-08-09 10:50:54 -07:00
Micah Snyder
5ad6c3ffe0
CMake: link openssl 3.x with clamsubmit on macOS
When switching to openssl 3.x, linking with clamsubmit fails with
undefined openssl symbols. The error message from Xcode is crazy obtuse:

ld: initializer '_OPENSSL_cpuid_setup' is >4GB from start of image in 'anon' from /Users/clamav_jenkins_svc/clamav-mussels-cookbook/test/install-x86_64/lib/libcrypto.a(libcrypto-lib-x86_64cpuid.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Anyhow... It seems that we must explicitly link clamsubmit with openssl
now in order for this to work.

In addition to this change, I also found that the CMake FindRust.cmake 
module breaks the ability to build specifically for just x86_64 or arm64
(i.e. possibly cross-compiling. 
This commit includes a change to accommodate that scenario.
2023-07-11 09:39:57 -07:00
Orion Poplawski
81472182e6
CMake: Allow passing in custom RUSTFLAGS
A user building clamav may now set the RUSTFLAGS CMake variable
if additional options such as `--verbose` are desired.

E.g.
    cmake .. -D RUSTFLAGS="--verbose"

See `rustc --help` for more details.
2023-03-22 15:39:04 -07:00
Micah Snyder
6eebecc303 Bump copyright for 2023 2023-02-12 11:20:22 -08:00
Micah Snyder
e8a1fa6d53 CMake: define _GNU_SOURCE for Clang, as well
Building with these will fail for Clang because _GNU_SOURCE is not
defined.
    -Werror=implicit-function-declaration
    -Werror=implicit-int
    -Werror=strict-prototypes

Also added fix to use "MATCHES" instead of "EQUALS" in FindLLVM where
the same sort of logic is used.
2022-11-22 23:22:57 -08:00
Micah Snyder
5c3e866d30 CMake: remove option to build using external TomsFastMath library
ClamAV requires non-default build options for TomsFastMath to support
bigger floating point numbers. Without this change, database and
Windows EXE/DLL authenticode certificate validation may fail.

The option to build with an external TomsFastMath library should be
removed. The `ENABLE_EXTERNAL_TOMSFASTMATH` build should be ignored,
with some sort of warning.

This commit removes the option. If used, the build will not fail, but
CMake will print a warning that the unused option was ignored.
2022-11-10 07:56:06 -08:00
Micah Snyder
197113cded Fix mmap() C API detection on macOS
The CheckFmapFeatures module is failing because HAVE_SYS_STAT_H and
HAVE_SYS_TYPES_H are not defined within the check_c_source_compiles
environment.

This commit adds them in the same way as is done for CheckFDPassing
module.
2022-09-26 12:10:29 -07:00
Micah Snyder
bafb26bad3 CMake+Rust: default build must be release with debug info
We already set the default build type to RelWithDebInfo for CMake, but
we were setting it *after* adding the Rust module.  We need to do it
before, or else the Rust stuff will still default to Debug, which makes
for really slow scans of images that get fuzzy hashed.
2022-09-20 17:55:42 -07:00
Micah Snyder
d5dd055ada Cmake+Rust: Disable test precompile feature
Precompiling the test executable causes `sudo make install` to fail.
The issue is that because we don't know the OUTPUT file path for the
test executable, CMake can't know if it doesn't need to rerun that
command, so it will run it with any call to `make`. The problem is that
cargo is will fail to run with `sudo` on many systems.

This is generally okay, because we just fixed the issue where we had
been compiling the dependencies for each module. Now that we only build
the dependencies once, building the test executable is actually very
fast. So compiling it during the test isn't so bad.
2022-09-16 13:05:48 -07:00
Micah Snyder
6814f71448 CMake+Rust: Don't rebuild Rust dependencies
Right now, each Rust-based target added in CMake is being built in its
own directory under the build path. This causes Rust to build each
module from scratch, meaning any dependencies they have in common are
built twice.

The solution in this commit is to specify the top level build directory
as the target directory for every Rust build and test.

Note this also changes where the `clamav_rust.h` file is generated.  It
is now also placed in the top-level build directory, instead of under the
`build/libclamav_rust` directory. That's a bit of a side-effect, and
could be rectified if needed, but it appears to have no ill-effects.
It's the same location that we drop the clamav-types.h file, so I think
it's fine, for now. Note that `clamav_rust.h` is not a public header,
it's just so libclamav functions can call into libclamav_rust functions.
2022-09-16 13:05:48 -07:00
Micah Snyder
64d6861d93 CMake, Rust: precompile test executable
Precompile the test executable during the main build, after libclamav
has built. This will make it so the compile time does not count against
the test time.
It also, unfortunately, make the main build take way longer.

Removed 3 duplicate variables from the test ENVIRONMENT variable.
2022-09-16 13:05:48 -07:00
Micah Snyder
c4ceb9a9a1 Auto-format CMakeRust module with vscode 2022-09-16 13:05:48 -07:00
Micah Snyder
1ee33809ca CMake, Rust: Add support for building Rust executables
Update CMakeRust.cmake from github.com/micahsnyder/cmake-rust-demo
Add the ability to build Rust-based executables from CMake.
2022-09-16 13:05:48 -07:00
antchan2
cbaf87494c CMake: arch order fix for Rust-based OSX universal binaries
The FindRust.cmake module is hard-coded to expect CMAKE_OSX_ARCHITECTURES
value of "arm64,x86_64" to build a Rust-based Apple universal binary.
If the build uses "x86_64,arm64", which is equivalent, then the build will
fail. Order should not matter.
2022-07-19 16:40:09 -07:00
Andy Ragusa
4b83bcf0c5 Updated llvm runtime to support llvm versions 8, 9, 10, 11, 12
Modified bytecode JIT code to support llvm versions 8, 9, 10, 11, 12.
Additionally updated FindLLVM.cmake to the current version, found at
https://github.com/ldc-developers/ldc/blob/master/cmake/Modules/FindLLVM.cmake,
as well as making modifications suggested by Micah Snyder to check VERSION_LESS
in CMakeLists.txt to avoid having modifications to FindLLVM.cmake.
2022-03-09 20:35:42 -08:00
Micah Snyder
027e5b6144 CMake, CTest: Decrease Rust test verbosity
Now that we have a fair number of Rust crate dependencies,
`cargo test -vv` is way too verbose.
2022-03-02 13:12:59 -07:00
Micah Snyder
0556550b23 CMake, Rust: Improve toolchain (target triple) selection
The current method of trying to determine the target triple based
the architecture, operating system, etc. is difficult to get right
and maintain. In particular, I found that some installations like the
Alpine package will use "alpine" in the name of the triple instead of
"unknown".
E.g. "aarch64-alpine-linux-musl" instead of "aarch64-unknown-linux-musl".
This makes it nearly impossible to figure out the exact target name
based on target system specifications.

I believe it will be better to use the default target 99% of the time
and require users that which to cross-compile to use a new CMake
variable `-D RUST_TARGET_TRIPLE=<target>` to choose the target.
This is basically how it works for C/C++ anyways.
2022-03-01 16:18:03 -07:00
Micah Snyder
9035ef10af CMake, no pkg-config: Also support finding ncursesw
Like the commit to support ncursesW using pkg-config, this commit
extends that to the non-pkg-config scenario.
2022-02-22 20:25:09 -07:00
Micah Snyder
d4a5f9f77e CMake: curses detection with-or-without pkg-config
FreeBSD and OpenBSD package maintainers identified failures when
pkg-config .pc files not present for curses/ncurses.

Patch courtesy of Stuart Henderson.
2022-02-22 20:25:09 -07:00
Carlos Velasco
c40a2c2660
CMake: Fix FindCurses.cmake to try ncursesw if ncurses not found
Change to pkg_search_module, first try to find ncurses pkg, if not found, then try with ncursesw pkg
2022-02-18 15:02:54 -08:00
Micah Snyder
9bdc28b052 CMake: Support external TomsFastMath library (libtfm)
Add support for compiling with external TomsFastMath library provided by
the system instead of compiling the vendored copy into libclamav.

The vendored source is still built directly into libclamav instead of as
a separate library the way libmspack is done.
The rationale is that:
A) it's more complicated to deal with possibly compiling as static or
dynamic, and also
B) libmspack and libunrar are compiled separately primarily because of
licensing concerns. TomsFastMath public domain, so that isn't a concern.

Resolves: https://bugzilla.clamav.net/show_bug.cgi?id=12562
2022-02-10 12:54:23 -07:00
micasnyd
0fe0b79b94 CMake: Rust RelWithDebInfo and MinSizeRel builds
RelWithDebInfo is our preferred build type. It has optimizations and
should run faster, but includes debugging symbols for better profiling,
stack traces, etc.

The Rust MinSizeRel support is just Release mode for now. There are
optimizations we can do to shrink it further, but for now at least it
won't actually be Debug (aka slow).
2022-01-19 16:12:25 -07:00
micasnyd
4d34bc10b8 Rust bindgen: Only generate if CMake MAINTAINER_MODE is ON
In testing, I found that libclang.so/clang.dll is required by bindgen
and was not found on all of our test machines. To resolve this we will
only generate sys.rs bindings when CMake MAINTAINER_MODE option is "ON".

This is unfortunate that we have to commit generated source to version
control. But as a benefit it makes rust-analyzer happier when editing a
workspace that hasn't yet been compiled. And it makes it more reasonable
that the generated sys.rs file generated to the source directory and not
the build directory (something we hadn't resolved yet).
2022-01-14 11:50:07 -07:00
micasnyd
5698e3285c CMake-Rust: Only execute cbindgen for build, not tests
Generate c-bindings header in build (binary) directory,
not source directory (if different).
2022-01-10 12:18:33 -07:00
micasnyd
140c88aa4e Bump copyright for 2022
Includes minor format corrections.
2022-01-09 14:23:25 -07:00
Scott Hutton
278ba2923e Integrate cbindgen via build.rs 2021-12-08 13:15:46 -07:00
Scott Hutton
37e5b573aa Add Rust logging module unit test & integrate with CMake / CTest
Add a basic unit test for the new libclamav_rust `logging.rs` module.
This test simply initializes logging and then prints out a message with
each of the `log` macros.

Also set the Rust edition to 2018 because the default is the 2015
edition in which using external crates is very clunky.

For the Rust test support in CMake this commit adds support for
cross-compiling the Rust tests.
Rust tests must be built for the same LLVM triple (target platform) as
the rest of the project. In particular this is needed to build both
x64 and x86 packages on a 64bit Windows host.

For Alpine, we observed that the LLVM triple for the host platform tools
may be either:
- x86_64-unknown-linux-musl, or
- x86_64-alpine-linux-musl
To support it either way, we look up the host triple with `rustc -vV`
and use that if the musl libc exists. This is a big hacky and
unfortunately means that we probably can't cross-compile to other
platforms when running on a musl libc host. There are probably
improvements to be made to improve cross compiling support.

The Rust test programs must link with libclamav, libclammspack, and
possibly libclamunrar_iface and libclamunrar plus all of the library
dependencies for those libraries.
To do this, we pass the path of each library in environment variables
when building the libclamav_rust unit test program.
Within `libclamav_rust/build.rs`, we read those environment variables.
If set, we parse each into library path and name components to use
as directives for how to build the unit test program.
See: https://doc.rust-lang.org/cargo/reference/build-scripts.html

Our `build.rs` file ignores the library path environment variables if
thye're not set, which is necessary when building the libclamav_rust
library and when libclamunrar isn't static and for when not linking with
a libiconv external to libc.

Rust test programs are built and executed in subdirectory under:
  <target>/<llvm triple>/<config>/deps
where "target" for libclamav_rust tests is set to <build>/unit_tests
For example:
  clamav/build/unit_tests/x86_64-pc-windows-msvc/debug/deps/clamav_rust-7e1343f8a2bff1cc.exe
Since this program isn't co-located with the rest of the libraries
we also have to set environment variables so the test program can find and
load the shared libraries:
- Windows: PATH
- macOS: DYLD_LIBRARY_PATH
We already set LD_LIBRARY_PATH when not Windows for similar reasons.

Note: In build.rs, we iterate references to LIB_ENV_LINK & Co because
older Rust versions do implement Iterator for [&str].
2021-11-23 10:43:14 -08:00
Micah Snyder
679883fdb6 CMake: Improve Rust platform support
Add support for Rust FreeBSD, OpenBSD targets

Add support for Rust on GNU aarch64.

Add support for Rust on Alpine (musl x86_64).
Note: Current trick of checking for musl libc.so doesn't work when
cross compiling. TODO: Find a better way to check if the target is
MUSL.

Add Rust toolchain to fix Dockerfile build.
2021-11-15 12:33:05 -08:00
Micah Snyder
6f4bbe2d8b CMake: Add support for Rust (Cargo) universal binary builds on macOS 2021-11-15 12:33:05 -08:00
Micah Snyder
147502dcf6 Add cargo vendor feature
Vendoring crate dependencies is required for offline builds.
Some packaging systems require that builds can be performed offline.
This feature enabled vendoring crates at configure time which are
then included in in CPack source packaging.
2021-11-15 12:33:05 -08:00
Micah Snyder
a53eeec275 CMake: Add Rust toolchain detection 2021-11-15 12:33:05 -08:00
Luca Barbato
54829910d0
CMake: Fix FindCurses.cmake issue when tinfo is separate library
Use all the link line from ncurses pkg-config.
Otherwise it would fail at link time if ncurses has a stand alone tinfo library.
2021-10-29 14:53:16 -07:00
bleve
872a83fbfe Fix systemd detection to detect also older versions of systemd
This fixes issue when building on rhel7/centos7 and other distros with older systemd versions.
2021-08-22 10:14:20 -07:00
Micah Snyder
a868a7a055 CMake: Fix find-curses issue with static libs
If ncurses or pdcurses are static libraries, they are not properly
detected.

First, the user compiling clamav needs to specify if the include path is
for NCURSES or PDCURSES, which will differentiate the two. I've updated
the INSTALL.md file to show this.

Second, the wrong variable was being used to add the include path to the
Curses::curses target, which means that clamdtop would fail to include
ncurses.h. I fixed this.
2021-08-18 13:53:34 -07:00
Micah Snyder
e0e0c8f955 CMake: Support to build deb, rpm, & macOS pkg packages
CMake/CPack is already used to build:
- TGZ source tarball
- WiX-based installer (Windows)
- ZIP install packages (Windows)

This commit adds support for building:
- macOS PKG installer
- DEB package
- RPM package

This should also enable building FreeBSD packages, but while I was able
to build all of the static dependencies using Mussels, CMake/CPack 3.20
doesn't appear to have the the FreeBSD generator despite being in the
documentation.

The package names are will be in this format:
  clamav-<version><suffix>.<os>.<arch>.<extension>

This includes changing the Windows .zip and .msi installer names.

E.g.:
- clamav-0.104.0-rc.macos.x86_64.pkg
- clamav-0.104.0-rc.win.win32.msi
- clamav-0.104.0-rc.win.win32.zip
- clamav-0.104.0-rc.win.x64.msi
- clamav-0.104.0-rc.linux.x86_64.deb
- clamav-0.104.0-rc.linux.x86_64.rpm

Notes about building the packages:

I've only tested this with building ClamAV using static dependencies that
I build using the clamav_deps "host-static" recipes from the "clamav"
Mussels cookbook. Eg:

  msl build clamav_deps -t host-static

Here's an example configuration to build clam in this way, installing to
/usr/local/clamav:

```sh
cmake .. \
  -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \
  -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \
  -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \
  -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \
  -D CMAKE_BUILD_TYPE=RelWithDebInfo \
  -D ENABLE_EXAMPLES=OFF \
  -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \
  -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \
  -D ENABLE_JSON_SHARED=OFF \
  -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \
  -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \
  -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \
  -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \
  -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \
  -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \
  -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \
  -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \
  -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \
  -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \
  -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a"
```

Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's
install location. This can be different than the install prefix. E.g.:
```sh
  -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \
  -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \
```

Then `make` and then one of these, depending on the platform:
```sh
cpack        # macOS: productbuild is default
cpack -G DEB # Debian-based
cpack -G RPM # RPM-based
```

On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can
be converted to html so it will render in the installer.

On RPM-based systems, you'll need rpmbuild (install rpm-build)

This commit also fixes an issue where the html manual (if present) was
not correctly added to the Windows (or now other) install packages.

Fix num to hex function for Windows installer guid

Fix win32 cpack build

Fix macOS cpack build
2021-08-18 13:53:34 -07:00
Arjen de Korte
9f8b01ec79 cmake/FindIconv.cmake: fix return type in test code
In openSUSE Tumbleweed, this test always fails because it compiles with `-Werror=return-type` by default. Fixing this by adding a return value in the test script to keep the compiler happy.
2021-07-30 14:23:13 -07:00