View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014252CMake(No Category)public2013-06-28 09:132016-06-10 14:31
ReporterMojca Miklavec 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
Platformx86_64-darwinOSMac OS XOS Version10.7.5
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0014252: Unsupported "-arch x86_64" mysteriously ends up in Fortran_FLAGS
Descriptionhttp://public.kitware.com/pipermail/cmake-developers/2013-January/006230.html [^]

An unsupported compiler flag "-arch x86_64" mysteriously sneaks into Fortran_FLAGS when
    -DCMAKE_OSX_ARCHITECTURES="x86_64"
is passed to cmake. That flag CMAKE_OSX_ARCHITECTURES is added automatically to all projects in MacPorts (third-party package manager for Mac OS X) even when cross-compiling or compilation of fat binaries (like i386+x86_64) is not needed, so no project that needs Fortran and CMake can be compiled (luckily there are not many such projects, but it's still a showstopper to switch to CMake).


The g95 compiler ignores "-arch <...>" flag, but GCC's gfortran 4.x throws an error and breaks compilation. I could probably try to prevent DCMAKE_OSX_ARCHITECTURES from being passed to cmake (via some tricks in MacPorts or by modifying MacPorts sources), but I still believe that passing "-arch x86_64" to Fortran_FLAGS is a bug in CMake.
Steps To ReproduceCompiled Root (root.cern.ch) or any minimal project which needs Fortran with

cmake \
-DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.5 \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_PREFIX=/path/to/install \
-DCMAKE_OSX_ARCHITECTURES="x86_64" ../path/to/sources

In that particular project the generated file
    misc/minicern/CMakeFiles/minicern.dir/flags.make
ends up containing the following variables (among others):
    C_FLAGS = -m64 -pipe -W -Wall -fsigned-char -fno-common -O2 -g-arch x86_64 -fPIC -I<path/to/some/include/dirs>
    Fortran_FLAGS = -m64 -std=legacy -arch x86_64 -fPIC -I<path/to/some/include/dirs>

The flag "-arch x86_64" shouldn't be there.
Additional InformationCiting http://public.kitware.com/pipermail/cmake-developers/2013-January/006230.html [^]

The "-arch" flag is hard-coded here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.10.2#l1826 [^]

It was added to CMake way back when universal binary support was
first added to OS X under the assumption that all compilers that
would be used in combination with CMAKE_OSX_ARCHITECTURES would
support the flag. Obviously the assumption is wrong.

The hard-coded flag needs to be replaced with a lookup of a new
per-language platform information variable, perhaps called

 CMAKE_<LANG>_OSX_ARCHITECTURE_FLAG

-Brad


Some more links:
- https://trac.macports.org/ticket/37732 [^] (about the -arch flag in Fortran)
- https://trac.macports.org/ticket/37688 [^] ([also] about development of a package for Root using CMake)
- https://sft.its.cern.ch/jira/browse/ROOT-4874 [^] (not strictly related)
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0033397)
Brad King (manager)
2013-06-28 09:31

For reference, the full thread where we previously discussed this is here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5876 [^]
(0042305)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-06-28 09:13 Mojca Miklavec New Issue
2013-06-28 09:28 Brad King Additional Information Updated
2013-06-28 09:31 Brad King Note Added: 0033397
2016-06-10 14:29 Kitware Robot Note Added: 0042305
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team