pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

Add PICOTOOL_OVERRIDE_DIR

Open shabaz123 opened this issue 1 year ago • 1 comments

Submitting against 'develop' Fixes #1818

When using Windows 11 and SDK 2.0.0, when trying to do a cmake -G "NMake Makefiles" .. or cmake -G "Ninja" .. then picotool executable is not found, and it gets built within the project. The Findpicotool.cmake file does not seem to find the picotool executable at least with Windows, I have not checked Linux/Mac.

I have a solution which should be benign, since it only kicks in if the user creates a system environment variable in Windows, called PICOTOOL_OVERRIDE_DIR. If that is set, then the picotool.exe file there is used (and the version command is executed to confirm it is the correct version).

The submitted change is in a single file (Findpicotool.cmake), placed near the top of the file, after the cmake_minimum_required(VERSION 3.17) line.

I have tested by performing a build, and I can see that the picotool executable was used, and that the .uf2 file was successfully created.

The attached files evidence that, and at the end there is a dir listing that shows that the .uf2 file was created.

nmake_output.txt cmake_g_nmake_makefile_output.txt

shabaz123 avatar Aug 14 '24 17:08 shabaz123

I don't want to add this, as there are already better ways to do this native to CMake. See the Usage by the SDK section of the picotool README for more details.

In short, you can run the following CMake commands from your picotool build directory to install the required files to $MY_INSTALL_DIR (replacing $MY_INSTALL_DIR with the path you want to use)

cmake -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR -DPICOTOOL_FLAT_INSTALL=1 ..
cmake --build .
cmake --install .

then set the picotool_DIR environment variable to $MY_INSTALL_DIR/picotool - so no need to add an additional PICOTOOL_OVERRIDE_DIR variable.

will-v-pi avatar Aug 15 '24 09:08 will-v-pi

Can confirm, after running cmake --install . from my cmake build folder of the picotool project, the Findpicotool.cmake finds my precompiled picotool. More details in Issue #1818

bhass1 avatar Aug 15 '24 14:08 bhass1

Thanks for the response!

@will-v-pi does the mixed-case env var picotool_DIR function with Windows? Traditionally env vars are case-insensitive with Windows, and I don't know if Windows CMake would match that with the mixed case (I don't know either way, I've not tried it yet).

I'll close this PR for now, since it's been confirmed working with Linux.

shabaz123 avatar Aug 15 '24 15:08 shabaz123

I've confirmed it works in Windows too, by running

$env:picotool_DIR = '~\.pico-sdk\picotool\2.0.0\picotool'
$env:pioasm_DIR = '~\.pico-sdk\tools\2.0.0\pioasm'
$env:PICO_SDK_PATH = '~\.pico-sdk\sdk\2.0.0'
$env:PICO_TOOLCHAIN_PATH = '~\.pico-sdk\toolchain\13_2_Rel1'
cmake .. -G "NMake Makefiles"

will-v-pi avatar Aug 15 '24 16:08 will-v-pi