Skip to content

Commit

Permalink
Migrate to CMake (#9)
Browse files Browse the repository at this point in the history
* Migrate to CMake

* Update gh workflow
  • Loading branch information
anoopmsivadas authored Jul 16, 2024
1 parent 496c25d commit 7a73125
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 140 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/cmake_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CMake Build and Test
on:
push:
branches: [main]
paths:
- "**.cpp"
- "**.h"
- "**CMakeLists.txt"
pull_request:
branches: [main]
paths:
- "**.cpp"
- "**.h"
- "**CMakeLists.txt"

jobs:
build:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.16
- name: Install Fcitx5 dev packages
run: sudo apt install -y fcitx5-modules-dev
- name: Build and install Varnam
run: |
cd ../
git clone https://github.com/varnamproject/govarnam.git govarnam
cd govarnam
make
sudo make install
- name: Install Cmake
run: sudo apt install -y cmake extra-cmake-modules pkgconf
- name: Checkout code
uses: actions/checkout@v4
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure Project
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=/usr
-DVARNAM_DEBUG=ON
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Debug
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config Debug
55 changes: 0 additions & 55 deletions .github/workflows/meson_cpp.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@

build/
builddir/
**/Testing/

*.so
*.o
*.a

**/varnamfcitx-addon.conf
**/CMakeLists.txt
**/CMakeCache.txt
**/meson.build
CMakeFiles/
meson_options.txt
meson.options

compile_commands.json
.cache/
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.25)

project(fcitx5-varnam VERSION 0.0.2)

find_package(ECM REQUIRED 1.0.0 REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

include(FeatureSummary)
include(GNUInstallDirs)
include(ECMUninstallTarget)

find_package(Fcitx5Core 5.0.2 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(varnam "govarnam" IMPORTED_TARGET REQUIRED)

include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
add_definitions(-DFCITX_GETTEXT_DOMAIN=\"fcitx5-varnam\" -D_GNU_SOURCE)
fcitx5_add_i18n_definition()

option(VARNAM_DEBUG "Enable debug logs" OFF)

add_subdirectory(src)
add_subdirectory(icons)

install(FILES "com.varnamproject.Fcitx5.Addon.varnamfcitx.metainfo.xml.in"
RENAME com.varnamproject.Fcitx5.Addon.varnamfcitx.metainfo.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A wrapper to add Varnam Input Method Engine support in Fcitx5 Input Method.
## Dependencies

* [Meson](https://github.com/mesonbuild/meson)
* [CMake](https://cmake.org/)
* A c++ compiler that supports c++17 standard.
* [Varnam](https://github.com/varnamproject/govarnam)
* [Fcitx5](https://github.com/fcitx/fcitx5)
Expand All @@ -30,35 +30,47 @@ Install `fcitx5-modules-dev` if you're building it on a debian based distributio
```bash
git clone https://github.com/varnamproject/varnam-fcitx5.git
cd varnam-fcitx5
meson setup builddir
cd builddir
meson compile
sudo meson install
cmake -B build/ -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -S .
cmake --build build/ --config Release
sudo cmake --install build/ --config Release
```

To enable debug logs set `varnam_debug` to `true` by using the following command, before compiling the project.
or

```bash
meson configure -Dvarnam_debug=true
git clone https://github.com/varnamproject/varnam-fcitx5.git
cd varnam-fcitx5
cmake -B build/ -DCMAKE_INSTALL_PREFIX=/usr
cd build && make -j4
sudo make install
```
CMake supports multiple build system generators including [Ninja](https://ninja-build.org/). Commands could change based on the generator you use.


If meson version is less than `1.1` run the following command before `meson setup`.
To enable debug logs, configure the project with `-DVARNAM_DEBUG=ON` option.

```bash
mv meson.options meson_options.txt
cmake -B build/ -DVARNAM_DEBUG=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
```


### Uninstall

```
cd build
sudo make uninstall
```
or

```
cd buildir
cd build
sudo ninja uninstall
```
---

[![Packaging status](https://repology.org/badge/vertical-allrepos/varnam-fcitx5.svg)](https://repology.org/project/varnam-fcitx5/versions)

* Thank you [@mohammedbilalns](https://github.com/mohammedbilalns) for the Arch Linux Package([AUR](https://aur.archlinux.org/packages/varnam-fcitx5-git))
* [AUR Package](https://aur.archlinux.org/packages/varnam-fcitx5-git) by [@mohammedbilalns](https://github.com/mohammedbilalns)
* [Varnam Nix Flake](https://github.com/adtya/varnam-nix) by [@Adtya](https://github.com/adtya)
## Configuration

Varnam Fcitx can be configured using `fcitx5-configtool`. Please refer the [official documentation](https://fcitx-im.org/wiki/Configtool_(Fcitx_5)).
Expand Down
1 change: 1 addition & 0 deletions com.varnamproject.Fcitx5.Addon.varnamfcitx.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<project_group>Fcitx</project_group>
<releases>
<release version="0.0.1" date="2024-07-07"/>
<release version="0.0.2" date="2024-07-16"/>
</releases>
</component>
3 changes: 3 additions & 0 deletions icons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
install(DIRECTORY 48x48 DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor"
PATTERN .* EXCLUDE
PATTERN *~ EXCLUDE)
4 changes: 0 additions & 4 deletions icons/meson.build

This file was deleted.

35 changes: 0 additions & 35 deletions meson.build

This file was deleted.

2 changes: 0 additions & 2 deletions meson.options

This file was deleted.

19 changes: 19 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(varnam_fcitx_sources
varnam_engine.cpp
varnam_state.cpp
varnam_candidate.cpp
varnam_utils.cpp
)

add_library(varnamfcitx MODULE ${varnam_fcitx_sources})
target_link_libraries(varnamfcitx Fcitx5::Core Fcitx5::Config PkgConfig::varnam)

if(VARNAM_DEBUG)
target_compile_definitions(varnamfcitx PRIVATE DEBUG_MODE)
endif()

install(TARGETS varnamfcitx DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")

configure_file(varnamfcitx-addon.conf.in varnamfcitx-addon.conf)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/varnamfcitx-addon.conf" RENAME varnamfcitx.conf DESTINATION "${FCITX_INSTALL_PKGDATADIR}/addon")
install(FILES "varnamfcitx.conf" DESTINATION "${FCITX_INSTALL_PKGDATADIR}/inputmethod")
29 changes: 0 additions & 29 deletions src/meson.build

This file was deleted.

2 changes: 1 addition & 1 deletion src/varnamfcitx-addon.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name=Varnam
Comment=Varnam Engine for Fcitx5
Category=InputMethod
Version=@version@
Version=@PROJECT_VERSION@
Library=libvarnamfcitx
Type=SharedLibrary
Configurable=True
Expand Down

0 comments on commit 7a73125

Please sign in to comment.