diff --git a/CMakeLists.txt b/CMakeLists.txt index 77f4877272..335dddfcd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project("vtm" CXX) # project("term") # project("calc") +set(CMAKE_POLICY_VERSION_MINIMUM "3.5" CACHE STRING "" FORCE) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -29,16 +30,70 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") target_compile_options(vtm PRIVATE -fconstexpr-loop-limit=100000000) endif() -find_package(Freetype 2.13.2 QUIET) -find_package(harfbuzz REQUIRED) -find_package(Lua 5.4 REQUIRED) -find_package(lunasvg QUIET) -find_package(Stb QUIET) +find_package(Freetype CONFIG QUIET) +find_package(harfbuzz CONFIG QUIET) +find_package(lunasvg QUIET) +find_package(Stb QUIET) -if(Freetype_FOUND) +if(NOT Freetype_FOUND) + find_package(Freetype 2.13.2 QUIET) +endif() +if(NOT harfbuzz_FOUND) + find_package(harfbuzz 12.2.0 QUIET) +endif() +if(WIN32 OR VCPKG_TOOLCHAIN) + message(STATUS "Windows/vcpkg environment detected. Using built-in Lua target.") + find_package(Lua 5.4 REQUIRED) + set(Lua_FOUND TRUE) +else() + find_package(Lua 5.4 QUIET) +endif() + +if(Lua_FOUND) + message(STATUS "Suitable Lua found via find_package: ${LUA_VERSION_STRING}") + if(NOT TARGET Lua::Lua) + add_library(Lua::Lua INTERFACE IMPORTED) + set_target_properties(Lua::Lua PROPERTIES INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}") + set(LUA_INCLUDE_DIR "${LUA_INCLUDE_DIR}") + endif() +else() + message(STATUS "Lua 5.4 NOT found in the system. Downloading clean source from lua.org...") + if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) + endif() + FetchContent_Declare(lua_source + URL https://www.lua.org/ftp/lua-5.4.8.tar.gz + URL_HASH SHA256=4f18ddae154e793e46eeab727c59ef1c0c0c2b744e7b94219710d76f530629ae + SOURCE_SUBDIR "DONOTEXIST") + FetchContent_MakeAvailable(lua_source) + set(LUA_CUSTOM_CMAKE "${lua_source_BINARY_DIR}/CMakeLists.txt") + file(WRITE "${LUA_CUSTOM_CMAKE}" [====[ + cmake_minimum_required(VERSION 3.22) + project(lua C) + file(GLOB LUA_CORE_SRC "src/*.c") + list(REMOVE_ITEM LUA_CORE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/lua.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/luac.c") + add_library(lua STATIC ${LUA_CORE_SRC}) + target_include_directories(lua PUBLIC src) + target_compile_definitions(lua PRIVATE LUA_USE_DLOPEN=0 LUA_DL_DLL=0 LUA_DL_DLOPEN=0) + ]====]) + file(COPY "${LUA_CUSTOM_CMAKE}" DESTINATION "${lua_source_SOURCE_DIR}") + add_subdirectory("${lua_source_SOURCE_DIR}" "${lua_source_BINARY_DIR}") + + if(NOT TARGET Lua::Lua) + add_library(Lua::Lua ALIAS lua) + endif() + set(LUA_INCLUDE_DIR "${lua_source_SOURCE_DIR}/src") +endif() + +if(Freetype_FOUND AND harfbuzz_FOUND) message(STATUS "Suitable FreeType found via find_package: ${FREETYPE_VERSION_STRING}") + message(STATUS "Suitable HarfBuzz found via find_package: ${harfbuzz_VERSION}") else() - message(STATUS "Suitable FreeType NOT found (min 2.13.2 required). Downloading via FetchContent...") + message(STATUS "FreeType or HarfBuzz not found/outdated (FT 2.13.2 and HB 12.2.0 required). Downloading both via FetchContent...") + + unset(Freetype_FOUND CACHE) + unset(harfbuzz_FOUND CACHE) + set(FT_WITH_ZLIB OFF CACHE BOOL "" FORCE) set(FT_WITH_BZIP2 OFF CACHE BOOL "" FORCE) set(FT_WITH_PNG OFF CACHE BOOL "" FORCE) @@ -50,8 +105,27 @@ else() if(NOT TARGET Freetype::Freetype) add_library(Freetype::Freetype ALIAS freetype) endif() - set(FREETYPE_INCLUDE_DIRS "${freetype_SOURCE_DIR}/include" - "${freetype_BINARY_DIR}/include") + + set(HB_HAVE_FREETYPE ON CACHE BOOL "" FORCE) + set(HB_BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(HB_BUILD_UTILS OFF CACHE BOOL "" FORCE) + set(HB_HAVE_GOBJECT OFF CACHE BOOL "" FORCE) + set(HB_HAVE_INTROSPECTION OFF CACHE BOOL "" FORCE) + set(HB_BUILD_DOCS OFF CACHE BOOL "" FORCE) + set(HB_BUILD_SUBSET OFF CACHE BOOL "" FORCE) + set(Freetype_DIR "${freetype_BINARY_DIR}" CACHE PATH "" FORCE) + set(FREETYPE_INCLUDE_DIR_ft2build "${freetype_SOURCE_DIR}/include" CACHE PATH "" FORCE) + set(FREETYPE_INCLUDE_DIR_freetype2 "${freetype_SOURCE_DIR}/include" CACHE PATH "" FORCE) + FetchContent_Declare(harfbuzz + GIT_REPOSITORY https://github.com/harfbuzz/harfbuzz.git + GIT_TAG 12.2.0) + FetchContent_MakeAvailable(harfbuzz) + if(NOT TARGET harfbuzz::harfbuzz) + add_library(harfbuzz::harfbuzz ALIAS harfbuzz) + endif() + + set(FREETYPE_INCLUDE_DIRS "${freetype_SOURCE_DIR}/include" "${freetype_BINARY_DIR}/include") + set(HARFBUZZ_INCLUDE_DIRS "${harfbuzz_SOURCE_DIR}/src" "${harfbuzz_BINARY_DIR}/src") endif() if(lunasvg_FOUND) @@ -88,9 +162,6 @@ else() add_library(stb::stb ALIAS stb_interface) endif() -add_library(Lua::Lua INTERFACE IMPORTED) -set_target_properties(Lua::Lua PROPERTIES INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}") - target_include_directories(vtm PRIVATE ${FREETYPE_INCLUDE_DIRS} ${HARFBUZZ_INCLUDE_DIRS} ${LUA_INCLUDE_DIR}) diff --git a/doc/build.md b/doc/build.md index bff467b5c3..e194353f2f 100644 --- a/doc/build.md +++ b/doc/build.md @@ -4,29 +4,40 @@ ### Unix -Build-time dependencies - - `C++20 compiler`: [GCC 12](https://gcc.gnu.org/projects/cxx-status.html) or [Clang 16](https://clang.llvm.org/cxx_status.html) - - `cmake` (minimum version v3.22) - - `git` - - `FreeType` (minimum version v2.13.2, will be fetched automatically via CMake if not found) - - `HarfBuzz` - - `Lua` (minimum version v5.4) - - `LunaSVG` (Will be built automatically from source via CMake if not found in the system) - - `stb` (Will be fetched automatically via CMake if not found) - -Examples of installing dependencies: - -OS | Dependency installation command | Notes ---------|---------------------------------|------ -Linux | `sudo apt install libfreetype-dev libharfbuzz-dev liblua5.4-dev git cmake` | `stb` and `LunaSVG` are managed automatically during CMake configuration. -FreeBSD | `pkg install freetype2 harfbuzz lua54 cmake` | Best results with GCC compiler and 6GB of RAM. -MacOS | `brew install freetype harfbuzz lua cmake` - -Use any terminal as a build environment +#### Required System Dependencies -``` +- `C++20 compiler`: [GCC 12+](https://gcc.gnu.org/projects/cxx-status.html) or [Clang 16+](https://clang.llvm.org/cxx_status.html) +- `CMake` (minimum version v3.22) +- `Git` + +#### Optional Dependencies + +The following libraries are required but will be automatically downloaded and built via CMake if they are missing or outdated in your system: +- `FreeType` (minimum version v2.13.2) +- `HarfBuzz` (minimum version v12.2.0) +- `LunaSVG` (minimum version v3.5.0) +- `Lua` (minimum version v5.4) +- `stb` + +#### Examples of installing system dependencies: + +OS | Dependency installation command | Notes +-----------------------|----------------------------------------------|------ + Linux (Ubuntu/Debian) | `sudo apt install git cmake build-essential` | + FreeBSD | `pkg install lua54 cmake git` | Best results with GCC compiler and 6GB of RAM. + macOS | `brew install lua cmake git` | + +#### Build Steps + +Run the following commands in your terminal: + +```bash git clone https://github.com/directvt/vtm.git cd vtm + +# Specify the required compiler if needed: +# export CXX=/usr/bin/g++-12 + cmake . -B bin cmake --build bin sudo cmake --install bin @@ -34,17 +45,18 @@ vtm ``` > Installation Note: -> - By default, files are installed to system directories (e.g., `/usr/local/bin/`). If you want to install vtm to a user directory without using sudo (e.g., `$HOME/.local/`; ensure that this directory is added to your $PATH), use the `CMAKE_INSTALL_PREFIX` flag during the cmake configuration step: -> ```bash -> cmake . -B bin -DCMAKE_INSTALL_PREFIX=$HOME/.local -> cmake --build bin -> cmake --install bin -> ``` +> - By default, files are installed to system directories (e.g., `/usr/local/bin/`). If you want to install `vtm` to a user directory without using `sudo` (e.g., `$HOME/.local/bin/`), specify the `CMAKE_INSTALL_PREFIX` flag during the configuration step. Ensure that this directory is added to your `$PATH`: +> ```bash +> cmake . -B bin -DCMAKE_INSTALL_PREFIX=\$HOME/.local +> cmake --build bin +> cmake --install bin +> ``` ### Windows -Build-time dependencies - - [MSVC](https://visualstudio.microsoft.com/downloads/) +#### Build-time Dependencies + + - [`Visual Studio 2022`](https://visualstudio.microsoft.com/downloads/) with the following workloads enabled: - Desktop Development with C++ - C++ CMake tools for Windows - Git for Windows @@ -56,4 +68,9 @@ Build-time dependencies - `LunaSVG` - `stb` -To manually compile vtm, launch Visual Studio and clone the repository https://github.com/directvt/vtm.git, after cloning is complete, double-click on the Folder View in Solution Explorer, wait for the dependencies to initialize (may take several minutes), select the required configuration on the top menu toolbar, and click the `Build All` menu button. \ No newline at end of file +#### Build Steps + +- Launch Visual Studio and clone the repository: `https://github.com/directvt/vtm`. +- Wait for the CMake generation and dependencies initialization to complete (this may take several minutes). +- Select your target build configuration (e.g., `1.Win-x64-Debug` or `PROD-Win-x64`) from the top toolbar configuration dropdown. +- Open the `Build` menu and click `Build All`. diff --git a/src/netxs/desktopio/application.hpp b/src/netxs/desktopio/application.hpp index 189dbb06c7..05e028c8c0 100644 --- a/src/netxs/desktopio/application.hpp +++ b/src/netxs/desktopio/application.hpp @@ -22,7 +22,7 @@ namespace netxs::app namespace netxs::app::shared { - static const auto version = "v2026.06.28"; + static const auto version = "v2026.06.29"; static const auto repository = "https://github.com/directvt/vtm"; static const auto usr_config = "~/.config/vtm/settings.xml"s; static const auto sys_config = "/etc/vtm/settings.xml"s;