Issue with CMAKE_OSX_DEPLOYMENT_TARGET being set before a project call

オープン
#2,366 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cmake, cpp
領域
build-system

調査の方向性

The default CMAKE_OSX_DEPLOYMENT_TARGET is set in the top-level CMakeLists.txt under an if(APPLE AND NOT DEFINED ...) guard, before the project() call. Read the ordering of that block against project() and the toolchain loading the reporter describes, then check how a value passed by a toolchain file is handled. Done means a toolchain-provided deployment target is respected on macOS, which needs a macOS build to verify, and the fix needs maintainer agreement on whether the default should move or be dropped.

索引モデルが issue の本文から書いたものです。

説明

I'm currently preparing/updating the conan recipe for OpenColorIO 2.6.0. While doing that, I saw the following in the CMakeLists.txt:

if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
    # The value of this variable should be set prior to the first project() command invocation
    # because it may influence configuration of the toolchain and flags.
    set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
endif()

Can't fully see the reasoning for setting this before calling project(). In the case of conan that actually is a downside, as only the call to project will trigger the load of the toolchain, so at the moment when this code runs it has not yet been set, thus 10.15 is set as a deployment target and Xcode fills the output with warnings that I try to target a system that is heavily outdated:

In file included from /Users/ingmar/.conan2/p/b/opencec55f948273cb/b/src/src/OpenColorIO/CPUInfo.cpp:5:
In file included from /Users/ingmar/.conan2/p/b/opencec55f948273cb/b/src/src/OpenColorIO/CPUInfo.h:8:
In file included from /Users/ingmar/.conan2/p/b/opencec55f948273cb/b/src/include/OpenColorIO/../OpenColorIO/OpenColorIO.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk/usr/include/c++/v1/cstddef:39:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk/usr/include/c++/v1/__config:15:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk/usr/include/c++/v1/__configuration/availability.h:204:4: warning: "The selected platform is no longer supported by libc++." [-W#warnings]

(This is just one, but basically appears for each file.)

Followed by the thus expected linker warning that the other libraries linked in are for a newer SDK:

...
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[22](parse.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[23](parser.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[24](regex_yaml.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[25](scanner.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[26](scanscalar.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[27](scantag.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[28](scantoken.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[29](simplekey.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
ld: warning: object file (/Users/ingmar/.conan2/p/b/yaml-c29218f011373/p/lib/libyaml-cpp.a[30](singledocparser.cpp.o)) was built for newer 'macOS' version (26.4) than being linked (11.0)
...

So the description says it is to prevent toolchain problems, here it seems to result in problems that the toolchain set variables are ignored.
This is the block of apple specific settings conan writes into the toolchain:

########## 'apple_system' block #############
# Define Apple architectures, sysroot, deployment target, bitcode, etc

# Set the architectures for which to build.
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "" FORCE)
# Setting CMAKE_OSX_SYSROOT SDK, when using Xcode generator the name is enough
# but full path is necessary for others
set(CMAKE_OSX_SYSROOT macosx CACHE STRING "" FORCE)
# Setting CMAKE_OSX_DEPLOYMENT_TARGET if "os.version" is defined by the used conan profile
set(CMAKE_OSX_DEPLOYMENT_TARGET "26.4" CACHE STRING "")
# Swift does not derive its target triple from CMAKE_OSX_SYSROOT/CMAKE_OSX_ARCHITECTURES
# the way Clang does, so it is set explicitly. Only a default, any user value wins
if(NOT DEFINED CMAKE_Swift_COMPILER_TARGET)
    set(CMAKE_Swift_COMPILER_TARGET "arm64-apple-macosx26.4")
endif()
set(BITCODE "")
set(FOBJC_ARC "")
set(VISIBILITY "")
#Check if Xcode generator is used, since that will handle these flags automagically
if(CMAKE_GENERATOR MATCHES "Xcode")
  message(DEBUG "Not setting any manual command-line buildflags, since Xcode is selected as generator.")
else()
    string(APPEND CONAN_C_FLAGS " ${BITCODE} ${VISIBILITY}")
    string(APPEND CONAN_CXX_FLAGS " ${BITCODE} ${VISIBILITY}")
    # Objective-C/C++ specific flags
    string(APPEND CONAN_OBJC_FLAGS " ${BITCODE} ${VISIBILITY} ${FOBJC_ARC}")
    string(APPEND CONAN_OBJCXX_FLAGS " ${BITCODE} ${VISIBILITY} ${FOBJC_ARC}")
endif()
主要言語
C++
スター
2.1k
フォーク
513
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AcademySoftwareFoundation/OpenColorIO のほかの issue

AcademySoftwareFoundation/OpenColorIO の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。