@@ -54,7 +54,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
5454 # To support Zephyr SDK tools (DTC, and other tools) with 3rd party toolchains
5555 # then we keep track of current toolchain variant.
5656 set (ZEPHYR_CURRENT_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} )
57- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION }
57+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE }
5858 REQUIRED QUIET CONFIG HINTS ${ZEPHYR_SDK_INSTALL_DIR}
5959 )
6060 if (DEFINED ZEPHYR_CURRENT_TOOLCHAIN_VARIANT)
@@ -82,18 +82,28 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
8282
8383 list (REMOVE_DUPLICATES Zephyr-sdk_CONSIDERED_VERSIONS)
8484 list (SORT Zephyr-sdk_CONSIDERED_VERSIONS COMPARE NATURAL ORDER DESCENDING)
85+ if ("${Zephyr-sdk_FIND_VERSION_RANGE_MAX}" STREQUAL "INCLUDE" )
86+ set (upper_bound _EQUAL)
87+ endif ()
88+
89+ if (NOT DEFINED Zephyr-sdk_FIND_VERSION_RANGE)
90+ # Range not given, max out to ensure max version is not in effect.
91+ set (Zephyr-sdk_FIND_VERSION_MAX 99999999)
92+ endif ()
8593
8694 # Loop over each found Zepher SDK version until one is found that is compatible.
8795 foreach (zephyr_sdk_candidate ${Zephyr-sdk_CONSIDERED_VERSIONS})
88- if ("${zephyr_sdk_candidate} " VERSION_GREATER_EQUAL "${Zephyr-sdk_FIND_VERSION}" )
96+ if ("${zephyr_sdk_candidate} " VERSION_GREATER_EQUAL "${Zephyr-sdk_FIND_VERSION}"
97+ AND "${zephyr_sdk_candidate} " VERSION_LESS ${upper_bound} "${Zephyr-sdk_FIND_VERSION_MAX}"
98+ )
8999 # Find the path for the current version being checked and get the directory
90100 # of the Zephyr SDK so it can be checked.
91101 list (FIND zephyr_sdk_found_versions ${zephyr_sdk_candidate} zephyr_sdk_current_index)
92102 list (GET zephyr_sdk_found_configs ${zephyr_sdk_current_index} zephyr_sdk_current_check_path)
93103 get_filename_component (zephyr_sdk_current_check_path ${zephyr_sdk_current_check_path} DIRECTORY )
94104
95105 # Then see if this version is compatible.
96- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION } QUIET CONFIG PATHS ${zephyr_sdk_current_check_path} NO_DEFAULT_PATH)
106+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE } QUIET CONFIG PATHS ${zephyr_sdk_current_check_path} NO_DEFAULT_PATH)
97107
98108 if (${Zephyr-sdk_FOUND})
99109 # A compatible version of the Zephyr SDK has been found which is the highest
@@ -106,7 +116,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
106116 if (NOT ${Zephyr-sdk_FOUND})
107117 # This means no compatible Zephyr SDK versions were found, set the version
108118 # back to the minimum version so that it is displayed in the error text.
109- find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION } REQUIRED CONFIG PATHS ${zephyr_sdk_search_paths} )
119+ find_package (Zephyr-sdk ${Zephyr-sdk_FIND_VERSION_COMPLETE } REQUIRED CONFIG PATHS ${zephyr_sdk_search_paths} )
110120 endif ()
111121 endif ()
112122
0 commit comments