Skip to content

Commit a759039

Browse files
committed
Add CMakelists
CMake support is still development. For more information, see mbed-os/cmake/README.md
1 parent 094ca61 commit a759039

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

.travis.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright (c) 2013-2020 Arm Limited. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the License); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
language: sh
18+
os: linux
19+
dist: xenial
20+
21+
cache:
22+
pip: true
23+
ccache: true
24+
# It looks like ccache for arm-none-eabi is not yet supported by Travis.
25+
# Therefore manually adding ccache directory to cache
26+
directories:
27+
- ${HOME}/.ccache
28+
29+
addons:
30+
apt:
31+
packages:
32+
- ninja-build
33+
34+
matrix:
35+
include:
36+
37+
- &cmake-build-test
38+
stage: "CMake"
39+
name: "CMake blinky example - develop (K64F)"
40+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=develop CACHE_NAME=develop-K64F
41+
language: python
42+
python: 3.8
43+
install:
44+
# Setup ccache
45+
- ccache -o compiler_check=content
46+
- ccache -M 1G
47+
- pushd /usr/lib/ccache
48+
- sudo ln -s ../../bin/ccache arm-none-eabi-gcc
49+
- sudo ln -s ../../bin/ccache arm-none-eabi-g++
50+
- export PATH="/usr/lib/ccache:$PATH"
51+
- popd
52+
# Install arm-none-eabi-gcc
53+
- pushd /home/travis/build && mkdir arm-gcc && cd arm-gcc
54+
- curl -L0 "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2?revision=05382cca-1721-44e1-ae19-1e7c3dc96118&la=en&hash=D7C9D18FCA2DD9F894FD9F3C3DC9228498FA281A" --output gcc-arm-none-eabi-9-2020-q2-update.tar.bz2
55+
- tar xf gcc-arm-none-eabi-9-2020-q2-update.tar.bz2
56+
- export PATH="$PATH:${PWD}/gcc-arm-none-eabi-9-2020-q2-update/bin"
57+
- popd
58+
- arm-none-eabi-gcc --version
59+
- pip install --upgrade cmake
60+
- pip install --upgrade mbed-tools
61+
# Fetch mbed-os: We use manual clone, with depth=1 and --single-branch to save time.
62+
- >-
63+
git clone --depth=1 --single-branch https://github.com/ARMmbed/mbed-os.git;
64+
- >-
65+
mbedtools configure -t GCC_ARM -m ${TARGET_NAME};
66+
mkdir -p build
67+
script:
68+
- cd build && cmake .. -GNinja -DCMAKE_BUILD_TYPE=${PROFILE} && cmake --build .
69+
- ccache -s
70+
71+
- <<: *cmake-build-test
72+
name: "CMake blinky example - release (K64F)"
73+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=release CACHE_NAME=release-K64F
74+
75+
- <<: *cmake-build-test
76+
name: "CMake blinky example - debug (K64F)"
77+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=debug CACHE_NAME=debug-K64F
78+
79+
- <<: *cmake-build-test
80+
name: "CMake blinky example - develop (DISCO_L475VG_IOT01A)"
81+
env: NAME=cmake_test TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=develop CACHE_NAME=develop-DISCO_L475VG_IOT01A
82+
83+
- <<: *cmake-build-test
84+
name: "CMake blinky example - release (DISCO_L475VG_IOT01A)"
85+
env: NAME=cmake_test TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=release CACHE_NAME=release-DISCO_L475VG_IOT01A
86+
87+
- <<: *cmake-build-test
88+
name: "CMake blinky example - debug (DISCO_L475VG_IOT01A)"
89+
env: NAME=cmake_test TARGET_NAME=DISCO_L475VG_IOT01A PROFILE=debug CACHE_NAME=debug-DISCO_L475VG_IOT01A
90+
91+
- <<: *cmake-build-test
92+
name: "CMake blinky example - develop (NRF52840_DK)"
93+
env: NAME=cmake_test TARGET_NAME=NRF52840_DK PROFILE=develop CACHE_NAME=develop-NRF52840_DK
94+
95+
- <<: *cmake-build-test
96+
name: "CMake blinky example - release (NRF52840_DK)"
97+
env: NAME=cmake_test TARGET_NAME=NRF52840_DK PROFILE=release CACHE_NAME=release-NRF52840_DK
98+
99+
- <<: *cmake-build-test
100+
name: "CMake blinky example - debug (NRF52840_DK)"
101+
env: NAME=cmake_test TARGET_NAME=NRF52840_DK PROFILE=debug CACHE_NAME=debug-NRF52840_DK

CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.18.2 FATAL_ERROR)
5+
6+
# TODO: @mbed-os-tools MBED_ROOT and MBED_CONFIG_PATH should probably come from mbedtools
7+
set(MBED_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
8+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
9+
set(APP_TARGET mbed-os-example-blinky)
10+
11+
add_subdirectory(${MBED_ROOT})
12+
13+
add_executable(${APP_TARGET})
14+
15+
mbed_configure_app_target(${APP_TARGET})
16+
17+
mbed_set_mbed_target_linker_script(${APP_TARGET})
18+
19+
project(${APP_TARGET})
20+
21+
target_sources(${APP_TARGET}
22+
PRIVATE
23+
main.cpp
24+
)
25+
26+
target_link_libraries(${APP_TARGET} mbed-os)
27+
28+
mbed_generate_bin_hex(${APP_TARGET})
29+
30+
option(VERBOSE_BUILD "Have a verbose build process")
31+
if(VERBOSE_BUILD)
32+
set(CMAKE_VERBOSE_MAKEFILE ON)
33+
endif()

0 commit comments

Comments
 (0)