Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Build Support for liquid 1.5.0 #314

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lukeprince20
Copy link

Current minimum version set to CMake 3.15 to take advantage of newer language features. Alternative to using autotools for building liquid. The contribution is purely additive and does not modify the autotools configuration or impact the current behavior/performance of liquid when built the conventional way. This is a 1-to-1 port of configure.ac and makefile.in to CMakeLists.txt + supporting CMake module files. Certain options such as the default CFLAGS are left up to the CMake generator to determine (e.g. If you want -g -O2 then you do a RelWithDebInfo build). Handles the required platform checks for generating config.h. Depends on the cpu_features library for detection of supported CPU instruction sets. All main targets defined by makefile.in are supported. The help target has been rebranded as list due to help being reserved by the CMake Unix Makefile generator. The .gitignore has been updated to handle CMake generated build files.

Note that not all generated executables currently write to the build folder, but continue to be created in their expected locations within the source. This is to ensure the correct results are output when running targets that depend on the autoscript generated xautotest/benchmark programs. Additionally the examples and sandbox executables are also still written to their expected locations within the source. The clean targets still work as expected.

Building with CMake is a prerequisite for introducing MSVC support. However, the Microsoft Visual Studio C Compiler is not fully compatible with the C99 standard. It does not support the complex/_Complex keywords or variable-length arrays, both of which are optional C11 features. These are currently required for compilation. I plan to address these in upcoming PRs with the goal of removing the need for MSYS2/MinGW and addressing other issues summarized in #209 (comment).

Credit where it's due: I built upon the prior work of @brian-armstrong in https://github.com/quiet/quiet-dsp/tree/win as a guide for the general layout of my CMakeLists.txt. This PR can be considered a resurrection of his work for the latest version of liquid, albeit without MSVC support. See #102 and #209 (comment).

This PR supersedes #40 which has staled.

Current minimum version set to CMake 3.15 to take advantage of newer language
features. Alternative to using autotools. One-to-one port of configure.ac and
makefile.in to CMakeLists.txt + supporting CMake module files. Certain options
such as the default CFLAGS are left up to the CMake generator to determine
(e.g. If you want '-g -O2' then you do a RelWithDebInfo build). Handles the
required platform checks for generating config.h. Depends on the cpu_features
library (https://github.com/google/cpu_features) for detection of supported CPU
instruction sets. All main targets defined by makefile.in are supported. The
help target has been rebranded as list due to help being reserved by the CMake
Unix Makefile generator. The .gitignore has been updated to handle CMake
generated build files.

Note that not all generated executables currently write to the build folder,
but continue to be created in their expected locations within the source. This
is to ensure the correct results are output when running targets that depend
the autoscript generated xautotest/benchmark programs. Additionally, the
doc-check, examples, and sandbox executables are also still written to their
expected locations within the source.
- Add liquid_config target to replace global options
- Remove non-standard header checks for malloc.h and memory.h
- Add autotest byproducts lists to facilitate automatic cleanup
- Additionally, manually link libc to conform with original makefile.in
- Enable test target
- Add string replacement to doc-test source to correct header include
- Removed doc-test runtime output from source directory
- Fix sandbox and coverage targets for when their dependencies aren't met
- Fix liquid_linker_test to properly use installed library/header
- Add distclean target
@pfeatherstone
Copy link

You can use target_sources() rather than having variables for different source lists.

@lukeprince20
Copy link
Author

I used variables as I was closely following the layout of the makefile.in to ease comparison. I liked the aesthetic of keeping the library, autotest, and benchmark sources grouped together. I suppose I could have also taken an object library approach as well. I'm open to changing it now or later if it positively impacts the build. Currently, the compile commands produced by the build closely mirror those in the autotools generated makefile which was my main objective.

@pfeatherstone
Copy link

I would use cmake best practices rather than make it mirror autotools. Not saying you don't but may as well use the functions cmake provides out the box.

@pfeatherstone
Copy link

I would use https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html for options that depend on libraries like FFTW.

@pfeatherstone
Copy link

Should we not revive cmake support? It's way better than autotools, cross platform and you can integrate into other projects quite easily using FetchContent. @jgaeddert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants