Skip to content

Commit def52a8

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 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent e411291 commit def52a8

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

cmake/modules/FindUnifySDK.cmake

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
9+
include(FetchContent)
10+
11+
# Standard cmake paths, you probably don't want/need to change
12+
if(NOT DEFINED UNIFYSDK_SOURCE_DIR)
13+
set(UNIFYSDK_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/unifysdk-src")
14+
endif()
15+
if(NOT DEFINED UNIFYSDK_BINARY_DIR)
16+
set(UNIFYSDK_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/unifysdk-build")
17+
endif()
18+
19+
if(NOT DEFINED UNIFYSDK_GIT_REPOSITORY)
20+
if(DEFINED ENV{UNIFYSDK_GIT_REPOSITORY})
21+
set(UNIFYSDK_GIT_REPOSITORY $ENV{UNIFYSDK_GIT_REPOSITORY})
22+
else()
23+
set(UNIFYSDK_GIT_REPOSITORY "")
24+
endif()
25+
endif()
26+
if(UNIFYSDK_GIT_REPOSITORY STREQUAL "")
27+
set(UNIFYSDK_GIT_REPOSITORY "https://github.com/SiliconLabs/UnifySDK")
28+
endif()
29+
30+
if(NOT DEFINED UNIFYSDK_GIT_TAG)
31+
if(DEFINED ENV{UNIFYSDK_GIT_TAG})
32+
set(UNIFYSDK_GIT_TAG $ENV{UNIFYSDK_GIT_TAG})
33+
else()
34+
set(UNIFYSDK_GIT_TAG "")
35+
endif()
36+
endif()
37+
38+
if(UNIFYSDK_GIT_TAG STREQUAL "")
39+
set(UNIFYSDK_GIT_TAG "main")
40+
endif()
41+
42+
FetchContent_Declare(
43+
UnifySDK
44+
GIT_REPOSITORY ${UNIFYSDK_GIT_REPOSITORY}
45+
GIT_TAG ${UNIFYSDK_GIT_TAG}
46+
GIT_SUBMODULES_RECURSE True
47+
GIT_SHALLOW 1
48+
)
49+
50+
message(STATUS "${CMAKE_PROJECT_NAME}: Depends: ${UNIFYSDK_GIT_REPOSITORY}#${UNIFYSDK_GIT_TAG}")
51+
message(STATUS "UnifySDK Sources: ${UNIFYSDK_SOURCE_DIR}")
52+
message(STATUS "UnifySDK Binaries: ${UNIFYSDK_BINARY_DIR}")
53+
54+
# Pull only once, this has be refreshed by developer
55+
if(NOT EXISTS ${CMAKE_BINARY_DIR}/_deps/unifysdk-src)
56+
if(UNIFYSDK_GIT_TAG STREQUAL "main")
57+
message(WARNING "Using: ${UNIFYSDK_GIT_TAG} TODO: Pin stable revision once supported")
58+
endif()
59+
FetchContent_MakeAvailable(UnifySDK)
60+
else()
61+
message(STATUS "Using UnifySDK from previous fetch (may be outdated)")
62+
add_subdirectory(${CMAKE_BINARY_DIR}/_deps/unifysdk-src)
63+
endif()

0 commit comments

Comments
 (0)