FindJNI: Improve output on macOS if Xcode is not installed

Improve the changes from:

* commit efa0e2ddaf (FindJNI: Update for Xcode greater than 12.1 on macOS,
                     2023-08-06, v3.27.2~5^2)
* commit 597139b853 (FindJNI: Restore support for macOS without Xcode,
                     2023-08-11, v3.27.3~8^2)

to avoid leaking `xcodebuild`'s stderr.

Issue: #26229
This commit is contained in:
Brad King 2024-08-19 11:30:30 -04:00
parent 97bb92ace5
commit 7402593a08

View File

@ -391,8 +391,10 @@ if(APPLE)
execute_process(
COMMAND xcodebuild -version
OUTPUT_VARIABLE _FindJNI_XCODEBUILD_VERSION
ERROR_VARIABLE _FindJNI_XCODEBUILD_VERSION
RESULT_VARIABLE _FindJNI_XCODEBUILD_RESULT
)
if(_FindJNI_XCODEBUILD_VERSION MATCHES "Xcode ([0-9]+(\\.[0-9]+)*)")
if(_FindJNI_XCODEBUILD_RESULT EQUAL 0 AND _FindJNI_XCODEBUILD_VERSION MATCHES "Xcode ([0-9]+(\\.[0-9]+)*)")
set(_FindJNI_XCODE_VERSION "${CMAKE_MATCH_1}")
else()
set(_FindJNI_XCODE_VERSION "")