Skip to content

Commit b53c22c

Browse files
authored
Merge pull request #323 from ARMmbed/add_cmakelists
Add CMake support
2 parents d85086d + ea38da6 commit b53c22c

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

.travis.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright (c) 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+
env:
22+
global:
23+
- PROFILE=develop
24+
25+
cache:
26+
pip: true
27+
ccache: true
28+
# It looks like ccache for arm-none-eabi is not yet supported by Travis.
29+
# Therefore manually adding ccache directory to cache
30+
directories:
31+
- ${HOME}/.ccache
32+
33+
addons:
34+
apt:
35+
sources:
36+
- sourceline: 'deb https://apt.kitware.com/ubuntu/ xenial main'
37+
key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc'
38+
- sourceline: 'deb https://apt.kitware.com/ubuntu/ xenial-rc main'
39+
packages:
40+
- cmake
41+
- ninja-build
42+
43+
matrix:
44+
include:
45+
46+
- &cmake-build-test
47+
stage: "CMake"
48+
name: "CMake mesh minimal example - develop (K64F)"
49+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=develop CACHE_NAME=develop-K64F
50+
language: python
51+
python: 3.8
52+
install:
53+
# Setup ccache
54+
- ccache -o compiler_check=content
55+
- ccache -M 1G
56+
- pushd /usr/lib/ccache
57+
- sudo ln -s ../../bin/ccache arm-none-eabi-gcc
58+
- sudo ln -s ../../bin/ccache arm-none-eabi-g++
59+
- export PATH="/usr/lib/ccache:$PATH"
60+
- popd
61+
# Install arm-none-eabi-gcc
62+
- pushd /home/travis/build && mkdir arm-gcc && cd arm-gcc
63+
- 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
64+
- tar xf gcc-arm-none-eabi-9-2020-q2-update.tar.bz2
65+
- export PATH="$PATH:${PWD}/gcc-arm-none-eabi-9-2020-q2-update/bin"
66+
- popd
67+
- arm-none-eabi-gcc --version
68+
# Hide Travis-preinstalled CMake
69+
# The Travis-preinstalled CMake is unfortunately not installed via apt, so we
70+
# can't replace it with an apt-supplied version very easily. Additionally, we
71+
# can't permit the Travis-preinstalled copy to survive, as the Travis default
72+
# path lists the Travis CMake install location ahead of any place where apt
73+
# would install CMake to. Instead of apt removing or upgrading to a new CMake
74+
# version, we must instead delete the Travis copy of CMake.
75+
- sudo rm -rf /usr/local/cmake*
76+
- pip install --upgrade mbed-tools
77+
- pip install prettytable==0.7.2
78+
- pip install future==0.16.0
79+
- pip install "Jinja2>=2.10.1,<2.11"
80+
- pip install "intelhex>=1.3,<=2.2.1"
81+
script:
82+
- mbedtools checkout
83+
- echo mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
84+
- mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
85+
- ccache -s
86+
87+
- <<: *cmake-build-test
88+
name: "CMake mesh minimal example - release (K64F)"
89+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=release CACHE_NAME=release-K64F
90+
91+
- <<: *cmake-build-test
92+
name: "CMake mesh minimal example - debug (K64F)"
93+
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=debug CACHE_NAME=debug-K64F
94+
95+
- <<: *cmake-build-test
96+
name: "CMake mesh minimal example - develop (NUCLEO_F401RE)"
97+
env: NAME=cmake_test TARGET_NAME=NUCLEO_F401RE PROFILE=develop CACHE_NAME=develop-NUCLEO_F401RE
98+
99+
- <<: *cmake-build-test
100+
name: "CMake mesh minimal example - release (NUCLEO_F401RE)"
101+
env: NAME=cmake_test TARGET_NAME=NUCLEO_F401RE PROFILE=release CACHE_NAME=release-NUCLEO_F401RE
102+
103+
- <<: *cmake-build-test
104+
name: "CMake mesh minimal example - debug (NUCLEO_F401RE)"
105+
env: NAME=cmake_test TARGET_NAME=NUCLEO_F401RE PROFILE=debug CACHE_NAME=debug-NUCLEO_F401RE

CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
5+
6+
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
7+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
8+
set(APP_TARGET mbed-os-example-mesh-minimal)
9+
10+
include(${MBED_PATH}/tools/cmake/app.cmake)
11+
12+
add_subdirectory(${MBED_PATH})
13+
14+
add_executable(${APP_TARGET})
15+
16+
mbed_configure_app_target(${APP_TARGET})
17+
18+
mbed_set_mbed_target_linker_script(${APP_TARGET})
19+
20+
project(${APP_TARGET})
21+
22+
target_include_directories(${APP_TARGET}
23+
PRIVATE
24+
.
25+
)
26+
27+
target_sources(${APP_TARGET}
28+
PRIVATE
29+
main.cpp
30+
mesh_led_control_example.cpp
31+
mesh_nvm.cpp
32+
)
33+
34+
target_link_libraries(${APP_TARGET}
35+
PRIVATE
36+
mbed-os
37+
mbed-mbedtls
38+
mbed-nanostack
39+
)
40+
41+
mbed_set_post_build(${APP_TARGET})
42+
43+
option(VERBOSE_BUILD "Have a verbose build process")
44+
if(VERBOSE_BUILD)
45+
set(CMAKE_VERBOSE_MAKEFILE ON)
46+
endif()

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#f2278567d09b9ae9f4843e1d9d393526b9462783
1+
https://github.com/ARMmbed/mbed-os/

0 commit comments

Comments
 (0)