Skip to content

Commit 55c28f6

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 19fdc38 + d41bb7a commit 55c28f6

File tree

4 files changed

+113
-21
lines changed

4 files changed

+113
-21
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: C/C++ CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
# Linux Job
15+
linux:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
include:
20+
- api: jack
21+
APIcmake: JACK
22+
deps: libjack-dev
23+
- api: alsa
24+
APIcmake: ALSA
25+
deps: libasound-dev
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- name: Install dependencies
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y build-essential cmake autoconf-archive ${{ matrix.deps }}
34+
- name: Build with CMake (Linux)
35+
run: |
36+
mkdir -p build
37+
cd build
38+
cmake .. -DCMAKE_BUILD_TYPE=Release -DRTMIDI_API_JACK=OFF -DRTMIDI_API_ALSA=OFF -DRTMIDI_API_${{ matrix.APIcmake }}=ON
39+
cmake --build . --config Release
40+
41+
# macOS Job
42+
macos:
43+
runs-on: macos-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
- name: Install dependencies (macOS)
49+
run: |
50+
brew install cmake autoconf-archive automake
51+
- name: Build with CMake (macOS)
52+
run: |
53+
mkdir -p build
54+
cd build
55+
cmake .. -DCMAKE_BUILD_TYPE=Release
56+
cmake --build . --config Release

CMakeLists.txt

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
# ----------------------------------
2-
# Project
3-
# ----------------------------------
41
cmake_minimum_required(VERSION 3.17)
5-
project(cpp-pinyin VERSION 1.0.0.0 LANGUAGES CXX)
2+
project(cpp-pinyin VERSION 1.0.1 LANGUAGES CXX)
63

74
set(CMAKE_CXX_STANDARD 17)
85

@@ -44,7 +41,7 @@ if (CPP_PINYIN_INSTALL)
4441
include(CMakePackageConfigHelpers)
4542
endif ()
4643
# ----------------------------------
47-
# Main Project
44+
# Project sources and targets
4845
# ----------------------------------
4946
file(GLOB_RECURSE _src include/*.h src/*.h src/*.cpp src/*/*.h src/*/*.cpp)
5047

@@ -65,17 +62,17 @@ if (CPP_PINYIN_BUILD_TESTS)
6562
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
6663
COMMAND
6764
${CMAKE_COMMAND} -E copy_directory
68-
${CMAKE_CURRENT_SOURCE_DIR}/res/${dict}
69-
${CMAKE_BINARY_DIR}/tests/${dict}
65+
${CMAKE_CURRENT_SOURCE_DIR}/res/dict
66+
${CMAKE_BINARY_DIR}/tests/dict
7067
)
7168
install(
72-
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/${dict}
69+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/dict
7370
DESTINATION .
7471
)
7572
endif ()
7673

7774
# ----------------------------------
78-
# Add platform specific
75+
# Add platform-specific settings
7976
# ----------------------------------
8077
if (WIN32)
8178
set(RC_DESCRIPTION "A lightweight Chinese/Cantonese to Pinyin library.")
@@ -84,25 +81,25 @@ if (WIN32)
8481
endif ()
8582

8683
# ----------------------------------
87-
# link libraries
84+
# Link libraries
8885
# ----------------------------------
8986
target_include_directories(${PROJECT_NAME} PRIVATE include src src/toneUtil)
9087
target_include_directories(${PROJECT_NAME} PUBLIC
9188
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
9289
)
9390

9491
# ----------------------------------
95-
# copy dictionary
92+
# Copy dictionary files
9693
# ----------------------------------
9794
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
9895
COMMAND
9996
${CMAKE_COMMAND} -E copy_directory
100-
${CMAKE_CURRENT_SOURCE_DIR}/res/${dict}
101-
${CMAKE_BINARY_DIR}/bin/${dict}
97+
${CMAKE_CURRENT_SOURCE_DIR}/res/dict
98+
${CMAKE_BINARY_DIR}/bin/dict
10299
)
103100

104101
# ----------------------------------
105-
# install
102+
# Install settings
106103
# ----------------------------------
107104
if (CPP_PINYIN_INSTALL)
108105
target_include_directories(${PROJECT_NAME} PUBLIC
@@ -146,15 +143,35 @@ if (CPP_PINYIN_INSTALL)
146143
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
147144
)
148145

149-
if (NOT DEFINED VCPKG_DICT_DIR)
146+
if (NOT DEFINED CPP_PINYIN_VCPKG_DICT_DIR)
147+
set(dictdir ${CMAKE_INSTALL_LIBDIR}/dict)
150148
install(
151-
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/${dict}
149+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/dict
152150
DESTINATION ${CMAKE_INSTALL_LIBDIR}
153151
)
154152
else ()
153+
set(dictdir ${CPP_PINYIN_VCPKG_DICT_DIR}/dict)
155154
install(
156-
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/${dict}
157-
DESTINATION ${VCPKG_DICT_DIR}
155+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/dict
156+
DESTINATION ${CPP_PINYIN_VCPKG_DICT_DIR}
158157
)
159158
endif ()
160-
endif ()
159+
endif ()
160+
161+
# ----------------------------------
162+
# Package config (.pc file) generation
163+
# ----------------------------------
164+
set(version ${PROJECT_VERSION})
165+
166+
# Configure the .pc file
167+
configure_file(
168+
${CMAKE_CURRENT_LIST_DIR}/cpp-pinyin.pc.in
169+
${CMAKE_BINARY_DIR}/cpp-pinyin.pc
170+
@ONLY
171+
)
172+
173+
# Install the .pc file
174+
install(
175+
FILES ${CMAKE_BINARY_DIR}/cpp-pinyin.pc
176+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
177+
)

cmake/winrc.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ set(_rc_content "#include <windows.h>
88
#define STRINGIFY(x) _STRINGIFY(x)
99
1010
VS_VERSION_INFO VERSIONINFO
11-
FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},${PROJECT_VERSION_TWEAK}
12-
PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},${PROJECT_VERSION_TWEAK}
11+
FILEVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH}
12+
PRODUCTVERSION ${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH}
1313
{
1414
BLOCK \"StringFileInfo\"
1515
{

cpp-pinyin.pc.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
prefix=${pcfiledir}/../..
2+
3+
# cpp-pinyin pkg-config file
4+
5+
exec_prefix=${prefix}/bin
6+
libdir=${prefix}/lib
7+
includedir=${prefix}/include
8+
9+
dictdir=${prefix}/share/cpp-pinyin/dict
10+
11+
Name: cpp-pinyin
12+
Description: A lightweight Chinese/Cantonese to Pinyin library.
13+
Version: @version@
14+
Requires:
15+
Conflicts:
16+
17+
Cflags: -I${includedir}
18+
Libs: -L${libdir} -lcpp-pinyin
19+

0 commit comments

Comments
 (0)