libowfat
This tree keeps the original GNUmakefile build untouched and adds an optional CMake build for projects that want to consume libowfat directly with CMake.
CMake build
Out-of-tree builds are supported:
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure
By default the CMake build produces the normal shared library name:
libowfat.so
A prefix can be added to the library basename. For example, this builds
libnwowfat.so and, when static builds are enabled, libnwowfat.a:
cmake -S . -B build-nw \
-DLIBOWFAT_LIBRARY_PREFIX=nw \
-DLIBOWFAT_BUILD_STATIC=ON \
-DLIBOWFAT_BUILD_SHARED=ON
cmake --build build-nw
The library version is read from the first line of CHANGES.
Installation
CMake installation uses GNUInstallDirs, so the library directory follows the
platform and the configured prefix, for example lib or lib64:
cmake --install build --prefix /usr
Headers are installed under:
${prefix}/include/libowfat
Generated compatibility headers such as haveip6.h, havesendfile.h,
haveaccept4.h, havesl.h, iopause.h, select.h, and entities.h are
installed there too. This lets consumers include either libowfat/foo.h or,
for legacy code that relies on the target include path, plain foo.h.
Using from another CMake project
As an installed package:
find_package(libowfat CONFIG REQUIRED)
target_link_libraries(myapp PRIVATE libowfat::libowfat)
As a subdirectory or submodule:
add_subdirectory(extern/libowfat)
target_link_libraries(myapp PRIVATE libowfat::libowfat)
The exported build-tree target includes both the source include directory and
the generated header directories, so generated have*.h headers are available
without copying files into the source tree.
Tests
When libowfat is built as the top-level CMake project, BUILD_TESTING=ON
registers t.c as a smoke test and builds the programs under test/:
cmake -S . -B build -DBUILD_TESTING=ON
cmake --build build
ctest --test-dir build --output-on-failure
Only the non-interactive tests are registered with CTest. Network/server/demo programs and tests that need command-line input are compiled but not run by CTest.
When libowfat is used through add_subdirectory(), tests are off by default so
that a parent project does not unexpectedly build the whole test tree. They can
be enabled explicitly:
-DLIBOWFAT_BUILD_TEST_PROGRAMS=ON
-DLIBOWFAT_RUN_SELF_TESTS=ON