Skip to content

Commit 738b81b

Browse files
committed
Merge branch 'main' into feature/update-clang-format-and-tidy
2 parents 18c392e + 97c973e commit 738b81b

11 files changed

Lines changed: 95 additions & 129 deletions

File tree

.github/workflows/build_cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
# We need to source the profile file to make sure conan is in PATH
6666
run: |
6767
source ~/.profile
68-
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
68+
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCPP_STARTER_USE_SML=ON -DCPP_STARTER_USE_BOOST_BEAST=ON -DCPP_STARTER_USE_CROW=ON
6969
7070
- name: Build
7171
working-directory: ${{runner.workspace}}/build

.travis.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
22

33
# Set the project name to your project name, my project isn't very descriptive
4-
PROJECT(myproject CXX)
4+
PROJECT(myproject
5+
LANGUAGES CXX
6+
VERSION 0.0.1)
7+
58
INCLUDE(cmake/StandardProjectSettings.cmake)
69
INCLUDE(cmake/PreventInSourceBuilds.cmake)
7-
810
INCLUDE(cmake/CodeFormat.cmake)
911

12+
EXECUTE_PROCESS(
13+
COMMAND git log -1 --format=%h
14+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
15+
OUTPUT_VARIABLE GIT_HASH
16+
OUTPUT_STRIP_TRAILING_WHITESPACE
17+
)
18+
19+
CONFIGURE_FILE("templates/version.hpp.in" "${CMAKE_BINARY_DIR}/generated/include/version.hpp" ESCAPE_QUOTES)
20+
1021
# Link this 'library' to set the c++ standard / compile-time options requested
1122
ADD_LIBRARY(project_options INTERFACE)
1223
TARGET_COMPILE_FEATURES(project_options INTERFACE cxx_std_17)

