Last active
September 10, 2020 20:53
-
-
Save timhugh/4aedb0d615defa505c811440d0db8726 to your computer and use it in GitHub Desktop.
Example project with conan.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir build | |
cd build | |
conan install .. | |
cmake .. | |
cmake --build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[requires] | |
cpp-httplib/0.7.6 | |
[generators] | |
cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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