-
Notifications
You must be signed in to change notification settings - Fork 21.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull Request resolved: #47635 Add macosx support for metal. The supported os version is 10.13 and above. ghstack-source-id: 116617355 Differential Revision: [D24825088](https://our.internmc.facebook.com/intern/diff/D24825088/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D24825088/)!
- Loading branch information
Showing
5 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
if(NOT APPLE) | ||
return() | ||
endif() | ||
|
||
if(NOT USE_PYTORCH_METAL) | ||
return() | ||
endif() | ||
|
||
set(OSX_PLATFORM "MacOSX.platform") | ||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR) | ||
set(XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${OSX_PLATFORM}/Developer") | ||
set(XCODE_PRE_43_ROOT "/Developer/Platforms/${OSX_PLATFORM}/Developer") | ||
if(NOT DEFINED CMAKE_OSX_DEVELOPER_ROOT) | ||
if(EXISTS ${XCODE_POST_43_ROOT}) | ||
set(CMAKE_OSX_DEVELOPER_ROOT ${XCODE_POST_43_ROOT}) | ||
elseif(EXISTS ${XCODE_PRE_43_ROOT}) | ||
set(CMAKE_OSX_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT}) | ||
endif(EXISTS ${XCODE_POST_43_ROOT}) | ||
endif(NOT DEFINED CMAKE_OSX_DEVELOPER_ROOT) | ||
set(CMAKE_OSX_DEVELOPER_ROOT ${CMAKE_OSX_DEVELOPER_ROOT} CACHE PATH "Location of OSX SDKs root directory") | ||
|
||
if(NOT DEFINED CMAKE_OSX_SDK_ROOT) | ||
file(GLOB _CMAKE_OSX_SDKS "${CMAKE_OSX_DEVELOPER_ROOT}/SDKs/*") | ||
if(_CMAKE_OSX_SDKS) | ||
list(SORT _CMAKE_OSX_SDKS) | ||
list(REVERSE _CMAKE_OSX_SDKS) | ||
list(GET _CMAKE_OSX_SDKS 0 CMAKE_OSX_SDK_ROOT) | ||
message(STATUS "_CMAKE_OSX_SDKS: ${_CMAKE_OSX_SDKS}") | ||
else(_CMAKE_OSX_SDKS) | ||
message(FATAL_ERROR "No OSX SDK's found in default search path ${CMAKE_OSX_DEVELOPER_ROOT}.") | ||
endif(_CMAKE_OSX_SDKS) | ||
message(STATUS "Toolchain using default OSX SDK: ${CMAKE_OSX_SDK_ROOT}") | ||
endif(NOT DEFINED CMAKE_OSX_SDK_ROOT) | ||
set(CMAKE_OSX_SDK_ROOT ${CMAKE_OSX_SDK_ROOT} CACHE PATH "Location of the selected OSX SDK") | ||
set(CMAKE_FRAMEWORK_PATH | ||
${CMAKE_OSX_SDK_ROOT}/System/Library/Frameworks | ||
${CMAKE_OSX_SDK_ROOT}/System/Library/PrivateFrameworks | ||
${CMAKE_OSX_SDK_ROOT}/Developer/Library/Frameworks | ||
) | ||
message(STATUS "CMAKE_FRAMEWORK_PATH: ${CMAKE_FRAMEWORK_PATH}") | ||
set(CMAKE_FIND_FRAMEWORK FIRST) | ||
|