cpp-utilities/README.md

105 lines
4.6 KiB
Markdown
Raw Normal View History

2016-06-11 18:53:26 +02:00
# C++ utilities
2015-04-22 18:24:43 +02:00
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities.
2015-05-19 22:33:12 +02:00
2016-02-17 20:20:37 +01:00
## Features
The library utilizes:
2016-07-04 23:53:56 +02:00
* parsing command-line arguments and providing Bash completion
2016-06-11 18:53:26 +02:00
* dealing with dates and times
* conversion of primitive data types to byte-buffers and vice versa (litte-endian and big-endian)
2016-02-17 20:20:37 +01:00
* common string conversions/operations, eg.
- character set conversion via iconv
2016-06-11 18:53:26 +02:00
- split, join, find and replace
- conversion from number to string and vice verca
- encoding/decoding base-64
- building string without multiple heap allocations (string builder)
2016-02-17 20:20:37 +01:00
* IO
- reading/writing primitive data types of various sizes (little-endian and big-endian)
2016-02-17 20:20:37 +01:00
- reading/writing terminated strings and size-prefixed strings
2016-06-11 18:53:26 +02:00
- reading/writing INI files
- reading bitwise
* building with CMake by providing some modules and templates
2016-02-17 20:20:37 +01:00
2015-05-19 22:33:12 +02:00
## Build instructions
2016-01-29 00:47:05 +01:00
### Requirements
#### Build-only dependencies
2017-02-05 19:19:15 +01:00
* C++ compiler supporting C++14, tested with
- GNU g++
- Clang
2016-11-21 20:39:01 +01:00
- mingw-w64 g++
- Cygwin g++
* CMake (at least 3.3.0)
* cppunit for unit tests (optional)
2016-06-11 18:53:26 +02:00
* Doxygen for API documentation (optional)
2016-07-04 23:53:56 +02:00
* Graphviz for diagrams in the API documentation (optional)
#### Runtime dependencies
* The c++utilities library itself only needs
2017-02-05 19:19:15 +01:00
- C/C++ standard library supporting C++14
- libiconv (might be part of glibc or provided as extra library)
* For dependencies of my other projects check the README.md of these projects.
2016-01-29 00:47:05 +01:00
### How to build
Just run:
```
cd "path/to/build/directory"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/final/install/location" "path/to/projectdirectory"
2016-01-29 00:47:05 +01:00
make
make check # build and run unit tests (optional)
2016-06-11 18:53:26 +02:00
make c++utilities_apidoc # build API documentation (optional)
make DESTDIR="/temporary/install/location" install
2015-05-19 22:33:12 +02:00
```
2016-01-29 00:47:05 +01:00
#### General notes
* Building with qmake is not supported anymore.
2016-07-04 23:53:56 +02:00
* The make option ```-j``` can be used for concurrent compilation.
* ```LIB_SUFFIX```, ```LIB_SUFFIX_32``` and ```LIB_SUFFIX_64``` can be set to
specify a suffix for the library directory, eg. lib*64* or lib*32*. The 32/64 variants are only used when building for 32/64-bit architecture.
* By default the build system will *build* shared libs. To *build* also static libraries, set `ENABLE_STATIC_LIBS=ON`. To disable building shared libs
set `DISABLE_SHARED_LIBS=ON`.
* By default the build system will prefer *linking against* shared libraries. To force *linking against* static libraries set `STATIC_LINKAGE=ON`.
However, this will only affect applications. To force linking statically when building shared libraries set `STATIC_LIBRARY_LINKAGE=ON`.
#### Building for Windows
2016-01-29 00:47:05 +01:00
Building for Windows with Mingw-w64 cross compiler can be utilized using a small
[cmake wrapper from Fedora](https://aur.archlinux.org/cgit/aur.git/tree/mingw-cmake.sh?h=mingw-w64-cmake):
2015-12-05 22:47:49 +01:00
```
2016-06-12 01:56:57 +02:00
${_arch}-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/final/install/location" "path/to/source/directory"
make DESTDIR="/temporary/install/location" install-mingw-w64-strip
2015-12-05 22:47:49 +01:00
```
* To create the \*.ico file for the application icon ffmpeg/avconv is required.
* The target ```install-mingw-w64-strip``` in the example will only install files
suitable for creating a cross-compiler package and additionally strip the binaries.
#### Development builds
During development I find it useful to build all required projects (for instace c++utilities, qtutilities, tagparser and tageditor) as one big project.
2016-07-04 23:53:56 +02:00
This can be easily achieved by using CMake's ```add_subdirectory()``` function. For project files
2016-11-21 20:39:01 +01:00
see the repository [subdirs](https://github.com/Martchus/subdirs). For an example, see
[build instructions for Syncthing Tray](https://github.com/Martchus/syncthingtray#building-this-straight).
2016-01-29 00:47:05 +01:00
For a debug build, just use ```-DCMAKE_BUILD_TYPE=Debug```.
2015-12-05 22:47:49 +01:00
2016-07-04 23:53:56 +02:00
#### Arch Linux package
The repository [PKGBUILDs](https://github.com/Martchus/PKGBUILDs) contains files
for building Arch Linux packages.
2016-11-18 18:31:48 +01:00
2016-01-29 00:47:05 +01:00
PKGBUILD files to build for Windows using the Mingw-w64 compiler are also included.
2015-12-05 22:47:49 +01:00
2016-11-18 18:31:48 +01:00
#### RPM packages
RPM \*.spec files can be found at [openSUSE Build Servide](https://build.opensuse.org/project/show/home:mkittler).
2016-11-21 20:39:01 +01:00
Those files have only been tested under Tumbleweed so far.
2016-11-18 18:31:48 +01:00
#### Gentoo
Packages are provided by perfect7gentleman; checkout his [repository](https://github.com/perfect7gentleman/pg_overlay).
2016-07-04 23:53:56 +02:00
2016-11-21 20:39:01 +01:00
#### Cygwin
Scripts to build with Cygwin are provided by svnpenn. Checkout his
[repository](https://github.com/svnpenn/glade).
2016-07-04 23:53:56 +02:00
### General notes
2016-06-14 22:53:19 +02:00
* There is a workaround for [GCC Bug 66145](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145) provided
in io/catchiofailure.h.
2016-01-18 23:41:30 +01:00
## TODO
- remove unused features