-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example for how to use NabtoEmbeddedSDK with vcpkg
- Loading branch information
Showing
11 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project(vcpkg_example) | ||
find_package(NabtoEmbeddedSDK REQUIRED) | ||
|
||
add_executable(vcpkg_example main.c) | ||
target_link_libraries(vcpkg_example PRIVATE NabtoEmbeddedSDK::nabto_device) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# vcpkg example | ||
|
||
This example shows how the nabto embedded sdk can be used with the vcpkg package | ||
management system. This is just an example, consult the vcpkg documentation for | ||
further information. | ||
|
||
usage: | ||
|
||
cd into this directory. | ||
``` | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_MODULE_PATH=`pwd`/../../../../cmake/vcpkg -DCMAKE_TOOLCHAIN_FILE=`pwd`/../../../../3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_OVERLAY_PORTS=`pwd`/../ports .. | ||
make | ||
./vcpkg_example | ||
``` | ||
|
||
Explanation: | ||
* The CMAKE_MODULE_PATH is needed since vcpkg still provides MbedTLS 2 and | ||
tinycbor which does not come with find_package scripts. | ||
* The CMAKE_TOOLCHAIN_FILE is set such that the cmake build system will use | ||
vcpkg | ||
* The VCPKG_OVERLAY_PORTS is set such that the NabtoEmbeddedSDK package can be | ||
found since it is not present in the vcpkg package repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
SOURCE_DIR=${DIR}/../../.. | ||
BUILD_DIR=${SOURCE_DIR}/build/vcpkg_example | ||
INSTALL_DIR=${BUILD_DIR}/install | ||
|
||
mkdir -p ${BUILD_DIR} | ||
|
||
set -v | ||
set -e | ||
|
||
cd ${BUILD_DIR} | ||
cmake -DCMAKE_MODULE_PATH=${SOURCE_DIR}/cmake/vcpkg -DCMAKE_TOOLCHAIN_FILE=${SOURCE_DIR}/3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_OVERLAY_PORTS=${DIR}/ports ${DIR} | ||
make -j 16 | ||
|
||
./vcpkg_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <stdio.h> | ||
|
||
#include <nabto/nabto_device.h> | ||
|
||
int main(int argc, char* argv[]) { | ||
printf("Nabto Embedded SDK verstion %s\r\n", nabto_device_version()); | ||
} |
23 changes: 23 additions & 0 deletions
23
test/distribution/vcpkg_example/ports/nabto-common/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
set(REF "95c9cae4b085668c4221f43c0d874d981daba4b1") | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO nabto/nabto-common | ||
REF ${REF} | ||
SHA512 b4b45751df9eecce634f740d61a481625001e0669a250fb72499c760f3b0b46bb51121ca8041e2708f3a3b7e022a62b2b3137dac353e82ea6924fc9b6c2a7da8 | ||
HEAD_REF "master" | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
-DNABTO_COMMON_VERSION=0.0.0+${REF} | ||
) | ||
|
||
vcpkg_cmake_install() | ||
|
||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_cmake_config_fixup(PACKAGE_NAME NabtoCommon CONFIG_PATH lib/cmake/NabtoCommon) | ||
|
||
#vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSING.md") |
17 changes: 17 additions & 0 deletions
17
test/distribution/vcpkg_example/ports/nabto-common/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "nabto-common", | ||
"version-string": "0.0.0", | ||
"description": "Nabto Common", | ||
"homepage": "https://github.com/nabto/nabto-common", | ||
"license": "Apache-2.0", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
] | ||
} |
35 changes: 35 additions & 0 deletions
35
test/distribution/vcpkg_example/ports/nabto-embedded-sdk/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
set(REF "b05465f002a6b00722e14ba7955758fe919a5b08") | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO nabto/nabto-embedded-sdk | ||
REF ${REF} | ||
SHA512 83491c30f02045e8c3428b4316297196a9e3baae508ec5571c657488efb4499958e728589ed7b00530d555664ebef204a94ffad6fef6fe3809b3915d50db48e4 | ||
HEAD_REF "master" | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
-DCMAKE_MODULE_PATH=${SOURCE_PATH}/cmake/vcpkg | ||
-DDEVICE_BUILD_EXAMPLES=FALSE | ||
-DDEVICE_BUILD_TESTS=FALSE | ||
-DDEVICE_BUILD_APPS=FALSE | ||
-DNABTO_DEVICE_PREFER_SYSTEM_LIBS=ON | ||
-DNABTO_DEVICE_USE_SYSTEM_LIBEVENT=ON | ||
-DNABTO_DEVICE_USE_SYSTEM_NABTOCOMMON=ON | ||
-DNABTO_DEVICE_USE_SYSTEM_MBEDTLS=ON | ||
-DNABTO_DEVICE_USE_SYSTEM_NLOHMANNJSON=ON | ||
-DNABTO_DEVICE_USE_SYSTEM_TINYCBOR=ON | ||
-DNABTO_DEVICE_BUILD_WITH_VCPKG_DEPENDENCIES=TRUE | ||
-DNABTO_DEVICE_VERSION="0.0.0+${REF}" | ||
) | ||
|
||
vcpkg_cmake_install() | ||
|
||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_cmake_config_fixup(PACKAGE_NAME NabtoEmbeddedSDK CONFIG_PATH lib/cmake/NabtoEmbeddedSDK) | ||
|
||
|
||
#vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSING.md") |
32 changes: 32 additions & 0 deletions
32
test/distribution/vcpkg_example/ports/nabto-embedded-sdk/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "nabto-embedded-sdk", | ||
"version": "0.0.0+b05465f002a6b00722e14ba7955758fe919a5b08", | ||
"description": "Nabto Embedded SDK", | ||
"homepage": "https://github.com/nabto/nabto-embedded-sdk", | ||
"license": "Apache-2.0", | ||
"dependencies": [ | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
}, | ||
{ | ||
"name": "nabto-common" | ||
}, | ||
{ | ||
"name": "libevent" | ||
}, | ||
{ | ||
"name": "cjson" | ||
}, | ||
{ | ||
"name": "mbedtls" | ||
}, | ||
{ | ||
"name": "tinycbor" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"overlay-ports": [ | ||
"./ports" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "vcpkg-example", | ||
"version-string": "0.0.1", | ||
"dependencies": [ | ||
"nabto-embedded-sdk" | ||
] | ||
} |