mphowardlab / gsd-vmd

A VMD molfile plugin reader for HOOMD-blue GSD files.
BSD 3-Clause "New" or "Revised" License
15 stars 2 forks source link

Building on an M1 Mac. #12

Closed chrisiacovella closed 9 months ago

chrisiacovella commented 2 years ago

This is mostly an FYI, as I'm sure others may run into this issue when dealing with the transition to ARM64 (i.e. M1) machines.

When building on an M1-based Mac, cmake was trying to build the plugin for x86_64, which was causing conflict when linking because the version of VMD I installed was built for ARM64.

The reason for this: I was being lazy and just used the cmake package that was available on Conda ( version 3.14.0, for Conda 4.11.0 with python 3.9.7). It appears that at the current moment the version available on Conda is built for x86_64. This binary still runs, but assumes the wrong target architecture.

A simple work around was to add this to the compiler flags in cmake: -target arm64-apple-macos10.5

A better, long term solution, was to just build cmake from source for the M1 architecture. The version built from source did not require the additional step of setting the target architecture.

mphoward commented 2 years ago

Thanks for the info! I will try to incorporate this into the README. To help collect info, did you try -DCMAKE_OSX_ARCHITECTURES=arm64, and did this fail?

I'm also documenting on this issue that I need to move the location where CMAKE_OSX_ARCHITECTURES is defined: https://github.com/mphowardlab/gsd-vmd/blob/c04e83e6743a3ff3fee0067003ca778bad73d252/CMakeLists.txt#L17-L20 It is supposed to come before any project command. https://cmake.org/cmake/help/v3.23/variable/CMAKE_OSX_ARCHITECTURES.html#variable:CMAKE_OSX_ARCHITECTURES

chrisiacovella commented 2 years ago

-DCMAKE_OSX_ARCHITECTURES=arm64 works with the non-native cmake version from Conda. I had tried that initially but it failed, hence passing the compiler flag...but checking my terminal history, it was user error (typo: leaving off the 'S' in architectures).