build(qcbor): Simplify Qcbor build
This patch makes the build of QCBOR external component
as a regular lib build in RMM. This also simplifies the
dependency graph generated by CMake.
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: If958f0c2293d876437aa2f0af1a1ea7134fcce84
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f15a88..55c0050 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,11 +93,6 @@
link_libraries(rmm-lib-libc)
#
-# Build and link QCBOR
-#
-include("cmake/BuildQCBOR.cmake")
-
-#
# Recurse into the various component subdirectories
#
add_subdirectory("lib")
diff --git a/cmake/BuildQCBOR.cmake b/cmake/BuildQCBOR.cmake
deleted file mode 100644
index f66683c..0000000
--- a/cmake/BuildQCBOR.cmake
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# SPDX-License-Identifier: BSD-3-Clause
-# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
-#
-
-add_subdirectory("ext/qcbor")
-
-#
-# Set up qcbor using our own libc. This is done by getting certain properties
-# from our libc target and applying them to qcbor - not ideal, but qcbor
-# doesn't provide an interface library for us to use.
-#
-get_target_property(system_includes rmm-lib-libc
- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
-get_target_property(includes rmm-lib-libc
- INTERFACE_INCLUDE_DIRECTORIES)
-get_target_property(definitions rmm-lib-libc
- INTERFACE_COMPILE_DEFINITIONS)
-get_target_property(options rmm-lib-libc
- INTERFACE_COMPILE_OPTIONS)
-
-#
-# System include directories appear in both the `SYSTEM_INCLUDE_DIRECTORIES` and
-# `INCLUDE_DIRECTORIES` properties, so filter them out of the latter.
-#
-list(REMOVE_ITEM includes ${system_includes})
-
-#
-# Target properties that are not set return `<PROPERTY>-NOTFOUND`. Clear any
-# variables where this occurred.
-#
-foreach(set IN ITEMS system_includes includes definitions options)
- if(NOT ${set})
- set(${set})
- endif()
-endforeach()
-
-# QCBOR custom definitions
-list(APPEND definitions "QCBOR_DISABLE_FLOAT_HW_USE")
-list(APPEND definitions "USEFULBUF_DISABLE_ALL_FLOAT")
-
-#
-# Create compiler flags from the libc properties we retrieved.
-#
-list(TRANSFORM definitions PREPEND " -D")
-
-foreach(set IN ITEMS options definitions)
- string(REPLACE ";" " " ${set} "${${set}}")
-endforeach()
-
-string(PREPEND qcbor_C_FLAGS "${definitions} ")
-# Add the relevant build flags. TODO: Currently CBOR is only passed Release build flag
-string(PREPEND qcbor_C_FLAGS "${options} ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE} ")
-string(PREPEND qcbor_C_FLAGS "-Wno-maybe-uninitialized ")
-
-string(REPLACE " " ";" qcbor_C_FLAGS ${qcbor_C_FLAGS})
-
-#
-# qcbor's build system ignores and overwrites the flags we specify in our
-# toolchain files. Un-overwrite them, because they're there for a good reason.
-#
-target_include_directories(qcbor
- PUBLIC "${RMM_SOURCE_DIR}/ext/qcbor/inc"
-)
-
-target_include_directories(qcbor
- PRIVATE
- ${includes}
- ${system_includes}
-)
-
-target_compile_options(qcbor
- PRIVATE
- ${qcbor_C_FLAGS}
-)
-
-target_link_libraries(qcbor
- PRIVATE
- rmm-lib-libc
-)
-
-link_libraries(qcbor)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 7b9b2ed..6ffd4b5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -28,6 +28,7 @@
add_subdirectory("gic")
add_subdirectory("mbedtls")
add_subdirectory("measurement")
+add_subdirectory("qcbor")
add_subdirectory("realm")
add_subdirectory("rmm_el3_ifc")
add_subdirectory("smc")
diff --git a/lib/mbedtls/CMakeLists.txt b/lib/mbedtls/CMakeLists.txt
index 10c1c25..02f1b17 100644
--- a/lib/mbedtls/CMakeLists.txt
+++ b/lib/mbedtls/CMakeLists.txt
@@ -39,6 +39,6 @@
# Add the mbedtls subdirectory and exclude all targets in mbedtls from
# default `all` target
#
-add_subdirectory("${RMM_SOURCE_DIR}/ext/mbedtls" "${CMAKE_BINARY_DIR}/ext/medtls" EXCLUDE_FROM_ALL)
+add_subdirectory("${RMM_SOURCE_DIR}/ext/mbedtls" "${CMAKE_BINARY_DIR}/ext/mbedtls" EXCLUDE_FROM_ALL)
target_link_libraries(rmm-mbedtls INTERFACE mbedtls)
diff --git a/lib/qcbor/CMakeLists.txt b/lib/qcbor/CMakeLists.txt
new file mode 100644
index 0000000..27a6e63
--- /dev/null
+++ b/lib/qcbor/CMakeLists.txt
@@ -0,0 +1,36 @@
+#
+# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+#
+
+#
+# Add the qcbor subdirectory.
+#
+add_subdirectory("${RMM_SOURCE_DIR}/ext/qcbor" "${CMAKE_BINARY_DIR}/ext/qcbor")
+
+target_link_libraries(qcbor
+ PRIVATE
+ rmm-lib-libc
+)
+
+# Add the relevant build flags.
+string(PREPEND qcbor_C_FLAGS "${CMAKE_C_FLAGS} ")
+string(PREPEND qcbor_C_FLAGS "-Wno-maybe-uninitialized ")
+
+string(REPLACE " " ";" qcbor_C_FLAGS ${qcbor_C_FLAGS})
+
+#
+# qcbor's build system ignores and overwrites the flags we specify in our
+# toolchain files. Un-overwrite them, because they're there for a good reason.
+#
+target_include_directories(qcbor
+ PUBLIC "${RMM_SOURCE_DIR}/ext/qcbor/inc"
+)
+
+target_compile_options(qcbor
+ PRIVATE
+ ${qcbor_C_FLAGS}
+)
+
+target_compile_definitions(qcbor PRIVATE QCBOR_DISABLE_FLOAT_HW_USE)
+target_compile_definitions(qcbor PRIVATE USEFULBUF_DISABLE_ALL_FLOAT)