Skip to content

Commit ac2c5ab

Browse files
committed
CMake: Add test for multiple-executable support
Add a test to build two executables in two directories under a single project.
1 parent 8b7b803 commit ac2c5ab

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: test building multiple executables with CMake
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
multiple-executables-example:
7+
runs-on: ubuntu-latest
8+
container: mbedos/mbed-os-env:latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Build the multiple_executables example
14+
run: |
15+
mbedtools compile \
16+
-t GCC_ARM \
17+
-m ARM_MUSCA_S1 \
18+
--program-path tools/cmake/tests/multiple_executables/ \
19+
--mbed-os-path .
20+
21+
- name: Verify the post-build command has run successfully on each image
22+
run: |
23+
APP1=tools/cmake/tests/multiple_executables/cmake_build/ARM_MUSCA_S1/develop/GCC_ARM/app1/app1.bin
24+
APP2=tools/cmake/tests/multiple_executables/cmake_build/ARM_MUSCA_S1/develop/GCC_ARM/app2/app2.bin
25+
BOOTLOADER=targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/bl2.bin
26+
BOOTLOADER_SIZE=`du -b targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/bl2.bin | cut -f1`
27+
cmp -n $BOOTLOADER_SIZE $APP1 $BOOTLOADER
28+
cmp -n $BOOTLOADER_SIZE $APP2 $BOOTLOADER
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2021 Arm Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.19.0)
5+
6+
set(MBED_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
7+
set(MBED_CONFIG_PATH "${CMAKE_CURRENT_BINARY_DIR}")
8+
9+
include("${MBED_PATH}/tools/cmake/app.cmake")
10+
11+
project(multiple_executables)
12+
13+
add_subdirectory("${MBED_PATH}" "mbed-os-build")
14+
15+
add_subdirectory(app1)
16+
add_subdirectory(app2)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2021 Arm Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(APP_TARGET app1)
5+
6+
add_executable(${APP_TARGET} main.cpp)
7+
8+
target_link_libraries(${APP_TARGET} mbed-os)
9+
10+
mbed_set_post_build(${APP_TARGET})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2021 Arm Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include "mbed.h"
7+
8+
int main()
9+
{
10+
printf("Application 1\n");
11+
return 0;
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2021 Arm Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(APP_TARGET app2)
5+
6+
add_executable(${APP_TARGET} main.cpp)
7+
8+
target_link_libraries(${APP_TARGET} mbed-os)
9+
10+
mbed_set_post_build(${APP_TARGET})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2021 Arm Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include "mbed.h"
7+
8+
int main()
9+
{
10+
printf("Application 2\n");
11+
return 0;
12+
}

0 commit comments

Comments
 (0)