COMP: Pass macOS architecture settings to external projects#1346
Conversation
When building Slicer for a specific macOS architecture (e.g., arm64), the CMAKE_OSX_ARCHITECTURES, CMAKE_OSX_DEPLOYMENT_TARGET, and CMAKE_OSX_SYSROOT variables need to be explicitly passed to the CTK external project. This is work towards Slicer#6811 and Slicer#5944. Note: This change requires commontk/CTK#1346 to fully resolve native ARM64 builds, as CTK also needs to propagate these settings to its nested external projects (PythonQt, PythonQtGenerator).
|
I didn't build Qt5 myself, Homebrew provides Qt5 5.15.16 pre-built for ARM64. |
When building Slicer for a specific macOS architecture (e.g., arm64), the CMAKE_OSX_ARCHITECTURES, CMAKE_OSX_DEPLOYMENT_TARGET, and CMAKE_OSX_SYSROOT variables need to be explicitly passed to the CTK external project. This is work towards Slicer#6811 and Slicer#5944. Note: This change requires commontk/CTK#1346 to fully resolve native ARM64 builds, as CTK also needs to propagate these settings to its nested external projects (PythonQt, PythonQtGenerator).
|
@jamesobutler This request seems reasonable, the solution looks good to me. |
|
@hjmjohnson As @pieper mentioned in Slicer/Slicer#9003 (comment), he seemed to not need any additional code changes in the context of Slicer and CTK to pass things down as his ARM64 build has already been successful without it. |
|
@jamesobutler When environmental defaults are configured in a compatible way, there are no issues (i.e. when. the defaults are guessed correctly). I think this is a case of "not required when guesses are consistent, required when guesses are wrong". Explicitly setting these variables is the safest and most robust approach. Let's make propagating these items more robust and only propagate them if they are set to non-null values. I am a fan of being explicit when all the builds MUST use the same compilation environments/tools. Explicitly setting those values is often not needed in default builds, but it makes custom builds (i.e., old compilers/static analyzers/etc.) much easier to implement. My hypothesis is that one of the environmental variables that changes the default behavior was set. I.e., they were trying to compile the following outdated slicer build instructions that changed defaults to x86_64, then started a new build, but forgot to unset the environmental variable. Then the Outer superbuild was set to arm64, but the inner build had to guess and used the environmental variable as the default. I'm fine with this being ignored or incorporated, but I'd like a final decision. |
When building CTK for a specific macOS architecture (e.g., arm64),
the CMAKE_OSX_ARCHITECTURES, CMAKE_OSX_DEPLOYMENT_TARGET, and
CMAKE_OSX_SYSROOT variables need to be passed to nested external
projects like PythonQt and PythonQtGenerator.
Without this fix, building CTK with -DCMAKE_OSX_ARCHITECTURES=arm64
while using ARM64 Qt5 causes PythonQtGenerator to build for the
wrong architecture (defaulting to x86_64), resulting in linker
errors like:
ld: warning: ignoring file 'QtCore': found architecture 'arm64',
required architecture 'x86_64'
ld: symbol(s) not found for architecture x86_64
This change adds the macOS architecture variables to ep_common_cache_args
so they are consistently passed to all external projects.
9640069 to
4b260e1
Compare
lassoan
left a comment
There was a problem hiding this comment.
This looks good to me. Probably explicit propagation of these variables is not necessary in most cases, but it should not do any harm and it can be useful in some cases.
Summary
ep_common_cache_argsProblem
When building CTK with
-DCMAKE_OSX_ARCHITECTURES=arm64on a Mac with ARM64 Qt5, PythonQtGenerator fails to link:Root Cause
The
ep_common_cache_argsvariable (used by external projects like PythonQt and PythonQtGenerator) doesn't include macOS architecture settings, so nested projects default to x86_64 while trying to link against ARM64 Qt libraries.Test Plan
-DCMAKE_OSX_ARCHITECTURES=arm64on macOS Tahoe (M4)