From cc104eb05b9276aab9b830263b0274e87dc5cd28 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 8 May 2018 15:33:21 +0800 Subject: [PATCH] cmake: Add sdkconfig.h directory to include paths list not just compiler args Also move into 'build/config/' subdir, remove creation of empty include/config dir. --- components/esp32/CMakeLists.txt | 4 ++-- docs/en/api-guides/build-system.rst | 2 +- tools/cmake/idf_functions.cmake | 2 -- tools/cmake/kconfig.cmake | 12 ++++++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 2c4fc74298..3a514d9905 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -65,8 +65,8 @@ else() set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld) add_custom_command( OUTPUT esp32_out.ld - COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CMAKE_BINARY_DIR} ${LD_DIR}/esp32.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32.ld + COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp32.ld + MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${SDKCONFIG_H} COMMENT "Generating linker script..." VERBATIM) add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 2135ca0a2a..d63c54c2e9 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -825,7 +825,7 @@ For integration into IDEs and other build systems, when cmake runs the build pro - ``project_description.json`` contains some general information about the ESP-IDF project, configured paths, etc. - ``flasher_args.json`` contains esptool.py arguments to flash the project's binary files. There are also ``flash_*_args`` files which can be used directly with esptool.py. See `Flash arguments`_. - ``CMakeCache.txt`` is the CMake cache file which contains other information about the CMake process, toolchain, etc. -- ``sdkconfig.json`` is a JSON-formatted version of the project configuration values. +- ``config/sdkconfig.json`` is a JSON-formatted version of the project configuration values. .. _esp-idf-template: https://github.com/espressif/esp-idf-template .. _cmake: https://cmake.org diff --git a/tools/cmake/idf_functions.cmake b/tools/cmake/idf_functions.cmake index 3415f9da29..bd0aea6e55 100644 --- a/tools/cmake/idf_functions.cmake +++ b/tools/cmake/idf_functions.cmake @@ -98,8 +98,6 @@ function(idf_set_global_compiler_options) # go into the final binary so have no impact on size) add_compile_options(-ggdb) - add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h - # Enable ccache if it's on the path if(NOT CCACHE_DISABLE) find_program(CCACHE_FOUND ccache) diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 10894f6ad4..f20002e1a5 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -1,14 +1,18 @@ include(ExternalProject) macro(kconfig_set_variables) + set(CONFIG_DIR ${CMAKE_BINARY_DIR}/config) set_default(SDKCONFIG ${PROJECT_PATH}/sdkconfig) - set(SDKCONFIG_HEADER ${CMAKE_BINARY_DIR}/sdkconfig.h) - set(SDKCONFIG_CMAKE ${CMAKE_BINARY_DIR}/sdkconfig.cmake) - set(SDKCONFIG_JSON ${CMAKE_BINARY_DIR}/sdkconfig.json) + set(SDKCONFIG_HEADER ${CONFIG_DIR}/sdkconfig.h) + set(SDKCONFIG_CMAKE ${CONFIG_DIR}/sdkconfig.cmake) + set(SDKCONFIG_JSON ${CONFIG_DIR}/sdkconfig.json) set(ROOT_KCONFIG ${IDF_PATH}/Kconfig) set_default(SDKCONFIG_DEFAULTS "${SDKCONFIG}.defaults") + + # ensure all source files can include sdkconfig.h + include_directories("${CONFIG_DIR}") endmacro() if(CMAKE_HOST_WIN32) @@ -48,7 +52,7 @@ endif() # Find all Kconfig files for all components function(kconfig_process_config) - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/config") + file(MAKE_DIRECTORY "${CONFIG_DIR}") set(kconfigs) set(kconfigs_projbuild) -- 2.40.0