Installation¶
This guide explains how to build and install the HTTPServer library on your system so you can use it in other projects.
Installation Script¶
The project provides a dedicated script to handle the build and installation process: scripts/install_library.sh.
How to Use¶
To install the library to the default location (usually /usr/local), run:
./scripts/install_library.sh
Custom Installation Prefix¶
If you wish to install the library to a specific directory, you can pass the path as an argument to the script:
./scripts/install_library.sh /path/to/custom/location
What the Script Does¶
Build Configuration: It creates a clean build directory (
build_install) and configures the project using CMake inReleasemode.Optimized Build: It disables the build of tests and the example application (
BUILD_TESTING=OFFandBUILD_SERVER_APP=OFF) to ensure a fast, library-only installation.Cross-platform Support: It automatically detects the number of CPU cores to perform a parallel build.
Sudo Handling: If the installation prefix is not writable by the current user, it will automatically prompt for
sudoto perform the installation.
Using the Installed Library¶
Once installed, you can use the library in your own C++ projects.
CMake Integration¶
The library exports its targets, allowing you to use find_package() in your CMakeLists.txt:
find_package(HttpServer REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE HttpServer::httpserver_lib)
Including Headers¶
The easiest way to use the library is via the umbrella header:
#include <httpserver>
You can also include specific module headers if needed:
#include <httpserver_impl/core/server.h>
#include <httpserver_impl/http/http_parser.h>
// ... your code ...