DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

Build issue with ITK on Apple Silicon #1619

Open dcoeurjo opened 2 years ago

dcoeurjo commented 2 years ago

When build DGtal on a M1, there is no problem except when setting -DWITH_ITK=true which produces:

Consolidate compiler generated dependencies of target DGtal
[  1%] Building CXX object CMakeFiles/DGtal.dir/src/DGtal/base/Bits.cpp.o
In file included from /Users/davidcoeurjolly/Sources/DGtal/src/DGtal/base/Bits.cpp:30:
In file included from /Users/davidcoeurjolly/Sources/DGtal/src/DGtal/base/Bits.h:32:
In file included from /Users/davidcoeurjolly/Sources/DGtal/src/DGtal/base/Common.h:99:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/usr/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
...

Ping @kerautret

dcoeurjo commented 2 years ago

Have you already experienced something like that @kerautret ?

kerautret commented 2 years ago

yes I see it on the GitHub Actions when trying to activate ITK on MacOS build, it looks like that the include of cmath.h from Xcode build system find first the math.h of /usr/local/include before the one of Xcode Tools chain.

kerautret commented 2 years ago

Same problem here trying to activate ITK and macos GitHub Actions: (with a cmake small try fix) https://github.com/kerautret/DGtal/runs/4445372646?check_suite_focus=true

kerautret commented 2 years ago

@dcoeurjo have you tried to use the the CommandLineTools SDK instead the XCode SDK, by using: sudo xcode-select -s /Library/Developer/CommandLineTools It looks to be better when using ITK from brew (I tested on my non M1 Mac it works while also failing with Xcode SDK)

dcoeurjo commented 2 years ago

THanks for the tip, I'm not super fan of changing the SDK globally.. (I wasn't expecting that the command line has a different sdk than Xcode.. weird..)

kerautret commented 2 years ago

THanks for the tip, I'm not super fan of changing the SDK globally.. (I wasn't expecting that the command line has a different sdk than Xcode.. weird..)

I am agree not ideal, for instance I detected that Unreal Engine was no more working by using this SDK! 😱

kerautret commented 2 years ago

@dcoeurjo I tested a simple ITK helloworld project and it fails from the same errors so the problem is not related to DGtal itself but more from brew/ITK/osXSDK. I try to ask it on the ITK dev forum if they get a good workaround to fix it :). (since just test using #include and no errors).