From 9f936d3351af69377315f810a2bfbc20f94aa16b 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 | 24 ++++++++++++------------ apps/x86/zmq_samples/CMakeLists.txt | 27 +++++++++++---------------- 3 files changed, 29 insertions(+), 32 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 2469f648..b5d62b1d 100644 --- a/apps/Arm/vm_minimal/CMakeLists.txt +++ b/apps/Arm/vm_minimal/CMakeLists.txt @@ -16,30 +16,30 @@ 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(output_dtb_location "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") add_custom_command( - OUTPUT linux/linux-dtb - COMMAND - bash -c - "which dtc && dtc -I dts -O dtb ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} > linux/linux-dtb" + OUTPUT "${output_dtb_location}" + COMMAND bash -c "which dtc && dtc -I dts -O dtb ${device_tree_src} > ${output_dtb_location}" 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 "${output_dtb_location}") # 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" "${output_dtb_location}" DEPENDS set_dtb) elseif("${KernelARMPlatform}" STREQUAL "tx1") set(cpp_flags "-DKERNELARMPLATFORM_TX1") 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}")