Skip to content

Commit 78bba46

Browse files
authored
Merge pull request #846 from o-sdn-o/gui-bridge
Revise the way dependencies are handled (harfbuzz freetype lua)
2 parents 45929de + 46d7efa commit 78bba46

File tree

10 files changed

+301
-462
lines changed

10 files changed

+301
-462
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,67 @@ jobs:
2323
include:
2424
- os: macos-latest
2525
platform: macos
26-
cpu: universal
27-
arch: any
26+
cpu: arm64
27+
arch: arm64
2828
cxx: c++
2929
cc: cc
30-
flags: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG -Wall -Wno-unknown-pragmas -Wextra -Wno-missing-field-initializers -Werror"'
30+
flags: '-DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG -Wall -Wextra -Wno-missing-field-initializers -Werror"'
31+
triplet: arm64-osx
32+
- os: macos-latest
33+
platform: macos
34+
cpu: x64
35+
arch: x86_64
36+
cxx: c++
37+
cc: cc
38+
flags: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG -Wall -Wextra -Wno-missing-field-initializers -Werror"'
39+
triplet: x64-osx
3140
- os: windows-latest
3241
platform: windows
3342
cpu: Win32
3443
arch: x86
3544
cxx: cl
3645
cc: cl
37-
flags: '-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="/DEBUG /OPT:REF /OPT:ICF" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /c" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /DNDEBUG /Zi /Zc:preprocessor /W4" -A '
46+
flags: '-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="/DEBUG /OPT:REF /OPT:ICF" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /DNDEBUG /Zi /Zc:preprocessor /W4 /EHsc /bigobj /utf-8 /Zc:preprocessor" -A '
47+
triplet: x86-windows-static
3848
- os: windows-latest
3949
cxx: cl
50+
- os: windows-latest
51+
cpu: x64
52+
triplet: x64-windows-static
53+
- os: windows-latest
54+
cpu: arm64
55+
triplet: arm64-windows-static
4056
- os: ubuntu-22.04
4157
cpu: x64
4258
apt: g++-12 gcc-12
4359
cxx: /usr/bin/g++-12
44-
cc: /usr/bin/gcc-12
60+
cc: /usr/bin/gcc-12
61+
triplet: x64-linux
4562
- os: ubuntu-22.04
4663
cpu: x86
4764
apt: g++-12-i686-linux-gnu gcc-12-i686-linux-gnu
4865
cxx: /usr/bin/i686-linux-gnu-g++-12
49-
cc: /usr/bin/i686-linux-gnu-gcc-12
66+
cc: /usr/bin/i686-linux-gnu-gcc-12
67+
triplet: x86-linux
5068
- os: ubuntu-22.04
5169
cpu: arm
52-
apt: g++-12-arm-linux-gnueabihf gcc-12-arm-linux-gnueabihf
70+
# vcpkg requires the stock compiler for some reason (not -12).
71+
apt: g++-12-arm-linux-gnueabihf gcc-12-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
5372
cxx: /usr/bin/arm-linux-gnueabihf-g++-12
54-
cc: /usr/bin/arm-linux-gnueabihf-gcc-12
73+
cc: /usr/bin/arm-linux-gnueabihf-gcc-12
74+
triplet: arm-linux
5575
- os: ubuntu-22.04
5676
cpu: arm64
57-
apt: g++-12-aarch64-linux-gnu gcc-12-aarch64-linux-gnu
77+
# vcpkg requires the stock compiler for some reason (not -12).
78+
apt: g++-12-aarch64-linux-gnu gcc-12-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
5879
cxx: /usr/bin/aarch64-linux-gnu-g++-12
59-
cc: /usr/bin/aarch64-linux-gnu-gcc-12
80+
cc: /usr/bin/aarch64-linux-gnu-gcc-12
81+
triplet: arm64-linux
6082

