raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.27k stars 844 forks source link

CMAKE_PREFIX_PATH content lost in middle of the CMake configuration step #1578

Open opilat opened 7 months ago

opilat commented 7 months ago

Pico examples project (picowblink) configured with -DCMAKE_PREFIX_PATH=path_to_arm_none_eabitoolchain command line option fails to configure. Before the C compiler test step, it loses the content of the CMAKE_PREFIX_PATH.
-- Detecting C compiler ABI info CMake Error at C:/Projects/pico/pico-sdk/cmake/preload/toolchains/find_compiler.cmake:28 (message): Compiler 'arm-none-eabi-gcc' not found, you can specify search path with "PICO_TOOLCHAIN_PATH". configure_issue.txt

Krakonos commented 7 months ago

Note this issue can be fixed by either passing the CMAKE_PREFIX_PATH as an environment variable, or setting before running project:

set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH)

The problem is that try try_compile creates a CMakeFiles.txt that includes the preload/toolchains/pico_arm_gcc.cmake. I'm not sure how this mechanism should work, but seems like bad practice to depend on a specific ways to pass the variable. If something, I suggest using the variable above to pass the previously found compiler paths directly, instead of trying to find it again - since there may be other factors causing a different compiler is found in the toplevel cmake, and a different one is found in the generated try-compile cmake.