Skip to content

Improve CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT handling #1942

@Xottab-DUTY

Description

@Xottab-DUTY

Currently, we are setting CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT variables after the project call which is not recommended.
They should be set externally by the developer invoking CMake.

set(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_SYSTEM_VERSION})

CMAKE_OSX_SYSROOT is even more problematic: it is hardcoded with the assumption that Xcode is installed.

set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")

But it may be missing and a developer can have command line tools installed instead and the path would be Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions