diff options
author | sanine <sanine.not@pm.me> | 2022-08-24 00:02:17 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-24 00:02:17 -0500 |
commit | 2cb3c3df4099297b0a0554bb482e2de04fe86b5c (patch) | |
tree | 7796b4064c16460d9d603707b5256027649aa8b6 /libs/cargs/docs/embed.md | |
parent | 709e1b6e1ce86f8da4fc136747fcefbc6c6057bd (diff) |
add command-line arguments
Diffstat (limited to 'libs/cargs/docs/embed.md')
-rw-r--r-- | libs/cargs/docs/embed.md | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libs/cargs/docs/embed.md b/libs/cargs/docs/embed.md new file mode 100644 index 0000000..ed64d4e --- /dev/null +++ b/libs/cargs/docs/embed.md @@ -0,0 +1,47 @@ +--- +title: Embedding +description: A guide on how to embed the cargs command line parser library for C/C++. +--- + + +In order to embed **cargs**, you will have to download it. +You can do so using git (or download it from [here](https://github.com/likle/cargs/archive/stable.zip)). + +```bash +git clone -b stable git@github.com:likle/cargs.git +``` +**Note**: The *stable* branch points to the latest stable version. You should +always use a stable version in production code. + +## Using CMake to embed cargs +If you are using CMake it is fairly easy to embed **cargs**. +This only requires two lines, you don't even have to specify the include directories. +The following example shows how to do so: +```cmake +# Some basics you will need in your cmake file. +cmake_minimum_required(VERSION 3.9.2) +project(example C) +add_executable(example_target main.c) + +# Replace your_path_to_cargs with the path to your cargs copy. +# This could be something like "${CMAKE_CURRENT_SOURCE_DIR}/lib/cargs". +add_subdirectory(your_path_to_cargs) + +# Replace example_target with the target name which requires cargs. +# After this, there is no need to specify any include directories. +target_link_libraries(example_target cargs) +``` + +After that, you should be able to use cargs in your source code: +```c +#include <cargs.h> +``` + +## Directly embed cargs in your source +If you don't use CMake and would like to embed **cargs** directly, you could +just add the two files ``src/cargs.c`` and ``ìnclude/cargs.h`` to your project. +The folder containing ``cargs.h`` has to be in your include directories +([Visual Studio](https://docs.microsoft.com/en-us/cpp/ide/vcpp-directories-property-page?view=vs-2017), +[Eclipse](https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_pns_inc.htm), +[gcc](https://www.rapidtables.com/code/linux/gcc/gcc-i.html), +[clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#include-path-management)). |