Installation

Building from Source

Prerequisites

To build libserial from source, you’ll need:

  • CMake (version 3.10 or higher)

  • A C++17 compatible compiler (GCC 5.4+ or Clang 3.4+)

  • Git (for cloning the repository)

For documentation generation (optional):

  • Doxygen

  • Python 3.6+

  • Sphinx

  • sphinx-rtd-theme

  • breathe

Building the Library

  1. Clone the repository:

git clone https://github.com/NestorDP/cppserial.git
cd cppserial
  1. Create a build directory:

mkdir build
cd build
  1. Configure the build:

cmake ..
  1. Build the library:

make
  1. Install the library (optional):

sudo make install

Using CMake Options

You can customize the build with various CMake options:

# Build in Release mode (optimized)
cmake -DCMAKE_BUILD_TYPE=Release ..

# Install to a custom location
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..

# Enable testing
cmake -DBUILD_TESTING=ON ..

# Enable coverage reports
cmake -DENABLE_COVERAGE=ON ..

# Enable documentation generation
cmake -DBUILD_DOCUMENTATION=ON ..

Verifying Installation

To verify that cppserial is installed correctly, create a simple test program:

#include <libserial/serial.hpp>
#include <iostream>

int main() {
    std::cout << "libserial is installed!" << std::endl;
    return 0;
}

Compile and run:

g++ -std=c++17 test.cpp -lserial -o test
./test