Skip to content

Instantly share code, notes, and snippets.

@timhugh
Last active September 10, 2020 20:53
Show Gist options
  • Save timhugh/4aedb0d615defa505c811440d0db8726 to your computer and use it in GitHub Desktop.
Save timhugh/4aedb0d615defa505c811440d0db8726 to your computer and use it in GitHub Desktop.
Example project with conan.io
A simple web server using cpp-httplib to demonstrate using conan.io to manage dependencies.
Install conan first: https://docs.conan.io/en/latest/installation.html
(I used homebrew: `brew install conan`)
#!/bin/sh
mkdir build
cd build
conan install ..
cmake ..
cmake --build .
cmake_minimum_required(VERSION 3.17.0)
project(ConanTest)
add_definitions("-std=c++17")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(test-server server.cpp)
target_link_libraries(test-server ${CONAN_LIBS})
[requires]
cpp-httplib/0.7.6
[generators]
cmake
#include <httplib.h>
int main(int argc, char** argv) {
httplib::Server server;
server.Get("/", [](const httplib::Request& req, httplib::Response& res) {
res.set_content("Hello!", "text/plain");
});
server.listen("localhost", 8000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment