@@ -77,7 +77,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
7777 # To support Zephyr SDK tools (DTC, and other tools) with 3rd party toolchains
7878 # then we keep track of current toolchain variant.
7979 set (ZEPHYR_CURRENT_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} )
80- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION }
80+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE }
8181 REQUIRED QUIET CONFIG HINTS ${ZEPHYR_SDK_INSTALL_DIR}
8282 )
8383 if (DEFINED ZEPHYR_CURRENT_TOOLCHAIN_VARIANT)
@@ -123,16 +123,27 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
123123 endif ()
124124 endforeach ()
125125 else ()
126+ if ("${Zephyr-sdk_FIND_VERSION_RANGE_MAX}" STREQUAL "INCLUDE" )
127+ set (upper_bound _EQUAL)
128+ endif ()
129+
130+ if (NOT DEFINED Zephyr-sdk_FIND_VERSION_RANGE)
131+ # Range not given, max out to ensure max version is not in effect.
132+ set (Zephyr-sdk_FIND_VERSION_MAX 99999999)
133+ endif ()
134+
126135 # Loop over each found Zepher SDK version until one is found that is compatible.
127136 foreach (zephyr_sdk_candidate ${Zephyr-sdk_CONSIDERED_VERSIONS})
128- if ("${zephyr_sdk_candidate} " VERSION_GREATER_EQUAL "${Zephyr-sdk_FIND_VERSION}" )
137+ if ("${zephyr_sdk_candidate} " VERSION_GREATER_EQUAL "${Zephyr-sdk_FIND_VERSION}"
138+ AND "${zephyr_sdk_candidate} " VERSION_LESS ${upper_bound} "${Zephyr-sdk_FIND_VERSION_MAX}"
139+ )
129140 # Find the path for the current version being checked and get the directory
130141 # of the Zephyr SDK so it can be checked.
131142 cmake_path(GET Zephyr-sdk-${zephyr_sdk_candidate} _DIR PARENT_PATH zephyr_sdk_current_check_path)
132143 cmake_path(GET zephyr_sdk_current_check_path PARENT_PATH zephyr_sdk_current_check_path)
133144
134145 # Then see if this version is compatible.
135- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION } QUIET CONFIG PATHS ${zephyr_sdk_current_check_path} NO_DEFAULT_PATH)
146+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE } QUIET CONFIG PATHS ${zephyr_sdk_current_check_path} NO_DEFAULT_PATH)
136147
137148 if (${Zephyr-sdk_FOUND})
138149 # A compatible version of the Zephyr SDK has been found which is the highest
@@ -145,7 +156,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
145156 if (NOT ${Zephyr-sdk_FOUND})
146157 # This means no compatible Zephyr SDK versions were found, set the version
147158 # back to the minimum version so that it is displayed in the error text.
148- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION } REQUIRED CONFIG PATHS ${zephyr_sdk_search_paths} )
159+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE } REQUIRED CONFIG PATHS ${zephyr_sdk_search_paths} )
149160 endif ()
150161 endif ()
151162 endif ()
0 commit comments