6183
- os: ubuntu-22.04
62-
# -Wno-array-bounds: harfbuzz on 32-bit platforms warning: offset '12' outside bounds of constant string [-Warray-bounds=].
63-
flags: '-DCMAKE_C_FLAGS="-O2 -static " -DCMAKE_CXX_FLAGS_RELEASE=" -static -s -O2 -DNDEBUG -Wall -Wno-array-bounds -Wno-unknown-pragmas -Wextra -Wno-missing-field-initializers -Wno-psabi -Werror"'
84+
flags: '-DCMAKE_CXX_FLAGS_RELEASE=" -static -s -DNDEBUG -Wall -Wextra -Wno-missing-field-initializers -Wno-psabi -Werror"'
6485
- os: windows-latest
65-
flags: '-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="/DEBUG /OPT:REF /OPT:ICF" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /c" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /DNDEBUG /Zi /Zc:preprocessor /W4" -A '
86+
flags: '-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="/DEBUG /OPT:REF /OPT:ICF" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /DNDEBUG /Zi /Zc:preprocessor /W4 /EHsc /bigobj /utf-8 /Zc:preprocessor" -A '
6687

6788
- os: ubuntu-22.04
6889
platform: linux
@@ -93,17 +114,33 @@ jobs:
93114
sudo apt -y update
94115
sudo apt -y install ${{ matrix.apt }}
95116
117+
- name: Clone and Bootstrap vcpkg (win32)
118+
if: matrix.os == 'windows-latest'
119+
run: |
120+
git clone https://github.com/microsoft/vcpkg.git ${{ github.workspace }}/vcpkg
121+
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat -disableMetrics
122+
123+
- name: Clone and Bootstrap vcpkg (ubuntu)
124+
if: matrix.os != 'windows-latest'
125+
run: |
126+
git clone https://github.com/microsoft/vcpkg.git ${{ github.workspace }}/vcpkg
127+
${{ github.workspace }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
128+
96129
- name: Configure CMake
130+
env:
131+
CC: ${{ matrix.cc }}
132+
CXX: ${{ matrix.cxx }}
133+
WIN32_RESOURCES: ${{ matrix.os == 'windows-latest' && '.resources/images/vtm.rc' || '' }}
97134
run: >
98135
cmake -B ${{ steps.strings.outputs.bin }}
99-
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
100-
-DCMAKE_C_COMPILER=${{ matrix.cc }}
136+
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
137+
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
101138
${{ matrix.flags }} ${{ matrix.os == 'windows-latest' && matrix.cpu || '' }}
102139
-DCMAKE_BUILD_TYPE=Release
103140
-S ${{ github.workspace }}
104141
105142
- name: Build
106-
run: cmake --build ${{ steps.strings.outputs.bin }} --config Release
143+
run: cmake --build ${{ steps.strings.outputs.bin }} --config Release -v
107144

108145
- name: Pack (POSIX)
109146
if: matrix.os != 'windows-latest'

CMakeLists.txt

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.22)
22
include(FetchContent)
33

4-
project("vtm")
4+
project("vtm" CXX)
55
# project("term")
66
# project("calc")
77

@@ -13,68 +13,28 @@ if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
1313
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
1414
endif()
1515

16-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") # WIN32 and similar checks are soft-deprecated
17-
# Disable manifest embedding for the windows builds.
18-
# Reason: Anti-virus program (Windows Defender) may lock and scan `vtm.exe` file before embedding the manifest.
19-
# mt.exe: general error c101008d: Failed to write the updated manifest to the resource of file...
20-
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
21-
# /EHsc Tells the compiler that exceptions can only occur at a throw statement or at a function call.
22-
# /bigobj Our event model spawns a large number of objects. By default, an object file can hold up to 65,279 (almost 2^16) addressable sections. This limit applies no matter which target platform is specified. /bigobj increases that address capacity to 4,294,967,296 (2^32).
23-
# /utf-8 All literals in our source code are in UTF-8 format.
24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /EHsc /bigobj /utf-8 /Zc:preprocessor")
25-
set(WIN32_RESOURCES ".resources/images/vtm.rc")
26-
else()
16+
if(NOT WIN32 AND "$ENV{LINUX_CXX_FLAGS}" STREQUAL "") # If CMakeSettings.json is not used (MS Visual Studio).
2717
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -pthread")
28-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -DLUA_USE_POSIX")
29-
# Static linkage
30-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -O2 -pthread")
31-
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -O2 -DLUA_USE_POSIX")
3218
endif()
3319

