Skip to content

Commit 98e015e

Browse files
committed
SWPROT-8953: build: cmake: Use Upstream cmock
Not this is not latest version but it aligned to the version used at zwa, may unify-core align to it and synchronize all projects accordingly, or reconsider the archtecture. Signed-off-by: Philippe Coval <[email protected]>
1 parent 80e83f9 commit 98e015e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if(NOT DEFINED COMMON_LOCATION)
1414
endif()
1515

1616
if(BUILD_TESTING)
17+
include(cmake/modules/FindCMock.cmake)
18+
set(THS-CMOCK_LOCATION "${cmock_SOURCE_DIR}")
19+
set(THS-UNITY_LOCATION "${cmock_SOURCE_DIR}/vendor/unity")
1720
# https://gitlab.kitware.com/cmake/cmake/-/issues/22813#note_1620373
1821
option(BUILD_TESTING_PROPERTY_DISABLED "WARNING: Bypass some tests" True)
1922
if(BUILD_TESTING_PROPERTY_DISABLED)

cmake/modules/FindCMock.cmake

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)