Issue with CMAKE_OSX_DEPLOYMENT_TARGET being set before a project call

Aberta
#2,366 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
cmake, cpp
Domínio
build-system

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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()
Linguagem predominante
C++
Estrelas
2.1k
Forks
513
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de AcademySoftwareFoundation/OpenColorIO

Todas as issues de AcademySoftwareFoundation/OpenColorIO

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.