idf.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. get_property(__idf_env_set GLOBAL PROPERTY __IDF_ENV_SET)
  2. if(NOT __idf_env_set)
  3. # Infer an IDF_PATH relative to the tools/cmake directory
  4. get_filename_component(_idf_path "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
  5. file(TO_CMAKE_PATH "${_idf_path}" _idf_path)
  6. # Get the path set in environment
  7. set(idf_path $ENV{IDF_PATH})
  8. file(TO_CMAKE_PATH "${idf_path}" idf_path)
  9. # Environment IDF_PATH should match the inferred IDF_PATH. If not, warn the user.
  10. if(idf_path)
  11. if(NOT idf_path STREQUAL _idf_path)
  12. message(WARNING "IDF_PATH environment variable is different from inferred IDF_PATH.
  13. Check if your project's top-level CMakeLists.txt includes the right
  14. CMake files. Environment IDF_PATH will be used for the build.")
  15. endif()
  16. else()
  17. message(WARNING "IDF_PATH environment variable not found. Setting IDF_PATH to '${_idf_path}'.")
  18. set(idf_path ${_idf_path})
  19. set(ENV{IDF_PATH} ${_idf_path})
  20. endif()
  21. # Include other CMake modules required
  22. set(CMAKE_MODULE_PATH
  23. "${idf_path}/tools/cmake"
  24. "${idf_path}/tools/cmake/third_party"
  25. ${CMAKE_MODULE_PATH})
  26. include(build)
  27. set(IDF_PATH ${idf_path})
  28. include(GetGitRevisionDescription)
  29. include(git_submodules)
  30. include(crosstool_version_check)
  31. include(kconfig)
  32. include(component)
  33. include(utilities)
  34. include(targets)
  35. include(ldgen)
  36. include(version)
  37. __build_init("${idf_path}")
  38. set_property(GLOBAL PROPERTY __IDF_ENV_SET 1)
  39. endif()