Skip to content

Detect PICO_COMPILER automatically when PICO_TOOLCHAIN_PATH is set#2937

Open
kilograham wants to merge 1 commit into
developfrom
compiler-detect
Open

Detect PICO_COMPILER automatically when PICO_TOOLCHAIN_PATH is set#2937
kilograham wants to merge 1 commit into
developfrom
compiler-detect

Conversation

@kilograham
Copy link
Copy Markdown
Contributor

In passing with other compiler/clib related changes, this PR removes the need to specify PICO_COMPILER when already specifying PICO_TOOLCHAIN_PATH

Thus PICO_DEFAULT_COMPILER is now only used if you have neither specified PICO_COMPILER or a toolchain file/path in which case you're basically looking in the users path environment at which point it's not a bad idea to pick one to look for (we could even help there, but that is a more involved change)

@kilograham kilograham requested a review from will-v-pi May 14, 2026 20:48
@kilograham kilograham added this to the 2.2.1 milestone May 14, 2026
@@ -1,4 +1,7 @@
# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, type=string, default=none (i.e. search system paths), group=build, docref=cmake-toolchain-config
if (NOT PICO_TOOLCHAIN_PATH AND DEFINED ENV{PICO_TOOLCHAIN_PATH})
set(PICO_TOOLCHAIN_PATH $ENV{PICO_TOOLCHAIN_PATH})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a message, like the other bits like this (eg PICO_SDK_PATH in pico_sdk_import.cmake)

Suggested change
set(PICO_TOOLCHAIN_PATH $ENV{PICO_TOOLCHAIN_PATH})
set(PICO_TOOLCHAIN_PATH $ENV{PICO_TOOLCHAIN_PATH})
message("Using PICO_TOOLCHAIN_PATH from environment ('${PICO_TOOLCHAIN_PATH}')")

pico_message("Defaulting compiler (PICO_COMPILER) to '${PICO_DEFAULT_COMPILER}' since not specified.")
if (PICO_TOOLCHAIN_PATH)
if (PICO_DEFAULT_GCC_COMPILER)
FILE(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*gcc*")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently support PICO_TOOLCHAIN_PATH being set to the bin folder of the toolchain, so this should also search for ${PICO_TOOLCHAIN_PATH}/*gcc*

Suggested change
FILE(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*gcc*")
file(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*gcc*" "${PICO_TOOLCHAIN_PATH}/*gcc*")

(also lowercase file for consistency as that's what we use elsewhere)

endif()
endif()
if (NOT PICO_COMPILER AND PICO_DEFAULT_CLANG_COMPILER)
FILE(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*llvm*")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Suggested change
FILE(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*llvm*")
file(GLOB _COMPILER "${PICO_TOOLCHAIN_PATH}/bin/*llvm*" "${PICO_TOOLCHAIN_PATH}/*llvm*")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants