From 57ddc4ca36d88b255ff72c30ad39d05cb29a266e Mon Sep 17 00:00:00 2001 From: "Maarten L. Hekkelman" Date: Thu, 1 Feb 2024 09:11:42 +0100 Subject: [PATCH] Optionally build examples --- CMakeLists.txt | 6 ++++++ examples/daemon-sample.cpp | 2 +- examples/http-server-1.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d70421f4..d23b9f2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) option(ZEEP_BUILD_LIBRARY "Build the library from source code, should be off when configuring on ReadTheDocs" ON) option(ZEEP_BUILD_DOCUMENTATION "Build documentation" OFF) +option(ZEEP_BUILD_EXAMPLES "Build the example applications" ON) option(ZEEP_USE_BOOST_ASIO "Use the asio library from Boost instead of the non-boost version" ON) option(ZEEP_ALLOW_FETCH_CONTENT "Use cmake's FetchContent to retrieve missing packages" ON) @@ -315,6 +316,11 @@ if(ZEEP_BUILD_DOCUMENTATION) add_subdirectory(docs) endif() +# Examples +if(ZEEP_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + # Test applications, but only if we're not included as a subproject get_directory_property(HAS_PARENT PARENT_DIRECTORY) diff --git a/examples/daemon-sample.cpp b/examples/daemon-sample.cpp index b428ba49..065b2a38 100644 --- a/examples/daemon-sample.cpp +++ b/examples/daemon-sample.cpp @@ -19,7 +19,7 @@ class hello_controller : public zh::controller { } - bool handle_request(zh::request &req, zh::reply &rep) + bool handle_request([[maybe_unused]] zh::request &req, zh::reply &rep) { /* Construct a simple reply with status OK (200) and content string */ rep = zh::reply::stock_reply(zh::ok); diff --git a/examples/http-server-1.cpp b/examples/http-server-1.cpp index 8816bd99..d4bc261b 100644 --- a/examples/http-server-1.cpp +++ b/examples/http-server-1.cpp @@ -13,7 +13,7 @@ class hello_controller : public zeep::http::controller /* Specify the root path as prefix, will handle any request URI */ hello_controller() : controller("/") {} - bool handle_request(zeep::http::request& req, zeep::http::reply& rep) + bool handle_request([[maybe_unused]] zeep::http::request& req, zeep::http::reply& rep) { /* Construct a simple reply with status OK (200) and content string */ rep = zeep::http::reply::stock_reply(zeep::http::ok);