Tehreer / SheenBidi

A sophisticated implementation of Unicode Bidirectional Algorithm
Apache License 2.0
127 stars 21 forks source link

Add cmake support #27

Open glebm opened 5 days ago

glebm commented 5 days ago

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
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libsheenbidi.so
-- Installing: /usr/local/include/SheenBidi/SBAlgorithm.h
-- Installing: /usr/local/include/SheenBidi/SBBase.h
-- Installing: /usr/local/include/SheenBidi/SBBidiType.h
-- Installing: /usr/local/include/SheenBidi/SBCodepoint.h
-- Installing: /usr/local/include/SheenBidi/SBCodepointSequence.h
-- Installing: /usr/local/include/SheenBidi/SBGeneralCategory.h
-- Installing: /usr/local/include/SheenBidi/SBLine.h
-- Installing: /usr/local/include/SheenBidi/SBMirrorLocator.h
-- Installing: /usr/local/include/SheenBidi/SBParagraph.h
-- Installing: /usr/local/include/SheenBidi/SBRun.h
-- Installing: /usr/local/include/SheenBidi/SBScript.h
-- Installing: /usr/local/include/SheenBidi/SBScriptLocator.h
-- Installing: /usr/local/include/SheenBidi/SheenBidi.h
-- Installing: /usr/local/lib/cmake/SheenBidi/SheenBidiTargets.cmake
-- Installing: /usr/local/lib/cmake/SheenBidi/SheenBidiTargets-release.cmake
-- Installing: /usr/local/lib/cmake/SheenBidi/SheenBidiConfig.cmake
-- Installing: /usr/local/lib/cmake/SheenBidi/SheenBidiConfigVersion.cmake

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):

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j $(getconf _NPROCESSORS_ONLN) --target test
ctest --test-dir build --output-on-failure -j $(getconf _NPROCESSORS_ONLN)
Internal ctest changing into directory: /home/gleb/SheenBidi/build
Test project /home/gleb/SheenBidi/build
    Start 1: tests
1/1 Test #1: tests ............................   Passed   17.07 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =  17.07 sec

GitHub Actions

A GitHub Action builds all targets and runs the tests.

/cc @BLooperZ @AJenbo