babelouest / ulfius

Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
https://babelouest.github.io/ulfius
GNU Lesser General Public License v2.1
1.07k stars 183 forks source link

cmake: think in CMake targets #242

Closed madebr closed 1 year ago

madebr commented 1 year ago

After this pr, an install prefix looks as the tree below. The reason for installing FindXXXX.cmake for GnuTLS, Jansson and libmicrohttpd is that there exists no "official" CMake support for these.

With this pr, users can include ulfius in their project by doing:

cmake_minimum_required(VERSION 3.0)
project(my_app C)
find_package(Ulfius REQUIRED)
add_executable(my_app my_app.c)
target_link_libraries(my_app PRIVATE Ulfius::Ulfius)
add_executable(my_app-static my_app.c)
target_link_libraries(my_app-static PRIVATE Ulfius::Ulfius-static)
prefix
├── bin
│   └── uwsc
├── include
│   ├── ulfius-cfg.h
│   └── ulfius.h
├── lib64
│   ├── cmake
│   │   └── Ulfius
│   │       ├── FindGnuTLS.cmake
│   │       ├── FindJansson.cmake
│   │       ├── FindMHD.cmake
│   │       ├── UlfiusConfig.cmake
│   │       ├── UlfiusConfigVersion.cmake
│   │       ├── UlfiusTargets.cmake
│   │       └── UlfiusTargets-debug.cmake
│   ├── libulfius.a
│   ├── libulfius.so -> libulfius.so.2.7
│   ├── libulfius.so.2.7 -> libulfius.so.2.7.11
│   ├── libulfius.so.2.7.11
│   └── pkgconfig
│       └── libulfius.pc
└── share
    <snip>