pico_pre_load_toolchain.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, default=none (i.e. search system paths), group=build
  2. set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "")
  3. # Set a default build type if none was specified
  4. set(default_build_type "Release")
  5. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  6. message(STATUS "Defaulting build type to '${default_build_type}' since not specified.")
  7. set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build, options are: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo'." FORCE)
  8. # Set the possible values of build type for cmake-gui
  9. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
  10. "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
  11. endif()
  12. if (CMAKE_BUILD_TYPE STREQUAL "Default")
  13. error("Default build type is NOT supported")
  14. endif()
  15. # PICO_CMAKE_CONFIG: PICO_COMPILER, Optionally specifies a different compiler (other than pico_arm_gcc.cmake) - this is not yet fully supported, default=none, group=build
  16. # If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
  17. if (DEFINED PICO_COMPILER)
  18. if (DEFINED CMAKE_TOOLCHAIN_FILE)
  19. get_filename_component(toolchain "${CMAKE_TOOLCHAIN_FILE}" NAME_WE)
  20. if (NOT "${PICO_COMPILER}" STREQUAL "${toolchain}")
  21. message(WARNING "CMAKE_TOOLCHAIN_FILE is already defined to ${toolchain}.cmake, you\
  22. need to delete cache and reconfigure if you want to switch compiler.")
  23. endif ()
  24. else ()
  25. set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
  26. set(toolchain_file "${toolchain_dir}/${PICO_COMPILER}.cmake")
  27. if (EXISTS "${toolchain_file}")
  28. set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" CACHE INTERNAL "")
  29. else ()
  30. # todo improve message
  31. message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
  32. select one from \"cmake/toolchains\" folder.")
  33. endif ()
  34. endif ()
  35. message("PICO compiler is ${PICO_COMPILER}")
  36. endif ()
  37. unset(PICO_COMPILER CACHE)