cmake: Use prebuilt mconf on Windows

Closes https://github.com/espressif/esp-idf/issues/1905
This commit is contained in:
Angus Gratton 2018-05-01 15:42:28 +10:00 committed by Angus Gratton
parent f6db61e4f4
commit c42b791aaa

View file

@ -1,8 +1,6 @@
include(ExternalProject) include(ExternalProject)
macro(kconfig_set_variables) macro(kconfig_set_variables)
set(MCONF kconfig_bin/mconf)
set_default(SDKCONFIG ${PROJECT_PATH}/sdkconfig) set_default(SDKCONFIG ${PROJECT_PATH}/sdkconfig)
set(SDKCONFIG_HEADER ${CMAKE_BINARY_DIR}/sdkconfig.h) set(SDKCONFIG_HEADER ${CMAKE_BINARY_DIR}/sdkconfig.h)
set(SDKCONFIG_CMAKE ${CMAKE_BINARY_DIR}/sdkconfig.cmake) set(SDKCONFIG_CMAKE ${CMAKE_BINARY_DIR}/sdkconfig.cmake)
@ -13,9 +11,26 @@ macro(kconfig_set_variables)
set_default(SDKCONFIG_DEFAULTS "${SDKCONFIG}.defaults") set_default(SDKCONFIG_DEFAULTS "${SDKCONFIG}.defaults")
endmacro() endmacro()
if(CMAKE_HOST_WIN32)
# Prefer a prebuilt mconf on Windows
find_program(MCONF mconf)
if(NOT MCONF)
find_program(NATIVE_GCC gcc)
if(NOT NATIVE_GCC)
message(FATAL_ERROR
"Windows requires a prebuilt ESP-IDF-specific mconf for your platform "
"on the PATH, or an MSYS2 version of gcc on the PATH to build mconf. "
"Consult the setup docs for ESP-IDF on Windows.")
endif()
endif()
endif()
if(NOT MCONF)
# Use the existing Makefile to build mconf (out of tree) when needed # Use the existing Makefile to build mconf (out of tree) when needed
# #
# TODO: Download(?) a prebuilt mingw mconf on Windows set(MCONF kconfig_bin/mconf)
externalproject_add(mconf externalproject_add(mconf
SOURCE_DIR ${IDF_PATH}/tools/kconfig SOURCE_DIR ${IDF_PATH}/tools/kconfig
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
@ -25,7 +40,8 @@ externalproject_add(mconf
INSTALL_COMMAND "" INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_ALL 1
) )
set(menuconfig_depends DEPENDS mconf)
endif()
# Find all Kconfig files for all components # Find all Kconfig files for all components
function(kconfig_process_config) function(kconfig_process_config)
@ -66,9 +82,9 @@ function(kconfig_process_config)
--env "COMPONENT_KCONFIGS=${kconfigs}" --env "COMPONENT_KCONFIGS=${kconfigs}"
--env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}") --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}")
# Generate the menuconfig target (uses C-based mconf tool) # Generate the menuconfig target (uses C-based mconf tool, either prebuilt or via mconf target above)
add_custom_target(menuconfig add_custom_target(menuconfig
DEPENDS mconf ${menuconfig_depends}
# create any missing config file, with defaults if necessary # create any missing config file, with defaults if necessary
COMMAND ${confgen_basecommand} --output config ${SDKCONFIG} COMMAND ${confgen_basecommand} --output config ${SDKCONFIG}
COMMAND ${CMAKE_COMMAND} -E env COMMAND ${CMAKE_COMMAND} -E env