From d6f53f93811ec571bc424e88e961204b4635eb99 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Sat, 25 Mar 2023 02:33:38 +0100 Subject: [PATCH] CMake: remove redundancy Signed-off-by: Axel Heider --- apps/Arm/odroid_vm/CMakeLists.txt | 10 +++++---- apps/Arm/vm_minimal/CMakeLists.txt | 32 +++++++++++++++-------------- apps/x86/zmq_samples/CMakeLists.txt | 27 ++++++++++-------------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/apps/Arm/odroid_vm/CMakeLists.txt b/apps/Arm/odroid_vm/CMakeLists.txt index 553674fa..aeab0695 100644 --- a/apps/Arm/odroid_vm/CMakeLists.txt +++ b/apps/Arm/odroid_vm/CMakeLists.txt @@ -36,16 +36,18 @@ set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux") # Different device tree if compiling with VmVUSB if(VmVUSB) - set(device_tree_src "linux-secure-vusb-dtb") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-vusb-dtb") else() - set(device_tree_src "linux-secure-dtb") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-dtb") endif() + # Sed the device tree updating the rootfs name +set(linux_dtb "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT "${linux_dtb}" COMMAND bash -c - "sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} > linux/linux-dtb" + "sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${device_tree_src} > ${linux_dtb}" VERBATIM ) # Create custom target for setting the dtb diff --git a/apps/Arm/vm_minimal/CMakeLists.txt b/apps/Arm/vm_minimal/CMakeLists.txt index b4fc6474..196c0673 100644 --- a/apps/Arm/vm_minimal/CMakeLists.txt +++ b/apps/Arm/vm_minimal/CMakeLists.txt @@ -18,29 +18,31 @@ if("${KernelARMPlatform}" STREQUAL "tk1") # Different device tree if compiling with Tk1Insecure if(Tk1Insecure) - set(device_tree_src "linux-tk1-nonsecured.dts") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-nonsecured.dts") else() - set(device_tree_src "linux-tk1-secure.dts") + set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-secure.dts") endif() if(VmTk1InitrdRootfs) - set(linux_binary_name "linux-tk1-initrd") + set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-initrd") else() - set(linux_binary_name "linux-tk1-debian") + set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-debian") endif() + + set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT "${dtb_file}" COMMAND - dtc -I dts -O dtb -o linux/linux-dtb ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} + dtc -I dts -O dtb -o ${dtb_file} ${device_tree_src} VERBATIM - DEPENDS ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} + DEPENDS ${device_tree_src} ) # Create custom target for setting the dtb - add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") + add_custom_target(set_dtb DEPENDS "${dtb_file}") # Add Linux VM images into file server - AddToFileServer("linux" "${CAMKES_ARM_LINUX_DIR}/${linux_binary_name}") - AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) + AddToFileServer("linux" "${linux_binary_name}") + AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb) elseif("${KernelARMPlatform}" STREQUAL "tx1") set(cpp_flags "-DKERNELARMPLATFORM_TX1") @@ -146,18 +148,18 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102") ) set(dts_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux.dts") - + set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb + OUTPUT ${dtb_file} COMMAND - dtc -q -I dts -O dtb -o linux/linux-dtb ${dts_file} + dtc -q -I dts -O dtb -o ${dtb_file} ${dts_file} VERBATIM DEPENDS ${dts_file} ) # Create custom target for setting the dtb - add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") - AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) + add_custom_target(set_dtb DEPENDS "${dtb_file}") + AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb) list(APPEND cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm/plat_include/zynqmp") endif() diff --git a/apps/x86/zmq_samples/CMakeLists.txt b/apps/x86/zmq_samples/CMakeLists.txt index aa6e69ec..f8d80204 100644 --- a/apps/x86/zmq_samples/CMakeLists.txt +++ b/apps/x86/zmq_samples/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(camkes-vm-linux REQUIRED) include(${CAMKES_VM_LINUX_HELPERS_PATH}) if(CAKEML_FILTER) + set(zmq_camkes "zmq_cakeml.camkes") include("libs/cakeml_helpers.cmake") # Number of vms. @@ -37,6 +38,7 @@ if(CAKEML_FILTER) 50 ) else() + set(zmq_camkes "zmq_samples.camkes") # Number of vms. set(NumberVMs 3) endif() @@ -134,29 +136,26 @@ AddZMQBinary(pub) AddZMQBinary(sub) foreach(i RANGE ${NumberVMsLess1}) + set(overlay_target "overlay_vm${i}") + set(rootfs_target "rootfs_target_vm${i}") if(NOT CAKEML_FILTER) AddFileToOverlayDir( "S91zmq_bench" ${CMAKE_CURRENT_SOURCE_DIR}/src/user/zmq_bench_${i}.sh "etc/init.d" - overlay_vm${i} + "${overlay_target}" ) endif() # Add the buildroot overlay to our bare rootfs image AddOverlayDirToRootfs( - overlay_vm${i} - ${rootfs_file} + "${overlay_target}" + "${rootfs_file}" "buildroot" "rootfs_install" - output_rootfs_location_vm${i} - rootfs_target_vm${i} - ) - AddToFileServer( - "vm${i}_rootfs.cpio" - "${output_rootfs_location_vm${i}}" - DEPENDS - rootfs_target_vm${i} + rootfs_img + "${rootfs_target}" ) + AddToFileServer("vm${i}_rootfs.cpio" "${rootfs_img}" DEPENDS "${rootfs_target}") endforeach() # Decompress Linux Kernel image and add to file server @@ -164,8 +163,4 @@ DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) # Initialise CAmkES Root Server with addition CPP includes -if(CAKEML_FILTER) - DeclareCAmkESVMRootServer(zmq_cakeml.camkes) -else() - DeclareCAmkESVMRootServer(zmq_samples.camkes) -endif() +DeclareCAmkESVMRootServer("${zmq_camkes}")