Skip to content

Commit

Permalink
Add a "Hello, world!" example.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Jun 24, 2024
1 parent 313b163 commit f30655c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/examples/hello/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CMake artifacts
build/
CMakeUserPresets.json
5 changes: 5 additions & 0 deletions doc/examples/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.15)
project(hello CXX)
find_package(know.cpp REQUIRED)
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} know.cpp::know.cpp)
11 changes: 11 additions & 0 deletions doc/examples/hello/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Hello, World! for Know.cpp

```console
$ conan install . --output-folder=build --build=missing

$ cd build
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
$ cmake --build .

$ ./hello
```
6 changes: 6 additions & 0 deletions doc/examples/hello/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[requires]
know.cpp/0.0.0

[generators]
CMakeDeps
CMakeToolchain
15 changes: 15 additions & 0 deletions doc/examples/hello/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This is free and unencumbered software released into the public domain. */

#include <know.hpp> // for know::*

#include <cstdlib> // for EXIT_SUCCESS
#include <iostream> // for std::cout

int main(void) {
know::thing you;
you.names = {"J. Random Hacker"};

std::cout << "Hello, " << you.names[0] << "!\n";

return EXIT_SUCCESS;
}

0 comments on commit f30655c

Please sign in to comment.