diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt new file mode 100644 index 000000000..678aebcb4 --- /dev/null +++ b/samples/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.1) + +project(aws-iot-device-sdk-cpp-v2-samples) + +add_subdirectory(device_defender/basic_report) +add_subdirectory(greengrass/ipc) +add_subdirectory(greengrass/basic_discovery) +add_subdirectory(identity/fleet_provisioning) +add_subdirectory(jobs/describe_job_execution) +add_subdirectory(mqtt/basic_connect) +add_subdirectory(mqtt/custom_authorizer_connect) +add_subdirectory(mqtt/pkcs11_connect) +add_subdirectory(mqtt/raw_connect) +add_subdirectory(mqtt/websocket_connect) +add_subdirectory(mqtt/windows_cert_connect) +add_subdirectory(mqtt/x509_credentials_provider_connect) +add_subdirectory(mqtt5/mqtt5_pubsub) +add_subdirectory(pub_sub/basic_pub_sub) +add_subdirectory(pub_sub/cycle_pub_sub) +add_subdirectory(secure_tunneling/secure_tunnel) +add_subdirectory(secure_tunneling/tunnel_notification) +add_subdirectory(shadow/shadow_sync) diff --git a/samples/README.md b/samples/README.md index 6ada347a5..985278448 100644 --- a/samples/README.md +++ b/samples/README.md @@ -23,28 +23,43 @@ Firstly, build and install aws-iot-devices-sdk-cpp-v2 with following instructions from [Installation](../README.md#Installation). -### Build samples +### Build individual sample -Change directory into one of the samples. Under the directory of the sample, run the following commands: +Change directory into one of the samples. Under the directory of the sample you wish to build, run the following commands: ``` sh -mkdir build -cd build -cmake -DCMAKE_PREFIX_PATH="" -DCMAKE_BUILD_TYPE="" .. -cmake --build . --config "" +cmake -B build -S . -DCMAKE_PREFIX_PATH="" -DCMAKE_BUILD_TYPE="" . +cmake --build build --config "" ``` -To view the commands for a given sample, run the compiled program and pass `--help`. +To view the commands for a given sample, run the compiled program and pass `--help`. For example, with the PubSub sample: +```sh +./build/basic-pub-sub --help ``` -./basic-pub-sub --help + +### Build all samples + +Change directory to the `aws-iot-device-sdk-cpp-v2/samples` directory and then run the following commands: + +```sh +cmake -B build -S . -DCMAKE_PREFIX_PATH="" -DCMAKE_BUILD_TYPE="" . +cmake --build build --config "" ``` -#### Note +This will compile all the samples at once and place the executables under the `build` directory relative to their file path. To view the commands for a given sample, run the compiled program and pass `--help`. For example, with the PubSub sample: + +```sh +./build/pub_sub/basic_pub_sub/basic-pub-sub --help +``` + +This will compile all of the samples at once. You can then find the samples in the `aws-iot-device-sdk-cpp-v2/samples/build` folder. For example, the PubSub sample will be located at `aws-iot-device-sdk-cpp-v2/samples/build/pubsub/basic_pubsub`. + +### Sample Build Notes -* `-DCMAKE_PREFIX_PATH` needs to be set to the path aws-iot-device-sdk-cpp-v2 installed. Since [Installation](../README.md#Installation) takes sdk-cpp-workspace as an example, here takes that as an example too. +* `-DCMAKE_PREFIX_PATH` needs to be set to the path aws-iot-device-sdk-cpp-v2 installed at. Since [Installation](../README.md#Installation) takes `sdk-cpp-workspace` as an example, this file uses that example too. -* `-DCMAKE_BUILD_TYPE` and `--config` needs to match the CMAKE_BUILD_TYPE when aws-iot-device-sdk-cpp-v2 built. `--config` is only REQUIRED for multi-configuration build tools. +* `-DCMAKE_BUILD_TYPE` and `--config` needs to match the `CMAKE_BUILD_TYPE` when aws-iot-device-sdk-cpp-v2 built. `--config` is only REQUIRED for multi-configuration build tools. ## Basic Pub-Sub