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

Another C++ conversion attempt #30

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
blocks: -DUNICODE_BLOCKS=/usr/share/unicode/Blocks.txt
install_packages: >
sudo apt update &&
sudo apt install cmake gettext libcairo2-dev libglib2.0-dev libfreetype6-dev libpango1.0-dev ninja-build pkg-config unicode-data
sudo apt install cmake gettext libcairo2-dev libcairomm-1.0-dev libglib2.0-dev libfmt-dev libfreetype6-dev libpango1.0-dev libpangomm-1.4-dev ninja-build pkg-config unicode-data
- os: macos-latest
env:
- CMAKE_PREFIX_PATH: /usr/local/opt/gettext
install_packages: >
brew update &&
brew install cairo cmake fontconfig freetype gettext glib pango ninja pkg-config
brew install cairo cairomm cmake fmt fontconfig freetype gettext glib pango pangomm ninja pkg-config

runs-on: ${{matrix.os}}

Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ project(fntsample
VERSION 5.4
DESCRIPTION "PDF and PostScript font samples generator"
HOMEPAGE_URL "https://github.com/eugmes/fntsample"
LANGUAGES C)
LANGUAGES CXX)

set(CMAKE_C_STANDARD 99 CACHE STRING "The C standard to use")
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use")
set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")

Expand All @@ -16,6 +16,7 @@ include(CPack)

find_package(PkgConfig REQUIRED)
find_package(Intl REQUIRED)
find_package(fmt REQUIRED)

# The target was added in CMake 3.20.
if(NOT TARGET Intl::Intl)
Expand All @@ -33,6 +34,10 @@ pkg_check_modules(pkgs REQUIRED IMPORTED_TARGET
pangoft2>=1.37.0
)

# FIXME: this is ugly
pkg_search_module(cairomm REQUIRED IMPORTED_TARGET cairomm cairomm-1.16 cairomm-1.0)
pkg_search_module(pangomm REQUIRED IMPORTED_TARGET pangomm pangomm-2.48 pangomm-1.4)

include(DownloadUnicodeBlocks)

download_unicode_blocks()
Expand Down
29 changes: 14 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,45 @@ configure_file(fntsample.1.in fntsample.1 @ONLY)

set(
C_WARNING_FLAGS
-Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
-Wcast-align -Wchar-subscripts
-Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
-Wmissing-format-attribute -fno-common -Wundef
CACHE STRING "Warning flags for C compiler"
)

add_executable(gen-unicode-blocks EXCLUDE_FROM_ALL
gen_unicode_blocks.c
read_blocks.c
gen_unicode_blocks.cpp
unicode_blocks.cpp
loadable_unicode_blocks.cpp
)

target_link_libraries(gen-unicode-blocks PRIVATE fmt::fmt)

target_compile_options(gen-unicode-blocks PRIVATE ${C_WARNING_FLAGS})

add_custom_command(
OUTPUT static_unicode_blocks.c
COMMAND gen-unicode-blocks "${UNICODE_BLOCKS}" static_unicode_blocks.c
OUTPUT static_unicode_blocks.cpp
COMMAND gen-unicode-blocks "${UNICODE_BLOCKS}" static_unicode_blocks.cpp
MAIN_DEPENDENCY "${UNICODE_BLOCKS}"
DEPENDS gen-unicode-blocks
VERBATIM
)

add_executable(fntsample
fntsample.c
read_blocks.c
${CMAKE_CURRENT_BINARY_DIR}/static_unicode_blocks.c
fntsample.cpp
unicode_blocks.cpp
loadable_unicode_blocks.cpp
${CMAKE_CURRENT_BINARY_DIR}/static_unicode_blocks.cpp
)

add_translatable_sources(fntsample.c read_blocks.c)
add_translatable_sources(fntsample.cpp unicode_blocks.cpp loadable_unicode_blocks.cpp)

target_include_directories(fntsample PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(fntsample PRIVATE Intl::Intl PkgConfig::pkgs)

find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(fntsample PRIVATE ${MATH_LIBRARY})
endif()
target_link_libraries(fntsample PRIVATE Intl::Intl PkgConfig::pkgs fmt::fmt PkgConfig::cairomm PkgConfig::pangomm)

target_compile_options(fntsample PRIVATE ${C_WARNING_FLAGS})

Expand Down
Loading