idf.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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}/../.." REALPATH)
  5. file(TO_CMAKE_PATH "${_idf_path}" _idf_path)
  6. # Get the path set in environment
  7. set(idf_path $ENV{IDF_PATH})
  8. # Environment IDF_PATH should match the inferred IDF_PATH. If not, warn the user.
  9. # (Note: REALPATH is needed in both above steps to account for case on case
  10. # insensitive filesystems, or relative paths)
  11. if(idf_path)
  12. get_filename_component(idf_path "${idf_path}" REALPATH)
  13. file(TO_CMAKE_PATH "${idf_path}" idf_path)
  14. if(NOT idf_path STREQUAL _idf_path)
  15. message(WARNING "IDF_PATH environment variable is different from inferred IDF_PATH.
  16. Check if your project's top-level CMakeLists.txt includes the right
  17. CMake files. Environment IDF_PATH will be used for the build:
  18. ${idf_path}")
  19. endif()
  20. else()
  21. message(WARNING "IDF_PATH environment variable not found. Setting IDF_PATH to '${_idf_path}'.")
  22. set(idf_path ${_idf_path})
  23. set(ENV{IDF_PATH} ${_idf_path})
  24. endif()
  25. # Include other CMake modules required
  26. set(CMAKE_MODULE_PATH
  27. "${idf_path}/tools/cmake"
  28. "${idf_path}/tools/cmake/third_party"
  29. ${CMAKE_MODULE_PATH})
  30. include(build)
  31. set(IDF_PATH ${idf_path})
  32. include(GetGitRevisionDescription)
  33. include(git_submodules)
  34. include(crosstool_version_check)
  35. include(kconfig)
  36. include(component)
  37. include(utilities)
  38. include(targets)
  39. include(ldgen)
  40. include(dfu)
  41. include(uf2)
  42. include(version)
  43. __build_init("${idf_path}")
  44. # Check if IDF_ENV_FPGA environment is set
  45. set(env_idf_env_fpga $ENV{IDF_ENV_FPGA})
  46. if(${env_idf_env_fpga})
  47. idf_build_set_property(__IDF_ENV_FPGA "y")
  48. message(NOTICE "IDF_ENV_FPGA is set, building for FPGA environment")
  49. endif()
  50. set_property(GLOBAL PROPERTY __IDF_ENV_SET 1)
  51. endif()