Strange CMAKE_OSX_DEPLOYMENT_TARGET variable behaviour
CMAKE_OSX_DEPLOYMENT_TARGET
behaves properly if it set as argument of CMake command:
cmake -DCMAKE_OSX_DEPLOYMENT_TARGET="10.10"
However, if CMAKE_OSX_DEPLOYMENT_TARGET
set inside CMakeLists.txt
before project()
. This CMakeLists.txt
:
cmake_minimum_required(VERSION 3.6)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10")
project(Test)
message("CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
add_executable(Test test.cpp)
Will print:
CMAKE_OSX_DEPLOYMENT_TARGET:
And test.cpp
compile command will not contain -mmacosx-version-min=10.10
argument.
And only after second call of cmake
without clearing cache it will print:
CMAKE_OSX_DEPLOYMENT_TARGET: 10.10
And generate correct compile command. Maybe I don't understand something but it sound like bug for me.
CMake version is 3.10.2
macOS version is 10.13.4
macOS SDK is 10.13