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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions samples/cmake/FindWASISDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@
include(FindPackageHandleStandardArgs)

file(GLOB WASISDK_SEARCH_PATH "/opt/wasi-sdk-*")

function(check_version validator_result_var item)
if(WASISDK_FIND_VERSION)
if(item MATCHES "${WASISDK_FIND_VERSION}")
set(${validator_result_var} TRUE PARENT_SCOPE)
else()
set(${validator_result_var} FALSE PARENT_SCOPE)
endif()
else()
set(${validator_result_var} TRUE PARENT_SCOPE)
endif()
endfunction()

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).

NO_DEFAULT_PATH
REQUIRED
)
Expand Down
Loading