Merge branch 'feature/esp_platform_cmake_pr2601' into 'master'
cmake: Add ESP_PLATFORM in CMake build (PR 2601) See merge request idf/esp-idf!3823
This commit is contained in:
commit
6578673ed4
5 changed files with 22 additions and 7 deletions
|
@ -32,7 +32,13 @@ execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||||
-D "IDF_PATH=${IDF_PATH}"
|
-D "IDF_PATH=${IDF_PATH}"
|
||||||
-D "DEBUG=${DEBUG}"
|
-D "DEBUG=${DEBUG}"
|
||||||
-P "${IDF_PATH}/tools/cmake/scripts/expand_requirements.cmake"
|
-P "${IDF_PATH}/tools/cmake/scripts/expand_requirements.cmake"
|
||||||
WORKING_DIRECTORY "${PROJECT_PATH}")
|
WORKING_DIRECTORY "${PROJECT_PATH}"
|
||||||
|
RESULT_VARIABLE expand_requirements_result)
|
||||||
|
|
||||||
|
if(expand_requirements_result)
|
||||||
|
message(FATAL_ERROR "Failed to expand component requirements")
|
||||||
|
endif()
|
||||||
|
|
||||||
include("${CMAKE_BINARY_DIR}/component_depends.cmake")
|
include("${CMAKE_BINARY_DIR}/component_depends.cmake")
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -344,10 +344,12 @@ The following variables are set at the project level, but available for use in c
|
||||||
- ``IDF_TARGET``: Name of the target for which the project is being built.
|
- ``IDF_TARGET``: Name of the target for which the project is being built.
|
||||||
- ``PROJECT_VER``: Project version.
|
- ``PROJECT_VER``: Project version.
|
||||||
|
|
||||||
* If ``PROJECT_VER`` variable set in project CMakeLists.txt file, its value will be used.
|
* If ``PROJECT_VER`` variable set in project CMakeLists.txt file, its value will be used.
|
||||||
* Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
|
* Else, if the ``$PROJECT_PATH/version.txt`` exists, its contents will be used as ``PROJECT_VER``.
|
||||||
* Else, if the project is located inside a Git repository, the output of git describe will be used.
|
* Else, if the project is located inside a Git repository, the output of git describe will be used.
|
||||||
* Otherwise, ``PROJECT_VER`` will be "1".
|
* Otherwise, ``PROJECT_VER`` will be "1".
|
||||||
|
|
||||||
|
- ``ESP_PLATFORM``: Set to 1 whenever the ESP-IDF build system is being used.
|
||||||
|
|
||||||
If you modify any of these variables inside ``CMakeLists.txt`` then this will not prevent other components from building but it may make your component hard to build and/or debug.
|
If you modify any of these variables inside ``CMakeLists.txt`` then this will not prevent other components from building but it may make your component hard to build and/or debug.
|
||||||
|
|
||||||
|
@ -903,6 +905,9 @@ import it from other projects. Studying the library's CMakeLists.txt and build s
|
||||||
It is also possible to wrap a third-party library to be used as a component in this manner. For example, the :component:`mbedtls` component is a wrapper for
|
It is also possible to wrap a third-party library to be used as a component in this manner. For example, the :component:`mbedtls` component is a wrapper for
|
||||||
Espressif's fork of `mbedtls <https://github.com/ARMmbed/mbedtls>`_. See its :component_file:`component CMakeLists.txt <mbedtls/CMakeLists.txt>`.
|
Espressif's fork of `mbedtls <https://github.com/ARMmbed/mbedtls>`_. See its :component_file:`component CMakeLists.txt <mbedtls/CMakeLists.txt>`.
|
||||||
|
|
||||||
|
The CMake variable ``ESP_PLATFORM`` is set to 1 whenever the ESP-IDF build system is being used. Tests such as ``if (ESP_PLATFORM)`` can be used in generic CMake code if special IDF-specific logic is required.
|
||||||
|
|
||||||
|
|
||||||
Using ESP-IDF in Custom CMake Projects
|
Using ESP-IDF in Custom CMake Projects
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ macro(idf_set_variables)
|
||||||
|
|
||||||
set(IDF_PROJECT_PATH "${CMAKE_SOURCE_DIR}")
|
set(IDF_PROJECT_PATH "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
|
set(ESP_PLATFORM 1 CACHE BOOL INTERNAL)
|
||||||
|
|
||||||
spaces2list(IDF_COMPONENT_DIRS)
|
spaces2list(IDF_COMPONENT_DIRS)
|
||||||
spaces2list(IDF_COMPONENTS)
|
spaces2list(IDF_COMPONENTS)
|
||||||
spaces2list(IDF_COMPONENT_REQUIRES_COMMON)
|
spaces2list(IDF_COMPONENT_REQUIRES_COMMON)
|
||||||
|
|
|
@ -33,6 +33,8 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
include("${IDF_PATH}/tools/cmake/utilities.cmake")
|
include("${IDF_PATH}/tools/cmake/utilities.cmake")
|
||||||
include("${IDF_PATH}/tools/cmake/component_utils.cmake")
|
include("${IDF_PATH}/tools/cmake/component_utils.cmake")
|
||||||
|
|
||||||
|
set(ESP_PLATFORM 1)
|
||||||
|
|
||||||
if(NOT DEPENDENCIES_FILE)
|
if(NOT DEPENDENCIES_FILE)
|
||||||
message(FATAL_ERROR "DEPENDENCIES_FILE must be set.")
|
message(FATAL_ERROR "DEPENDENCIES_FILE must be set.")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -165,7 +165,7 @@ def _ensure_build_directory(args, always_run_cmake=False):
|
||||||
if args.generator is None:
|
if args.generator is None:
|
||||||
args.generator = detect_cmake_generator()
|
args.generator = detect_cmake_generator()
|
||||||
try:
|
try:
|
||||||
cmake_args = ["cmake", "-G", args.generator, "-DPYTHON_DEPS_CHECKED=1"]
|
cmake_args = ["cmake", "-G", args.generator, "-DPYTHON_DEPS_CHECKED=1", "-DESP_PLATFORM=1"]
|
||||||
if not args.no_warnings:
|
if not args.no_warnings:
|
||||||
cmake_args += ["--warn-uninitialized"]
|
cmake_args += ["--warn-uninitialized"]
|
||||||
if args.no_ccache:
|
if args.no_ccache:
|
||||||
|
|
Loading…
Reference in a new issue