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

Recommend using Ninja to build fcitx5-mcbopomofo #96

Open
xatier opened this issue Dec 11, 2023 · 1 comment
Open

Recommend using Ninja to build fcitx5-mcbopomofo #96

xatier opened this issue Dec 11, 2023 · 1 comment

Comments

@xatier
Copy link
Contributor

xatier commented Dec 11, 2023

I wonder if we would like to recommend using ninja to build the project.

To enable ninja, simply add -G Ninja to the CMake command.

cmake ../ -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DENABLE_CLANG_TIDY=On
cmake --build .
# or just `ninja`

I observed a ~2x boost on my system ( Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz)

# ninja uses $(nproc) +2 jobs by default
$ nproc 
16

$ time ninja
[40/40] Linking CXX shared module src/mcbopomofo.so

real    0m22.833s
user    2m46.923s
sys     0m4.956s
$ time make -j 18
...
[100%] Built target mcbopomofo

real    0m48.043s
user    2m9.943s
sys     0m4.526s
@xatier
Copy link
Contributor Author

xatier commented Dec 21, 2023

One can create CMakeUserPresets.json file with cmake presets

CMakeUserPresets.json:

{
    "version": 8,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 28,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "release",
            "displayName": "Release",
            "description": "Release build with Ninja",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build/",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "/usr",
                "CMAKE_BUILD_TYPE": "Release",
                "ENABLE_CLANG_TIDY": "On"
            }
        },
        {
            "name": "debug",
            "displayName": "Debug",
            "description": "Debug build with Ninja",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build/",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "/usr",
                "CMAKE_BUILD_TYPE": "Debug",
                "ENABLE_CLANG_TIDY": "On"
            }
        }
    ]
}

This will simplify the commands for developers:

$ cmake ../ --preset release
$ ninja

$ cmake ../ --preset debug
ninja && ninja test

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

No branches or pull requests

1 participant