cmake: Automatically include ccache if it's on the path

This commit is contained in:
Angus Gratton 2018-02-27 13:32:52 +11:00 committed by Angus Gratton
parent 9f8cdd3572
commit 15d5e88618
4 changed files with 21 additions and 3 deletions

View File

@ -12,15 +12,15 @@ To compile with ESP-IDF you need to get the following packages:
- CentOS 7::
sudo yum install git wget ncurses-devel flex bison gperf python pyserial cmake ninja-build
sudo yum install git wget ncurses-devel flex bison gperf python pyserial cmake ninja-build ccache
- Ubuntu and Debian::
sudo apt-get install git wget libncurses-dev flex bison gperf python python-serial cmake ninja-build
sudo apt-get install git wget libncurses-dev flex bison gperf python python-serial cmake ninja-build ccache
- Arch::
sudo pacman -S --needed gcc git make ncurses flex bison gperf python2-pyserial cmake ninja
sudo pacman -S --needed gcc git make ncurses flex bison gperf python2-pyserial cmake ninja ccache
.. note::
CMake version 3.5 or newer is required for use with ESP-IDF. Older Linux distributions may require updating, or enabling of a "backports" repository, or installing of a "cmake3" package not "cmake")

View File

@ -24,6 +24,8 @@ Install Prerequisites
Otherwise, consult the CMake_ and Ninja_ home pages for Mac OS installation.
- It is strongly recommended to also install ccache_ for faster builds. If you have HomeBrew, this can be done via ``brew install ccache``.
Toolchain Setup
===============
@ -59,3 +61,4 @@ To carry on with development environment setup, proceed to section :ref:`get-sta
.. _cmake: https://cmake.org/
.. _ninja: https://ninja-build.org/
.. _ccache: https://ccache.samba.org/

View File

@ -0,0 +1,8 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(MAIN_SRCS main/blink.c)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(blink)

View File

@ -86,6 +86,13 @@ function(idf_set_global_compiler_options)
add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h
# Enable ccache if it's on the path
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "ccache will be used")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif()
endfunction(idf_set_global_compiler_options)