Skip to content

Enable support for version specification inside samples/cmake/FindWASISDK.cmake #4212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zelzahn
Copy link

@Zelzahn Zelzahn commented Apr 24, 2025

Currently, it is not possible to select a specific WASI SDK version to use in a sample. Thus, I modified the FindWASISDK.cmake to let me do this.

I'm no CMake expert, so feedback is greatly appreciated.

@lum1n0us
Copy link
Collaborator

@Zelzahn
Copy link
Author

Zelzahn commented Apr 24, 2025

Hi, I already had a look at both, to be clear the issue isn't that you can't give a version. The issue is that if you have multiple wasi-sdk's installed, the find_path will just take the first one, regardless of the requested version. I tried to find if there's a way such that find_path could return a list, but I could only find this library for that: https://github.com/XiaoLey/fetch_paths.cmake and thus no built-in option.

@lum1n0us
Copy link
Collaborator

have multiple wasi-sdk's installed,
I have to admit this is something new to me. Wow.

If you refer to the installation script for CI, you will find the assumption about wasi-sdk is that there is always a symlink named /opt/wasi-sdk targeting a directory /opt/wasi-sdk-xxx. With that, I guess we can modify the FindWASISDK in the following ways:

  • Find (the symlink) "/opt/wasi-sdk" instead of (the directory) "/opt/wasi-sdk-*".
  • Follow the symlink of /opt/wasi-sdk to determine the actual /opt/wasi-sdk-xxx, and use xxx as the version name to compare with the requirement.

FindWASISDK.cmake should not search for the correct wasi-sdk if there are multiple versions. Developers should prepare for that.

find_path(WASISDK_HOME
NAMES share/wasi-sysroot
PATHS ${WASISDK_SEARCH_PATH}
VALIDATOR check_version
Copy link
Collaborator

Choose a reason for hiding this comment

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

VALIDATOR is documented as a cmake 3.25 feature.
https://cmake.org/cmake/help/latest/command/find_path.html

in most places we still use cmake_minimum_required (VERSION 3.14).

@Zelzahn
Copy link
Author

Zelzahn commented Apr 25, 2025

Yeah, I need to have multiple wasi-sdk's installed because I'm toying with some old projects.

FindWASISDK.cmake should not search for the correct wasi-sdk if there are multiple versions. Developers should prepare for that.

I agree, I propose that I then close this PR and open a new one where I modify FindWASISDK.cmake to follow the symlink?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants