You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2024/03/23 21:12:50 UTC

(nuttx-apps) branch master updated: cmake: add support for Unity

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 12f91b7ce cmake: add support for Unity
12f91b7ce is described below

commit 12f91b7cee5ae5d663d6fede57845d7105b3cec5
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Mar 23 14:13:51 2024 +0100

    cmake: add support for Unity
---
 testing/unity/CMakeLists.txt | 65 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/testing/unity/CMakeLists.txt b/testing/unity/CMakeLists.txt
new file mode 100644
index 000000000..d2734897f
--- /dev/null
+++ b/testing/unity/CMakeLists.txt
@@ -0,0 +1,65 @@
+# ##############################################################################
+# apps/testing/unity/CMakeLists.txt
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License.  You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# ##############################################################################
+
+if(CONFIG_TESTING_UNITY)
+  nuttx_add_library(unity)
+
+  if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/unity)
+    FetchContent_Declare(
+      unity
+      DOWNLOAD_NAME "v${CONFIG_TESTING_UNITY_VERSION}.tar.gz"
+      DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
+      URL "${CONFIG_TESTING_UNITY_URL}/v${CONFIG_TESTING_UNITY_VERSION}.tar.gz"
+          SOURCE_DIR
+          ${CMAKE_CURRENT_LIST_DIR}/Unity
+          BINARY_DIR
+          ${CMAKE_BINARY_DIR}/apps/testing/unity/unity
+          CONFIGURE_COMMAND
+          ""
+          BUILD_COMMAND
+          ""
+          INSTALL_COMMAND
+          ""
+          TEST_COMMAND
+          ""
+      DOWNLOAD_NO_PROGRESS true
+      TIMEOUT 30)
+
+    FetchContent_GetProperties(unity)
+
+    if(NOT unity_POPULATED)
+      FetchContent_Populate(unity)
+    endif()
+  endif()
+
+  set(SRCS Unity/src/unity.c)
+  target_compile_options(unity PRIVATE -DUNITY_INCLUDE_CONFIG_H
+                                       -DUNITY_INCLUDE_DOUBLE)
+
+  target_include_directories(unity PRIVATE ${NUTTX_APPS_DIR}/include/testing)
+
+  # allow use of <testing/unity.h> like for make build
+  file(COPY ${CMAKE_CURRENT_LIST_DIR}/Unity/src/unity.h
+            ${CMAKE_CURRENT_LIST_DIR}/Unity/src/unity_internals.h
+       DESTINATION ${CMAKE_BINARY_DIR}/include/testing/)
+
+  target_sources(unity PRIVATE ${SRCS})
+
+endif()