34-
add_executable(vtm "src/vtm.cpp" ${WIN32_RESOURCES})
20+
add_executable(vtm "src/vtm.cpp" $ENV{WIN32_RESOURCES})
3521
# add_executable(term "src/netxs/apps/term.cpp")
3622
# add_executable(calc "src/netxs/apps/calc.cpp")
3723

38-
# Set BUILD_SHARED_LIBS to OFF globally for fetched content.
39-
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries" FORCE)
24+
find_package(Freetype REQUIRED)
25+
find_package(harfbuzz REQUIRED)
26+
find_package(Lua REQUIRED)
4027

41-
# FreeType dependency
42-
set(FT_DISABLE_BROTLI ON CACHE BOOL "Disable brotli" FORCE)
43-
set(FT_DISABLE_ZLIB ON CACHE BOOL "Disable zlib" FORCE)
44-
set(FT_DISABLE_BZIP2 ON CACHE BOOL "Disable bzip2" FORCE)
45-
set(FT_DISABLE_PNG ON CACHE BOOL "Disable libpng" FORCE)
46-
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "Disable harfbuzz" FORCE)
47-
FetchContent_Declare(freetype
48-
GIT_REPOSITORY https://github.com/freetype/freetype.git
49-
GIT_TAG VER-2-14-1)
50-
FetchContent_MakeAvailable(freetype)
28+
add_library(Lua::Lua INTERFACE IMPORTED)
29+
set_target_properties(Lua::Lua PROPERTIES INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}")
5130

52-
# HarfBuzz dependency
53-
set(HB_NO_MT ON CACHE BOOL "Single threaded" FORCE)
54-
set(HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR ON CACHE BOOL "Disable pragma warning" FORCE)
55-
set(HB_HAVE_FREETYPE OFF CACHE BOOL "Disable freetype" FORCE)
56-
set(HB_HAVE_GLIB OFF CACHE BOOL "Disable glib" FORCE)
57-
set(HB_HAVE_GOBJECT OFF CACHE BOOL "Disable gobject" FORCE)
58-
set(HB_HAVE_ICU OFF CACHE BOOL "Disable icu" FORCE)
59-
set(HB_HAVE_CAIRO OFF CACHE BOOL "Disable cairo" FORCE)
60-
FetchContent_Declare(harfbuzz
61-
URL https://github.com/harfbuzz/harfbuzz/archive/refs/tags/12.1.0.tar.gz
62-
URL_HASH SHA256=0238bf7ada6b1fb92984f69f8b9cd66518af83cf24f7db1cfe60c772c42312d3)
63-
FetchContent_MakeAvailable(harfbuzz)
31+
target_include_directories(vtm PRIVATE ${FREETYPE_INCLUDE_DIRS}
32+
${HARFBUZZ_INCLUDE_DIRS}
33+
${LUA_INCLUDE_DIR})
6434

65-
# Lua dependency
66-
FetchContent_Declare(lua
67-
URL https://www.lua.org/ftp/lua-5.4.7.tar.gz
68-
URL_HASH SHA256=9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30)
69-
FetchContent_MakeAvailable(lua)
70-
file(GLOB lua_src CONFIGURE_DEPENDS ${lua_SOURCE_DIR}/src/*.c)
71-
list(REMOVE_ITEM lua_src ${lua_SOURCE_DIR}/src/lua.c ${lua_SOURCE_DIR}/src/luac.c)
72-
add_library(lua EXCLUDE_FROM_ALL ${lua_src})
73-
target_include_directories(vtm PRIVATE ${lua_SOURCE_DIR}/src)
74-
75-
target_link_libraries(vtm PRIVATE lua freetype harfbuzz)
76-
# target_link_libraries(term PRIVATE lua freetype harfbuzz)
77-
# target_link_libraries(calc PRIVATE lua freetype harfbuzz)
35+
target_link_libraries(vtm PRIVATE Lua::Lua Freetype::Freetype harfbuzz::harfbuzz)
36+
# target_link_libraries(term PRIVATE Lua::Lua Freetype::Freetype harfbuzz::harfbuzz)
37+
# target_link_libraries(calc PRIVATE Lua::Lua Freetype::Freetype harfbuzz::harfbuzz)
7838

7939
if(NOT WIN32)
8040
install(TARGETS vtm DESTINATION bin)

0 commit comments

Comments
 (0)