From 62d651fc6cb768f2b95c284938d96b29d81a03cb Mon Sep 17 00:00:00 2001 From: SEK1RO Date: Sun, 10 Nov 2024 19:49:13 +0300 Subject: [PATCH] feat(CMake): library only; update(README) --- .gitignore | 1 + CMakeLists.txt | 29 +++++++++++++++++++++++++++++ Makefile | 2 +- README.md | 29 ++++++++++++++++++++++++++--- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 3eba02e..d2deb1c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ WORKSPACE.bazel BUILD.bazel # Dirs +build bin obj lib diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1b1c744 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.21) +set(CMAKE_CXX_STANDARD 20) +project(libbasen + VERSION 1.1.1 + DESCRIPTION "c++20 encoding/decoding from arbitrary base" + LANGUAGES CXX +) + +set(CXX_FLAGS "-Wall -Wextra -Werror -Wno-unused-result -O3") + +set(OBJS + base58 + base64 + baseN + hex + Exception + hash/sha256 +) +set(SRCS) +foreach(OBJ ${OBJS}) + list(APPEND SRCS "src/${OBJ}.cpp") +endforeach() + +add_library(basen ${SRCS}) +add_library(basen::basen ALIAS basen) +target_include_directories(basen PUBLIC + $ + $ +) \ No newline at end of file diff --git a/Makefile b/Makefile index 866994d..4d09b91 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ ifeq (${origin CC}, default) CC = g++ endif -CFLAGS = -std=c++23 -Wall -Wextra -Werror -Wno-unused-result -fPIC +CFLAGS = -std=c++20 -Wall -Wextra -Werror -Wno-unused-result -fPIC ifneq (${DEBUG}, false) CFLAGS += -fsanitize=address,undefined -g -O0 diff --git a/README.md b/README.md index 67ef9f5..a1344ab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # libbasen -c++ encoding/decoding from arbitrary base +c++20 encoding/decoding from arbitrary base Packaging status @@ -12,17 +12,24 @@ c++ encoding/decoding from arbitrary base ## Contents - [Installation](#installation) + - [Package](#package) + - [Make](#make) + - [CMake](#cmake) - [Documentation](#documentation) - [Usage](#usage) - [Contributing](#contributing) ## Installation -Automatically from specified repositories: +### Package [![Packaging status](https://repology.org/badge/vertical-allrepos/libbasen.svg)](https://repology.org/project/libbasen/versions) -Manually using make: +### Make + +For cli tool you should have [argparse](https://github.com/p-ranav/argparse) as make dependency. + +Install: ``` make -j $(nproc) sudo make i USRDIR=(Your installation dir) @@ -32,6 +39,22 @@ Uninstall: sudo make uni USRDIR=(Your installation dir) ``` +### CMake + +For using as dependency only (without cli tool, test, coverage, docs) + +``` +include(FetchContent) +FetchContent_Declare( + basen + GIT_REPOSITORY https://github.com/vSEK1RO/libbasen.git + GIT_TAG latest +) +FetchContent_MakeAvailable(basen) + +target_link_libraries(MyProject PRIVATE basen::basen) +``` + ## Documentation Available [here](https://vsek1ro.github.io/libbasen)