pico_pre_load_toolchain.cmake 2.1 KB

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