Fix compiler detection on Mac OS X

Set the CMake variables CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET
must be set before the project() command since they can effect compiler
detection and capability tests.

Only use the -stdlib=libc++ option on Mac OS X when using Clang tools.
On other platforms with Clang tools libc+ is not currently the best choice.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4938 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-02-06 14:37:10 +00:00
parent 1271243952
commit f60c2e19c5

View File

@ -1,5 +1,32 @@
cmake_minimum_required (VERSION 2.8.10 FATAL_ERROR)
if (APPLE)
#
# The following variables define the portability and compatability attributes of the Mac OS X build
# they are choosen with care and should not be changed without good cause. Note that they preclude
# doing a default build on OS X 10.7 since there is no 10.9 SDK available for Mac OS X 10.7. This doesn't
# preclude builds on newer versions of OS X being installed on Mac OS X 10.7, in fact it is exacty these
# options that ensure offcial build run on 10.7 and newer versions of Mac OS X. At some point it may
# be that some new version cannot be supported as well as 10.7, at that point the deployment target below
# must be moved on to 10.8 and we can no longer support Mac OS X 10.7.
#
# Among other things these options are chosen to match the portability and compatability options of the
# Qt framework dylibs which can be checked as follows:
#
# otool -l <binary> | grep -A3 LC_VERSION_MIN_MACOSX
#
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.7
CACHE STRING "Earliest version of OS X supported
Earliest version we can support with C++11 & libc++ is 10.7.
Do not override this if you intend to build an official deployable installer.")
set (CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
CACHE STRING "Mac OS X SDK to build with
Change this to the newest SDK available that you can install on your system (10.9 preferred).
Do not override this if you intend to build an official deployable installer.")
endif (APPLE)
project (wsjtx C CXX Fortran)
#
@ -458,31 +485,9 @@ if (WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-keep-inline-dllexport")
endif (WIN32)
if (APPLE)
#
# The following variables define the portability and compatability attributes of the Mac OS X build
# they are choosen with care and should not be changed without good cause. Note that they preclude
# doing a default build on OS X 10.7 since there is no 10.9 SDK available for Mac OS X 10.7. This doesn't
# preclude builds on newer versions of OS X being installed on Mac OS X 10.7, in fact it is exacty these
# options that ensure offcial build run on 10.7 and newer versions of Mac OS X. At some point it may
# be that some new version cannot be supported as well as 10.7, at that point the deployment target below
# must be moved on to 10.8 and we can no longer support Mac OS X 10.7.
#
# Among other things these options are chosen to match the portability and compatability options of the
# Qt framework dylibs which can be checked as follows:
#
# otool -l <binary> | grep -A3 LC_VERSION_MIN_MACOSX
#
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set (CMAKE_OSX_DEPLOYMENT_TARGET 10.7
CACHE STRING "Earliest version of OS X supported
Earliest version we can support with C++11 & libc++ is 10.7.
Do not override this if you intend to build an official deployable installer.")
set (CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
CACHE STRING "Mac OS X SDK to build with
Change this to the newest SDK available that you can install on your system (10.9 preferred).
Do not override this if you intend to build an official deployable installer.")
endif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
else (APPLE)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")