diff --git a/docs/en/get-started/linux-setup-cmake.rst b/docs/en/get-started/linux-setup-cmake.rst index 2f54092fe..2e3bbdbbe 100644 --- a/docs/en/get-started/linux-setup-cmake.rst +++ b/docs/en/get-started/linux-setup-cmake.rst @@ -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") diff --git a/docs/en/get-started/macos-setup-cmake.rst b/docs/en/get-started/macos-setup-cmake.rst index 91a6c9dc4..ce5623a53 100644 --- a/docs/en/get-started/macos-setup-cmake.rst +++ b/docs/en/get-started/macos-setup-cmake.rst @@ -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/ diff --git a/examples/get-started/blink/CMakeLists.txt b/examples/get-started/blink/CMakeLists.txt new file mode 100644 index 000000000..56450928b --- /dev/null +++ b/examples/get-started/blink/CMakeLists.txt @@ -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) diff --git a/tools/cmake/idf_functions.cmake b/tools/cmake/idf_functions.cmake index 9bea6f760..2cb406e18 100644 --- a/tools/cmake/idf_functions.cmake +++ b/tools/cmake/idf_functions.cmake @@ -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)