avoid calling find_package for pico-sdk-tools over and over again #1403

Merged
kilograham merged 2 commits from find_package_perf into develop 2023-06-06 10:46:18 -05:00
kilograham commented 2023-05-29 10:16:57 -05:00 (Migrated from github.com)
see also https://forums.raspberrypi.com/viewtopic.php?t=351995
peterharperuk (Migrated from github.com) reviewed 2023-05-29 10:16:57 -05:00
kilograham commented 2023-05-29 10:33:36 -05:00 (Migrated from github.com)

cc @ndabas

cc @ndabas
smuehlst commented 2023-05-29 14:16:26 -05:00 (Migrated from github.com)

I had posted the question in the Raspberry Pi forum. I tried a new cmake configuration run with the find_package_perf branch checked out, and this reduces the time from over 15 minutes to 44 seconds.

I had posted the question in the Raspberry Pi forum. I tried a new cmake configuration run with the `find_package_perf` branch checked out, and this reduces the time from over 15 minutes to 44 seconds.
ndabas commented 2023-05-30 02:25:00 -05:00 (Migrated from github.com)

Thanks, I'll just do a quick test with the Windows installer.

Thanks, I'll just do a quick test with the Windows installer.
ndabas commented 2023-05-30 03:17:37 -05:00 (Migrated from github.com)

Okay, as it stands right now this is not compiling on Windows with the SDK installer. I'll need to look a bit deeper into it and see how to fix it.

-- Generating done
-- Build files have been written to: C:/Users/WDAGUtilityAccount/Documents/Pico-v1.5.1-develop/pico-examples/build
Building blink
[9/59] Performing configure step for 'ELF2UF2Build'
FAILED: blink/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure C:/Users/WDAGUtilityAccount/Documents/Pico-v1.5.1-develop/pico-examples/build/blink/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure
Okay, as it stands right now this is not compiling on Windows with the SDK installer. I'll need to look a bit deeper into it and see how to fix it. ``` -- Generating done -- Build files have been written to: C:/Users/WDAGUtilityAccount/Documents/Pico-v1.5.1-develop/pico-examples/build Building blink [9/59] Performing configure step for 'ELF2UF2Build' FAILED: blink/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure C:/Users/WDAGUtilityAccount/Documents/Pico-v1.5.1-develop/pico-examples/build/blink/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure ```
peterharperuk commented 2023-05-30 04:02:17 -05:00 (Migrated from github.com)

Looks ok. I'll test on Windows and see if I have any issues.

Looks ok. I'll test on Windows and see if I have any issues.
ndabas commented 2023-05-30 04:50:54 -05:00 (Migrated from github.com)

It'll probably work fine if you have native GCC or Visual Studio C++ compilers installed. However the point of making these changes in the first place was that the pico-setup-windows installer does not install native C++ compilers, so the SDK should be able to detect and use the pre-compiled versions of the SDK tools. Which is failing at the moment but I'll look deeper into it.

It'll probably work fine if you have native GCC or Visual Studio C++ compilers installed. However the point of making these changes in the first place was that the pico-setup-windows installer does not install native C++ compilers, so the SDK should be able to detect and use the pre-compiled versions of the SDK tools. Which is failing at the moment but I'll look deeper into it.
ndabas commented 2023-05-30 08:43:45 -05:00 (Migrated from github.com)

It works if I structure the first function like this: (and remove the find_package(pico-sdk-tools ... from global scope):

function(_pico_init_pioasm)
    if (NOT Pioasm_FOUND)
        # Assemble the version string from components instead of using PICO_SDK_VERSION_STRING, because the version string
        # potentially has a PRE_RELEASE_ID suffix, which will trip up the find_package call.
        find_package(pico-sdk-tools "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}" QUIET CONFIG CMAKE_FIND_ROOT_PATH_BOTH)
        if (NOT Pioasm_FOUND)
            set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools)
            # todo CMAKE_CURRENT_FUNCTION_LIST_DIR ... what version?
            find_package(Pioasm REQUIRED)
        endif()
    endif()
endfunction()

Since the call is now in a conditional, it should not be repeated if we have already found the package somehow (but I have not validated that on Linux.)

Similarly for the pico_add_uf2_output function:

    if (NOT ELF2UF2_FOUND)
        find_package(pico-sdk-tools "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}" QUIET CONFIG CMAKE_FIND_ROOT_PATH_BOTH)
        if (NOT ELF2UF2_FOUND)
            set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools)
            find_package(ELF2UF2)
        endif()
    endif()

If this solution works, while I don't have permission to push to this PR branch, I can open a new one with the fix.

It works if I structure the first function like this: (and remove the `find_package(pico-sdk-tools ...` from global scope): ``` function(_pico_init_pioasm) if (NOT Pioasm_FOUND) # Assemble the version string from components instead of using PICO_SDK_VERSION_STRING, because the version string # potentially has a PRE_RELEASE_ID suffix, which will trip up the find_package call. find_package(pico-sdk-tools "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}" QUIET CONFIG CMAKE_FIND_ROOT_PATH_BOTH) if (NOT Pioasm_FOUND) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools) # todo CMAKE_CURRENT_FUNCTION_LIST_DIR ... what version? find_package(Pioasm REQUIRED) endif() endif() endfunction() ``` Since the call is now in a conditional, it should not be repeated if we have already found the package somehow (but I have not validated that on Linux.) Similarly for the `pico_add_uf2_output` function: ``` if (NOT ELF2UF2_FOUND) find_package(pico-sdk-tools "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}" QUIET CONFIG CMAKE_FIND_ROOT_PATH_BOTH) if (NOT ELF2UF2_FOUND) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools) find_package(ELF2UF2) endif() endif() ``` If this solution works, while I don't have permission to push to this PR branch, I can open a new one with the fix.
kilograham commented 2023-05-30 09:18:54 -05:00 (Migrated from github.com)

Ha, that fix is exactly what i was going to suggest (and i had thought about that after i did it!)

Ha, that fix is exactly what i was going to suggest (and i had thought about that after i did it!)
ndabas commented 2023-05-31 04:53:01 -05:00 (Migrated from github.com)

Thanks! Looks good, it builds fine with pico-setup-windows now.

Thanks! Looks good, it builds fine with pico-setup-windows now.
kilograham commented 2023-05-31 09:31:32 -05:00 (Migrated from github.com)

Thanks! Looks good, it builds fine with pico-setup-windows now.

thanks

> Thanks! Looks good, it builds fine with pico-setup-windows now. thanks
liamfraser (Migrated from github.com) approved these changes 2023-06-06 10:40:09 -05:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!1403
No description provided.