-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add cmake support #27
base: master
Are you sure you want to change the base?
Conversation
bfb659a
to
cc40d09
Compare
Adds modern CMake support, allowing SheenBidi to be used as a subproject from a CMake project (e.g. via `FetchContent`).
Hey @glebm Thanks for taking the time to write cmake scripts. I'm not very much familiar with build systems, so I have a couple of questions:
|
It's a custom flag: option(ENABLE_INSTALL "Enable install targets" ON) is how you define an option and set it's description and default value. |
It's not needed for building the tester target, but it is used to automate running the tests during the GitHub Action: run: ctest --test-dir build --output-on-failure -j $(nproc) (last line in It's also useful for IDEs that support CMake to auto discover tests. |
It's a custom flag defined on line 5.
I've pushed a commit that does that. The oldest standard that CMake supports is
Unity and non-unity have different sources, so there have to be two targets. If we wanted to switch unity/non-unity based on a user-provided option, we could add an However, I'm not sure what the use-case for that would be. Currently, the unity target is the only target that is installed. (I also think in the future the unity target can be removed because all modern compilers support LTO but that can be a separate PR/discussion).
Currently,
CTest is the built-in CMake test tool. Like @AJenbo explains above, it handles tests in a uniform way.
There are 2 files in the cmake directory. The However, |
I've pushed a commit adding CMake documentation to the README.md, so you can see what it looks like from the perspective of the user or someone developing SheenBidi itself. |
@mta452 Visual Studio added support for CMake project in 2017 so this can also server as a replacement for Projects/VS_2017 in case you want to keep integrations to a minimum (I can help with adjusting I can also help you get coveralls working again using the GitHub action instead of Travis as a follow up to this. |
Added the "generator" target, so it can now also be built with CMake. It is also built in GitHub Actions. |
Must be the same as CMake namespace to use the standard package generation.
One problem with always forcing the standard to C89 is that stdlib headers may fail to parse if they require a newer C standard (for example on Amiga with libnix https://github.com/diasurgical/devilutionX/actions/runs/13100931473/job/36549084009) I've changed it to force C89 on CI but not by default. |
This is a library so the LTO decision should be left to the user.
Adds modern CMake support, allowing SheenBidi to be used as a subproject from a CMake project (e.g. via
FetchContent
), with support for installation, the test suite, and a GitHub Actions workflow.Fixes #26
Installation
Allows installing the library via CMake, which also installs CMake package definitions, enabling the use of
find_package(SheenBidi)
:cmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE=Release cmake --build build-rel -j $(getconf _NPROCESSORS_ONLN) sudo cmake --install build-rel
Additionally, this also allows testing via CMake and adds a GitHub Actions workflow.
Testing
Enables sanitizers in Debug build by default. Sanitizers run in the test suite and can catch undefined behaviour and memory errors.
The test suite can be run via CTest (the CMake test runner):
GitHub Actions
A GitHub Action builds all targets and runs the tests on Linux and macOS.
/cc @BLooperZ @AJenbo