README.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,15 @@ With this project, we want to provide an example and starting point for C++ proj
77
The project has initially been forked/copied from [Jason Turner's cpp_starter_project](https://github.com/lefticus/cpp_starter_project).
88

99

10-
<hr>
11-
## original README:
12-
13-
# cpp_starter_project
14-
15-
[![codecov](https://codecov.io/gh/lefticus/cpp_starter_project/branch/master/graph/badge.svg)](https://codecov.io/gh/lefticus/cpp_starter_project)
16-
17-
[![Build Status](https://travis-ci.org/lefticus/cpp_starter_project.svg?branch=master)](https://travis-ci.org/lefticus/cpp_starter_project)
18-
19-
[![Build status](https://ci.appveyor.com/api/projects/status/ro4lbfoa7n0sy74c/branch/master?svg=true)](https://ci.appveyor.com/project/lefticus/cpp-starter-project/branch/master)
20-
21-
![CMake](https://github.com/lefticus/cpp_starter_project/workflows/CMake/badge.svg)
10+
## Build Status
2211

12+
![CMake](https://github.com/Zuehlke/cpp_example_project/workflows/CMake/badge.svg)
2313

2414
## Getting Started
2515

2616
### Use the Github template
2717
First, click the green `Use this template` button near the top of this page.
28-
This will take you to Github's ['Generate Repository'](https://github.com/lefticus/cpp_starter_project/generate) page.
18+
This will take you to Github's ['Generate Repository'](https://github.com/Zuehlke/cpp_example_project/generate) page.
2919
Fill in a repository name and short description, and click 'Create repository from template'.
3020
This will allow you to create a new repository in your Github account,
3121
prepopulated with the contents of this project.
@@ -227,30 +217,6 @@ The following compilers should work:
227217
https://github.com/include-what-you-use/include-what-you-use#how-to-install
228218
</details>
229219

230-
#### GUI libraries
231-
This project can be made to work with several optional GUI frameworks.
232-
233-
If desired, you should install the following optional dependencies as
234-
directed by their documentation, linked here:
235-
236-
- [FLTK](https://www.fltk.org/doc-1.4/index.html)
237-
- [GTKMM](https://www.gtkmm.org/en/documentation.html)
238-
- [QT](https://doc.qt.io/)
239-
240-
The following dependencies can be downloaded automatically by CMake and Conan.
241-
All you need to do to install them is to turn on a CMake flag during
242-
configuration.
243-
If you run into difficulty using them, please refer to their documentation,
244-
linked here:
245-
246-
- [NANA](http://nanapro.org/en-us/documentation/)
247-
- [SDL](http://wiki.libsdl.org/FrontPage)
248-
- [IMGUI](https://github.com/ocornut/imgui/tree/master/docs):
249-
This framework depends on SFML, and if you are using Linux, you may need
250-
to install several of SFML's dependencies using your package manager. See
251-
[the SFML build tutorial](https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php)
252-
for specifics.
253-
254220
## Build Instructions
255221

256222
### Build directory

appveyor.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmake/Conan.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ macro(run_conan)
1818
sml/1.1.5
1919
nlohmann_json/3.10.5
2020
boost/1.78.0
21+
crowcpp-crow/1.0+1
2122
OPTIONS
2223
${CONAN_EXTRA_OPTIONS}
2324
gtest:build_gmock=True

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
OPTION(CPP_STARTER_USE_SML "Enable compilation of SML sample" OFF)
22
OPTION(CPP_STARTER_USE_BOOST_BEAST "Enable compilation of boost beast sample" OFF)
3+
OPTION(CPP_STARTER_USE_CROW "Enable compilation of crow sample" OFF)
34

45
# SML
56
IF(CPP_STARTER_USE_SML)
@@ -13,6 +14,12 @@ IF(CPP_STARTER_USE_BOOST_BEAST)
1314
ADD_SUBDIRECTORY(boost.beast)
1415
ENDIF()
1516

17+
# Crow
18+
IF(CPP_STARTER_USE_CROW)
19+
MESSAGE("Using Crow")
20+
ADD_SUBDIRECTORY(crow)
21+
ENDIF()
22+
1623

1724
# Generic test that uses conan libs
1825
ADD_EXECUTABLE(intro main.cpp)
@@ -24,3 +31,4 @@ TARGET_LINK_LIBRARIES(
2431
CONAN_PKG::fmt
2532
CONAN_PKG::spdlog)
2633

34+
TARGET_INCLUDE_DIRECTORIES(intro PRIVATE ${CMAKE_BINARY_DIR}/generated)

src/crow/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ADD_EXECUTABLE(test_crow main.cpp)
2+
TARGET_LINK_LIBRARIES(test_crow PRIVATE CONAN_PKG::crowcpp-crow CONAN_PKG::spdlog)

src/crow/main.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* example usage of crow-cpp http://crowcpp.org/ */
2+
#include "crow.h"
3+
4+
class a : public crow::returnable
5+
{
6+
public:
7+
a() : returnable("text/plain"){};
8+
9+
std::string dump() const override
10+
{
11+
return "ABCDF";
12+
}
13+
};
14+
15+
int main()
16+
{
17+
constexpr uint16_t port = 8080;
18+
std::vector<int> values;
19+
crow::SimpleApp app;
20+
21+
CROW_ROUTE(app, "/")
22+
([]() {
23+
return "Hello world";
24+
});
25+
26+
CROW_ROUTE(app, "/json")
27+
([] {
28+
return crow::json::wvalue({ { "message", "Hello, World!" }, {"message2", "Hello, World.. Again!"} });
29+
});
30+
31+
CROW_ROUTE(app, "/custom")
32+
([]() {
33+
return a();
34+
});
35+
36+
CROW_ROUTE(app, "/hello/<int>").methods(crow::HTTPMethod::POST)([&values](int count) {
37+
values.push_back(count);
38+
return crow::response(std::to_string(count));
39+
});
40+
41+
CROW_ROUTE(app, "/hello/").methods(crow::HTTPMethod::GET)([&values]() {
42+
crow::json::wvalue returnValue;
43+
returnValue["values"] = values;
44+
return returnValue;
45+
});
46+
47+
app.port(port).run();
48+
return 0;
49+
}

src/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <functional>
22
#include <iostream>
3-
3+
#include <string>
4+
#include "include/version.hpp"
45
#include <docopt/docopt.h>
56
#include <spdlog/spdlog.h>
67

@@ -24,14 +25,20 @@ static constexpr auto USAGE =
2425

2526
int main(int argc, const char **argv)
2627
{
28+
fmt::print(R"(Version
29+
Major {}
30+
Minor {}
31+
Patch {}
32+
Git Hash {}
33+
)", Version::Major, Version::Minor, Version::Patch, Version::GitHash);
34+
2735
std::map<std::string, docopt::value> args = docopt::docopt(USAGE,
2836
{ std::next(argv), std::next(argv, argc) },
2937
true,// show help if requested
3038
"Naval Fate 2.0");// version string
3139

3240
for (auto const &arg : args) { std::cout << arg.first << arg.second << std::endl; }
3341

34-
3542
// Use the default logger (stdout, multi-threaded, colored)
3643
spdlog::info("Hello, {}!", "World");
3744

0 commit comments

Comments
 (0)