Unverified Commit f1a6f064 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

Auto detect OSX_SYSROOT for macos >= 10.14 (#2470)

* Auto detect OSX_SYSROOT for macos >= 10.14

* Fix potential regex issue.
parent b7dc7493
......@@ -40,8 +40,8 @@ include(var_functions)
NGRAPH_GET_VERSION_LABEL()
string(REGEX MATCH "([0-9?]+)\.([0-9?]+)\.([0-9?]+)" NGRAPH_VERSION_SHORT "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "([0-9?]+)\.([0-9?]+)" NGRAPH_API_VERSION "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "([0-9?]+)\\.([0-9?]+)\\.([0-9?]+)" NGRAPH_VERSION_SHORT "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "([0-9?]+)\\.([0-9?]+)" NGRAPH_API_VERSION "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "[^v](.*)" NGRAPH_VERSION "${NGRAPH_VERSION_LABEL}")
string(REPLACE "." ";" NGRAPH_VERSION_PARTS "${NGRAPH_VERSION_SHORT}")
list(GET NGRAPH_VERSION_PARTS 0 NGRAPH_VERSION_MAJOR)
......@@ -76,6 +76,31 @@ if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*$")
set(MSVS TRUE)
endif()
if (APPLE AND (NOT CMAKE_OSX_SYSROOT))
execute_process(COMMAND sw_vers -productVersion
OUTPUT_VARIABLE OSX_FULL_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
OSX_SHORT_VERSION "${OSX_FULL_VERSION}")
if(NOT (OSX_SHORT_VERSION VERSION_LESS 10.14))
# Xcode is installed
set(XCODE_ISYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SHORT_VERSION}.sdk)
message(STATUS "Trying Xcode sdk at ${XCODE_ISYSROOT}.")
if(NOT EXISTS ${XCODE_ISYSROOT})
# Command line tools only
set(XCODE_ISYSROOT /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk)
message(STATUS "Trying command line tool sdk at ${XCODE_ISYSROOT}.")
if(NOT EXISTS ${XCODE_ISYSROOT})
message(FATAL_ERROR "Cannot find macos sdk.")
endif()
endif()
message(STATUS "Setting CMAKE_OSX_SYSROOT for macos ${OSX_SHORT_VERSION} to ${XCODE_ISYSROOT}")
set(CMAKE_OSX_SYSROOT ${XCODE_ISYSROOT})
endif()
endif()
# Setup CMAKE_ARGS to be forwarded to External Projects
set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment