Skip to content

Commit cac84ab

Browse files
committed
SWPROT-8953: Add recipe to pull UnifySDK dependency
This file is shared a single commit, to allow pick between projects (eg: z-wave-protocol-controller) consuming UnifySDK since the monorepo has been shrinked. Feedback welcome. Note values can be ajusted from env, it can be usefull for github actions with fork, if using private one make sure to pass the token in the build env: UNIFYSDK_GIT_REPOSITORY="https://<TOKEN>@github.com/rzr/UnifySDK" Bug-SiliconLabs: SWPROT-8953 Origin: SiliconLabs/UnifySDK#51 Forwarded: #10 Forwarded: uic/pull-requests/2972 Signed-off-by: Philippe Coval <[email protected]>
1 parent e411291 commit cac84ab

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

cmake/modules/FindUnifySDK.cmake

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-FileCopyrightText: Silicon Laboratories Inc. <https://www.silabs.com/>
2+
# SPDX-License-Identifier: Zlib
3+
4+
# This recipe allows to download Unify Core
5+
# Origin: https://github.com/SiliconLabs/UnifySDK/pulls?q=is%3Apr+author%3Arzr
6+
# It can be used by projects which are depending on it
7+
# Feel free to copy this (up to date) file everywhere it is needed
8+
# Typically it is located in "cmake/modules/FindUnifySDK.cmake"
9+
10+
include(FetchContent)
11+
12+
# Standard cmake paths, you probably don't want/need to change
13+
if(NOT DEFINED UNIFYSDK_SOURCE_DIR)
14+
set(UNIFYSDK_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/unifysdk-src")
15+
endif()
16+
if(NOT DEFINED UNIFYSDK_BINARY_DIR)
17+
set(UNIFYSDK_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/unifysdk-build")
18+
endif()
19+
20+
if(NOT DEFINED UNIFYSDK_GIT_REPOSITORY)
21+
if(DEFINED ENV{UNIFYSDK_GIT_REPOSITORY})
22+
set(UNIFYSDK_GIT_REPOSITORY $ENV{UNIFYSDK_GIT_REPOSITORY})
23+
else()
24+
set(UNIFYSDK_GIT_REPOSITORY "")
25+
endif()
26+
endif()
27+
if(UNIFYSDK_GIT_REPOSITORY STREQUAL "")
28+
set(UNIFYSDK_GIT_REPOSITORY "https://github.com/SiliconLabs/UnifySDK")
29+
endif()
30+
31+
if(NOT DEFINED UNIFYSDK_GIT_TAG)
32+
if(DEFINED ENV{UNIFYSDK_GIT_TAG})
33+
set(UNIFYSDK_GIT_TAG $ENV{UNIFYSDK_GIT_TAG})
34+
else()
35+
set(UNIFYSDK_GIT_TAG "")
36+
endif()
37+
endif()
38+
39+
if(UNIFYSDK_GIT_TAG STREQUAL "")
40+
set(UNIFYSDK_GIT_TAG "main")
41+
endif()
42+
43+
FetchContent_Declare(
44+
UnifySDK
45+
GIT_REPOSITORY ${UNIFYSDK_GIT_REPOSITORY}
46+
GIT_TAG ${UNIFYSDK_GIT_TAG}
47+
GIT_SUBMODULES_RECURSE True
48+
GIT_SHALLOW 1
49+
)
50+
51+
message(STATUS "${CMAKE_PROJECT_NAME}: Depends: ${UNIFYSDK_GIT_REPOSITORY}#${UNIFYSDK_GIT_TAG}")
52+
message(STATUS "UnifySDK Sources: ${UNIFYSDK_SOURCE_DIR}")
53+
message(STATUS "UnifySDK Binaries: ${UNIFYSDK_BINARY_DIR}")
54+
55+
# Pull only once, this has be refreshed by developer
56+
if(NOT EXISTS ${CMAKE_BINARY_DIR}/_deps/unifysdk-src)
57+
if(UNIFYSDK_GIT_TAG STREQUAL "main")
58+
message(WARNING "Using: ${UNIFYSDK_GIT_TAG} TODO: Pin stable revision once supported")
59+
endif()
60+
FetchContent_MakeAvailable(UnifySDK)
61+
else()
62+
message(STATUS "Using UnifySDK from previous fetch (may be outdated)")
63+
add_subdirectory(${CMAKE_BINARY_DIR}/_deps/unifysdk-src)
64+
endif()

0 commit comments

Comments
 (0)