diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-12-11 10:55:46 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-12-11 10:55:46 (GMT) |
commit | 7a44e16d7f262475e32920ae1dedaf57a320db82 (patch) | |
tree | 2fff1fb09c5f1b7660fa504705ee65246724cd17 /Modules/Platform | |
parent | 777d3649139c588b834007dc7d3422bc9defb900 (diff) | |
download | CMake-7a44e16d7f262475e32920ae1dedaf57a320db82.zip CMake-7a44e16d7f262475e32920ae1dedaf57a320db82.tar.gz CMake-7a44e16d7f262475e32920ae1dedaf57a320db82.tar.bz2 |
Refactor SDK name to path into a function
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Darwin-Initialize.cmake | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake index f4e8133..1c51ec9 100644 --- a/Modules/Platform/Darwin-Initialize.cmake +++ b/Modules/Platform/Darwin-Initialize.cmake @@ -122,7 +122,18 @@ endforeach() set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE} "The product will be built against the headers and libraries located inside the indicated SDK.") -# Transform the cached value to something we can use. +# Resolves the SDK name into a path +function(_apple_resolve_sdk_path sdk_name ret) + execute_process( + COMMAND xcrun -sdk ${sdk_name} --show-sdk-path + OUTPUT_VARIABLE _stdout + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _stderr + RESULT_VARIABLE _failed + ) + set(${ret} "${_stdout}" PARENT_SCOPE) +endfunction() + set(_CMAKE_OSX_SYSROOT_PATH "") if(CMAKE_OSX_SYSROOT) if("x${CMAKE_OSX_SYSROOT}" MATCHES "/") @@ -134,16 +145,9 @@ if(CMAKE_OSX_SYSROOT) endif() set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") else() - # Transform the sdk name into a path. - execute_process( - COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} --show-sdk-path - OUTPUT_VARIABLE _stdout - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE _stderr - RESULT_VARIABLE _failed - ) - if(NOT _failed AND IS_DIRECTORY "${_stdout}") - set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}") + _apple_resolve_sdk_path(${CMAKE_OSX_SYSROOT} _sdk_path) + if(IS_DIRECTORY "${_sdk_path}") + set(_CMAKE_OSX_SYSROOT_PATH "${_sdk_path}") # For non-Xcode generators use the path. if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}") |