|
| 1 | +# SPDX-FileCopyrightText: Silicon Laboratories Inc. <https://www.silabs.com/> |
| 2 | +# SPDX-License-Identifier: Zlib |
| 3 | +# |
| 4 | +# This recipe allows to download CMock |
| 5 | +# It can be used by projects which are depending on it |
| 6 | +# Feel free to copy this (up to date) file everywhere it is needed |
| 7 | + |
| 8 | +include(FetchContent) |
| 9 | + |
| 10 | +if(NOT DEFINED CMOCK_GIT_REPOSITORY) |
| 11 | + if(DEFINED ENV{CMOCK_GIT_REPOSITORY}) |
| 12 | + set(CMOCK_GIT_REPOSITORY $ENV{CMOCK_GIT_REPOSITORY}) |
| 13 | + endif() |
| 14 | +endif() |
| 15 | +if("${CMOCK_GIT_REPOSITORY}" STREQUAL "") |
| 16 | + set(CMOCK_GIT_REPOSITORY "https://github.com/ThrowTheSwitch/CMock") |
| 17 | +endif() |
| 18 | + |
| 19 | +if(NOT DEFINED CMOCK_GIT_TAG) |
| 20 | + if(DEFINED ENV{CMOCK_GIT_TAG}) |
| 21 | + set(CMOCK_GIT_TAG $ENV{CMOCK_GIT_TAG}) |
| 22 | + else() |
| 23 | + set(CMOCK_GIT_TAG "v2.5.3") |
| 24 | + endif() |
| 25 | +endif() |
| 26 | + |
| 27 | +FetchContent_Declare( |
| 28 | + CMock |
| 29 | + GIT_REPOSITORY ${CMOCK_GIT_REPOSITORY} |
| 30 | + GIT_TAG ${CMOCK_GIT_TAG} |
| 31 | + GIT_SUBMODULES_RECURSE True |
| 32 | + GIT_SHALLOW 1 |
| 33 | +) |
| 34 | + |
| 35 | +message(STATUS "${CMAKE_PROJECT_NAME}: Depends: ${CMOCK_GIT_REPOSITORY}#${CMOCK_GIT_TAG}") |
| 36 | +string(REGEX MATCH ".*/?main/?.*" CMOCK_UNSTABLE_GIT_TAG "${CMOCK_GIT_TAG}") |
| 37 | +if(CMOCK_GIT_TAG STREQUAL "" OR CMOCK_UNSTABLE_GIT_TAG) |
| 38 | + message(WARNING "${CMAKE_PROJECT_NAME}: Declare CMOCK_GIT_TAG to stable version not: ${CMOCK_UNSTABLE_GIT_TAG}") |
| 39 | +endif() |
| 40 | + |
| 41 | +set(FETCHCONTENT_QUIET FALSE) |
| 42 | +FetchContent_MakeAvailable(CMock) |
| 43 | + |
| 44 | +message(STATUS "CMock Sources: ${cmock_SOURCE_DIR}") |
| 45 | +message(STATUS "CMock Binaries: ${cmock_BINARY_DIR}") |
0 commit comments