Issue with CMAKE_OSX_DEPLOYMENT_TARGET being set before a project call

Abierto
#2,366 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cmake, cpp
Área
build-system

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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()
Lenguaje dominante
C++
Estrellas
2.1k
Forks
513
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AcademySoftwareFoundation/OpenColorIO

Todos los issues de AcademySoftwareFoundation/OpenColorIO

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.