On 24/10/2014 18:39, Zaak Beekman wrote:
Hi Bill,
Hi Zaak,
thanks for the detailed suggestions, more comments in line below.
I feel your pain. I suspect a CMake bug is hidden away somewhere
causing this behavior, and have struggled with this quite a lot.
I think you are correct.
I *think* explicitly passing the relevant option to the linker fixes
this, although I have some other CMake/Fortran/Mac hackery happening
in my CMakeLists.txt and I can’t remember the reasoning for
everything. The following is wrapped in something like if(APPLE), and
annoyingly, a slightly different form needs to be used if passing this
flag to the linker when using the Intel compilers:
if ( CMAKE_OSX_DEPLOYMENT_TARGET )
set ( CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS}
-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}" )
endif ( CMAKE_OSX_DEPLOYMENT_TARGET )
I *suspect* this work around will fix your problem.
Well in my case it is the compiler flags that need adding to.
I think what is happening is that the compiler is using an intrinsic
system call __stret_sincos to optimize sin and cos calculations with the
same arguments, this is only available on 10.9 so builds done on 10.9
will not run on earlier versions of OS X unless
-mmacosx-version-min=<version> is specified. This is exactly the reason
for the whole deployment target switch.
I don't know ifort so don't know if it has similar options or even if it
uses system calls that are that new. But for sure passing linker flags
is only part of the solution.
Some more details:
I can’t seem to follow my reasoning for exactly what hacks fixed what
problems; essentially I wanted to build a redistributable binary for
Mac using Fortran sources. Some of my hackery might be to allow for
statically linked builds, but here is my basic approach. First the
main CMakeLists.txt file:
Steering clear of static builds for our project. We have a application
bundle as out Mac deployable so we include any frameworks and extra
support dylibs within that.
cmake_minimum_required ( VERSION 2.8.11 FATAL_ERROR )
include ( checkOutOfSource.cmake )
include ( configurePlatform.cmake )
include ( configureBuilds.cmake )
enable_language ( C )
enable_language ( Fortran )
include ( compiler-specific-settings.cmake )
project ( myproj NONE )
add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/src )
Have found that the order of setting certain variables can make a big
difference, and that some are better set before the project command or
between the enable_language and project command. The other relevant
commands are in configurePlatform.cmake and
compiler-specific-settings.cmake.
In configurePlatform.cmake I have:
if ( APPLE )
set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
CACHE STRING "Oldest OS X version to compile and link for." )
set_property ( CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS
"10.6" "10.7" "10.8" "10.9" )
…
and then in compiler specific settings I have the modification to the
linker flags given above.
I hope this fixes your issue, and that someone with more intimate
knowledge of CMake can work on Fortran support using different
compilers on Mac.
I am rebuilding right now with manually set options. I agree better
Fortran compiler support on Mac seems necessary.
Izaak Beekman
===================================
(301)244-9367
Princeton University Doctoral Candidate
Mechanical and Aerospace Engineering
[email protected] <mailto:[email protected]>
UMD-CP Visiting Graduate Student
Aerospace Engineering
[email protected] <mailto:[email protected]>
[email protected] <mailto:[email protected]>
Regards
Bill.
Message: 3
Date: Fri, 24 Oct 2014 16:31:49 +0100
From: Bill Somerville <[email protected]
<mailto:[email protected]>>
To: CMake ML <[email protected] <mailto:[email protected]>>
Subject: [CMake] OS X Fortran flags
Message-ID: <[email protected]
<mailto:[email protected]>>
Content-Type: text/plain; charset=utf-8; format=flowed
Hi,
I am building some Fortran sources and on Mac I want to make the
resulting executable portable back to 10.7.
So I have:
if (APPLE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.7) # Earliest version we can
support with C++11 & libc++
set (CMAKE_OSX_SYSROOT
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
endif (APPLE)
in my CMakeLists.txt.
I am building on a 10.8 system with the 10.9 SDK installed.
This all works as expected with the C and C++ sources in the
project but
the Fortran compiles are not being passed the relevant options:
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
-mmacosx_version_min=10.7
The Fortran compiler is the MacPorts gcc49 itself built from sources
using the same options so that the distributable libraries
reference the
correct system library function versions.
So what am I missing? A brief scan of the CMake sources looks like it
should be doing this right for GNU compilers as the compiler tests
should check for those options being supported and supply them.
Do I have to add these options to the FFLAGS in my CMakeLists.txt?
Regards
Bill.
------------------------------
Message: 4
Date: Fri, 24 Oct 2014 17:44:56 +0100
From: Bill Somerville <[email protected]
<mailto:[email protected]>>
To: [email protected] <mailto:[email protected]>
Subject: Re: [CMake] OS X Fortran flags
Message-ID: <[email protected]
<mailto:[email protected]>>
Content-Type: text/plain; charset=windows-1252; format=flowed
A small correction:
On 24/10/2014 16:31, Bill Somerville wrote:
> Hi,
>
> I am building some Fortran sources and on Mac I want to make the
> resulting executable portable back to 10.7.
>
> So I have:
>
> if (APPLE)
> set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
> set (CMAKE_OSX_DEPLOYMENT_TARGET 10.7) # Earliest version we can
> support with C++11 & libc++
> set (CMAKE_OSX_SYSROOT
>
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
> endif (APPLE)
>
> in my CMakeLists.txt.
>
> I am building on a 10.8 system with the 10.9 SDK installed.
>
> This all works as expected with the C and C++ sources in the project
> but the Fortran compiles are not being passed the relevant options:
>
> -isysroot
>
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
> -mmacosx_version_min=10.7
-mmacosx-version-min=10.7
>
> The Fortran compiler is the MacPorts gcc49 itself built from sources
> using the same options so that the distributable libraries reference
> the correct system library function versions.
>
> So what am I missing? A brief scan of the CMake sources looks
like it
> should be doing this right for GNU compilers as the compiler tests
> should check for those options being supported and supply them.
>
> Do I have to add these options to the FFLAGS in my CMakeLists.txt?
>
> Regards
> Bill.
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake