wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Enable support for version specification inside `samples/cmake/FindWASISDK.cmake`

Open Zelzahn opened this issue 8 months ago • 4 comments

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.

Zelzahn avatar Apr 24 '25 10:04 Zelzahn

Please refer to https://izzys.casa/2020/12/how-to-find-packages-with-cmake-the-basics/ and https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html

lum1n0us avatar Apr 24 '25 12:04 lum1n0us

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.

Zelzahn avatar Apr 24 '25 12:04 Zelzahn

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.

lum1n0us avatar Apr 24 '25 13:04 lum1n0us

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?

Zelzahn avatar Apr 25 '25 08:04 Zelzahn