Browse Source

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.
Angus Gratton 7 years ago
parent
commit
cc104eb05b

+ 2 - 2
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)

+ 1 - 1
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

+ 0 - 2
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)

+ 8 - 4
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)