CMake/Modules/Platform
Brad King 7e58e5bb68 Prefer generic system compilers by default for C, C++, and Fortran
Teach CMake to prefer the system default compiler automatically when no
compiler is specified.  By default use "cc" for C, "CC" for C++, and
"f95" for Fortran.  Load a new Platform/<os>-<lang>.cmake module to
allow each platform to specify for each language its system compiler
name(s) and/or exclude certain names.

Create Platform/(CYGWIN|Darwin|Linux|Windows)-CXX.cmake modules to
specify "c++" as the system C++ compiler name for these platforms.  On
systems that use case-insensitive filesystems exclude C++ compiler names
that are distinguished from C compiler names only by case.

This will change the default compiler selection for existing build
scripts that do not specify a compiler when run on machines with
separate system and GNU compilers both installed in the PATH.  We do not
make this change in default behavior lightly.  However:

(1) If a given build really needs specific compilers one should specify
    them explicitly e.g. by setting CC, CXX, and FC in the environment.

(2) The motivating case is to prefer the system Clang on newer OS X
    systems over the older GNU compilers typically also installed.  On
    such systems the names "cc" and "c++" link to Clang.  This is the
    first platform known to CMake on which "c++" is not a GNU compiler.
    The old behavior selected "gcc" for C and "c++" C++ and therefore
    chooses GNU for C and Clang for C++ by default.  The new behavior
    selects GNU or Clang consistently for both languages on older or
    newer OS X systems, respectively.

(3) Other than the motivating OS X case the conditions under which the
    behavior changes do not tend to exist in default OS installations.
    They typically occur only on non-GNU systems with manually-installed
    GNU compilers.

(4) The consequences of the new behavior are not dire.  At worst the
    project fails to compile with the system compiler when it previously
    worked with the non-system GNU compiler.  Such failure is easy to
    work around (see #1).

In short this change creates a more sensible default behavior everywhere
and fixes poor default behavior on a widely-used platform at the cost of
a modest change in behavior in less-common conditions.
2012-08-02 13:26:01 -04:00
..
AIX-GNU-ASM.cmake Add ASM platform information for GNU compiler on AIX (#13390) 2012-07-10 15:18:55 -04:00
AIX-GNU-C.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
AIX-GNU-CXX.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
AIX-GNU-Fortran.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
AIX-GNU.cmake AIX-GNU: Link shared libs with -brtl,-bnoipath (#13352) 2012-07-09 17:18:41 -04:00
AIX-VisualAge-C.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
AIX-VisualAge-CXX.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
AIX-VisualAge-Fortran.cmake XL: Fix old VisualAge branding of Fortran compiler 2011-08-02 17:26:29 -04:00
AIX-XL-ASM.cmake Add ASM platform information for XL compiler on AIX 2011-03-02 13:48:04 -05:00
AIX-XL-C.cmake Factor AIX and XL compiler flags into common module 2011-03-02 11:20:50 -05:00
AIX-XL-CXX.cmake Factor AIX and XL compiler flags into common module 2011-03-02 11:20:50 -05:00
AIX-XL-Fortran.cmake Factor AIX and XL compiler flags into common module 2011-03-02 11:20:50 -05:00
AIX-XL.cmake Move RPATH flags to AIX per-compiler information files 2011-03-02 11:21:54 -05:00
AIX.cmake Move RPATH flags to AIX per-compiler information files 2011-03-02 11:21:54 -05:00
BSDOS.cmake BUG: also include UnixPaths.cmake on these platforms, this also sets UNIX to 1 2007-08-10 08:54:42 -04:00
BeOS.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
BlueGeneL.cmake ENH: Rename SET_PROPERITES command to SET_PROPERTY and give it a more powerful signature. 2008-01-17 15:54:49 -05:00
BlueGeneP-base.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
BlueGeneP-dynamic-GNU-C.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic-GNU-CXX.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic-GNU-Fortran.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic-XL-C.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic-XL-CXX.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic-XL-Fortran.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-dynamic.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-GNU-C.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-GNU-CXX.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-GNU-Fortran.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-XL-C.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-XL-CXX.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static-XL-Fortran.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
BlueGeneP-static.cmake Add platform files for BlueGene/P systems 2010-08-13 12:17:57 -04:00
CYGWIN-CXX.cmake Prefer generic system compilers by default for C, C++, and Fortran 2012-08-02 13:26:01 -04:00
CYGWIN-GNU-C.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
CYGWIN-GNU-CXX.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
CYGWIN-GNU-Fortran.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
CYGWIN-GNU.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
CYGWIN-windres.cmake Add support for windres to cygwin. 2010-12-23 17:04:50 -05:00
CYGWIN.cmake Cygwin: Do not define 'WIN32' (#10122) 2010-12-17 14:19:58 -05:00
Catamount.cmake ENH: Rename SET_PROPERITES command to SET_PROPERTY and give it a more powerful signature. 2008-01-17 15:54:49 -05:00
Darwin-Absoft-Fortran.cmake Absoft: Detect implicit link libraries on Linux and Mac 2011-05-20 08:57:51 -04:00
Darwin-CXX.cmake Prefer generic system compilers by default for C, C++, and Fortran 2012-08-02 13:26:01 -04:00
Darwin-GNU-C.cmake Fix issue #10155 - default value of CMAKE_OSX_DEPLOYMENT_TARGET should always be the empty string. When the value of CMAKE_OSX_DEPLOYMENT_TARGET is the empty string, the -mmacosx-version-min flag should not show up on the compiler command line. The logic for selecting default value of CMAKE_OSX_SYSROOT is orthogonal to and independent of the value of the deployment target. The default value for CMAKE_OSX_SYSROOT is the SDK that corresponds to the current version of Mac OSX on which cmake is running. 2010-01-29 11:56:35 -05:00
Darwin-GNU-CXX.cmake Fix issue #10155 - default value of CMAKE_OSX_DEPLOYMENT_TARGET should always be the empty string. When the value of CMAKE_OSX_DEPLOYMENT_TARGET is the empty string, the -mmacosx-version-min flag should not show up on the compiler command line. The logic for selecting default value of CMAKE_OSX_SYSROOT is orthogonal to and independent of the value of the deployment target. The default value for CMAKE_OSX_SYSROOT is the SDK that corresponds to the current version of Mac OSX on which cmake is running. 2010-01-29 11:56:35 -05:00
Darwin-GNU-Fortran.cmake Fix OS X dylib and module GNU flags 2009-12-02 15:09:03 -05:00
Darwin-GNU.cmake Pass Mac linker flag through all compilers with -Wl, 2010-12-22 16:28:54 -05:00
Darwin-NAG-Fortran.cmake Add NAG Fortran compiler information files 2010-12-09 18:12:34 -05:00
Darwin-VisualAge-C.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
Darwin-VisualAge-CXX.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
Darwin-XL-C.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
Darwin-XL-CXX.cmake Split XL compiler information files 2009-09-30 09:37:35 -04:00
Darwin-icc.cmake Mac: Add guards to CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE defaults 2012-05-31 08:10:17 -04:00
Darwin-icpc.cmake ENH: Add Intel compiler module files for the Mac. Thanks to Mike Jackson for contributing. 2008-03-31 08:04:12 -04:00
Darwin.cmake Mac: Add guards to CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE defaults 2012-05-31 08:10:17 -04:00
DragonFly.cmake ENH: add DragonFly BSD, which is very close to FreeBSD (#4500) 2007-07-13 11:20:42 -04:00
FreeBSD.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
GNU.cmake multiarch: Set CMAKE_LIBRARY_ARCHITECTURE_REGEX for Linux|Hurd|kFreeBSD 2011-06-13 11:12:23 -04:00
GNUtoMS_lib.bat.in Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 2011-12-05 18:13:49 -05:00
GNUtoMS_lib.cmake Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 2011-12-05 18:13:49 -05:00
Generic-ADSP-ASM.cmake ENH: add support for the ADSP toolchains for Blackfin, Shark and TigerShark 2007-07-12 13:41:00 -04:00
Generic-ADSP-C.cmake ENH: add support for the ADSP toolchains for Blackfin, Shark and TigerShark 2007-07-12 13:41:00 -04:00
Generic-ADSP-CXX.cmake ENH: add support for the ADSP toolchains for Blackfin, Shark and TigerShark 2007-07-12 13:41:00 -04:00
Generic-ADSP-Common.cmake ENH: add support for the ADSP toolchains for Blackfin, Shark and TigerShark 2007-07-12 13:41:00 -04:00
Generic-SDCC-C.cmake ENH: Create COMPILE_DEFINITIONS property for targets and source files. Create <config>_COMPILE_DEFINITIONS property as per-configuration version. Add Preprocess test to test the feature. Document limitations on Xcode and VS6 generators. 2008-01-14 09:20:58 -05:00
Generic.cmake -add basic search directories for the "Generic" platform 2010-04-14 22:09:19 +02:00
HP-UX-GNU-C.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
HP-UX-GNU-CXX.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
HP-UX-GNU-Fortran.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
HP-UX-GNU.cmake Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
HP-UX-HP-ASM.cmake HP: Drive shared library linking with compiler front end 2011-12-14 09:32:27 -05:00
HP-UX-HP-C.cmake HP: Drive shared library linking with compiler front end 2011-12-14 09:32:27 -05:00
HP-UX-HP-CXX.cmake HP: Drive shared library linking with compiler front end 2011-12-14 09:32:27 -05:00
HP-UX-HP-Fortran.cmake HP: Drive shared library linking with compiler front end 2011-12-14 09:32:27 -05:00
HP-UX-HP.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
HP-UX.cmake Factor HP compiler flags into per-platform/per-compiler files 2011-03-02 17:24:36 -05:00
Haiku.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
IRIX.cmake Reduce duplication in Platform/<os>.cmake files 2009-12-02 15:17:53 -05:00
IRIX64.cmake Reduce duplication in Platform/<os>.cmake files 2009-12-02 15:17:53 -05:00
Linux-Absoft-Fortran.cmake Absoft: Detect implicit link libraries on Linux and Mac 2011-05-20 08:57:51 -04:00
Linux-CXX.cmake Prefer generic system compilers by default for C, C++, and Fortran 2012-08-02 13:26:01 -04:00
Linux-Clang-C.cmake Recognize Clang C and C++ compilers (see #10693) 2010-05-17 14:11:20 -04:00
Linux-Clang-CXX.cmake Recognize Clang C and C++ compilers (see #10693) 2010-05-17 14:11:20 -04:00
Linux-GNU-C.cmake Create Linux GNU compiler flag consolidation macro 2010-01-13 08:13:19 -05:00
Linux-GNU-CXX.cmake Create Linux GNU compiler flag consolidation macro 2010-01-13 08:13:19 -05:00
Linux-GNU-Fortran.cmake Create Linux GNU compiler flag consolidation macro 2010-01-13 08:13:19 -05:00
Linux-GNU.cmake Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Linux-Intel-C.cmake Consolidate Linux Intel compiler information 2009-12-04 09:20:24 -05:00
Linux-Intel-CXX.cmake Consolidate Linux Intel compiler information 2009-12-04 09:20:24 -05:00
Linux-Intel-Fortran.cmake Consolidate Linux Intel compiler information 2009-12-04 09:20:24 -05:00
Linux-Intel.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
Linux-NAG-Fortran.cmake Add NAG Fortran compiler information files 2010-12-09 18:12:34 -05:00
Linux-PGI-C.cmake Generalize support for Portland Group Compiler 2009-12-04 10:21:57 -05:00
Linux-PGI-CXX.cmake Generalize support for Portland Group Compiler 2009-12-04 10:21:57 -05:00
Linux-PGI-Fortran.cmake Generalize support for Portland Group Compiler 2009-12-04 10:21:57 -05:00
Linux-PGI.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
Linux-PathScale-C.cmake Add PathScale shared library flags on Linux 2010-01-21 09:09:27 -05:00
Linux-PathScale-CXX.cmake Add PathScale shared library flags on Linux 2010-01-21 09:09:27 -05:00
Linux-PathScale-Fortran.cmake Add PathScale shared library flags on Linux 2010-01-21 09:09:27 -05:00
Linux-PathScale.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
Linux-SunPro-CXX.cmake Fix rpath-link flag for SunPro C++ 5.11 on Linux 2010-06-07 10:15:58 -04:00
Linux-TinyCC-C.cmake TinyCC: Add compiler info for shared libs on Linux (#12605) 2011-12-02 10:23:48 -05:00
Linux-VisualAge-C.cmake Teach compiler id about VisualAge -> XL rebranding 2009-08-07 10:13:07 -04:00
Linux-VisualAge-CXX.cmake Fix XL C++ compiler flags on Linux 2009-09-16 12:33:24 -04:00
Linux-VisualAge-Fortran.cmake Teach compiler id about VisualAge -> XL rebranding 2009-08-07 10:13:07 -04:00
Linux-XL-C.cmake Remove GNU-specific flags from Linux.cmake 2009-12-04 10:22:30 -05:00
Linux-XL-CXX.cmake Remove GNU-specific flags from Linux.cmake 2009-12-04 10:22:30 -05:00
Linux-XL-Fortran.cmake Remove GNU-specific flags from Linux.cmake 2009-12-04 10:22:30 -05:00
Linux-como.cmake Drop -rdynamic from Linux build rules 2009-12-01 14:25:21 -05:00
Linux.cmake multiarch: Set CMAKE_LIBRARY_ARCHITECTURE_REGEX for Linux|Hurd|kFreeBSD 2011-06-13 11:12:23 -04:00
MP-RAS.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
NetBSD.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
OSF1.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
OpenBSD.cmake OpenBSD: Work-around static/runtime linker inconsistency 2010-03-26 09:33:28 -04:00
OpenVMS.cmake ENH: use .exe on vms 2009-06-11 15:25:48 -04:00
QNX.cmake Reduce duplication in Platform/<os>.cmake files 2009-12-02 15:17:53 -05:00
RISCos.cmake BUG: also include UnixPaths.cmake on these platforms, this also sets UNIX to 1 2007-08-10 08:54:42 -04:00
SCO_SV.cmake Factor SCO compiler info out of platform file (#11700) 2011-01-17 09:57:17 -05:00
SINIX.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
SunOS-GNU-C.cmake Fix GNU C and Fortran flags on SunOS 2009-12-04 08:51:46 -05:00
SunOS-GNU-CXX.cmake Split GNU compiler information files 2009-12-02 09:52:00 -05:00
SunOS-GNU-Fortran.cmake Fix GNU C and Fortran flags on SunOS 2009-12-04 08:51:46 -05:00
SunOS-GNU.cmake Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
SunOS.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
Tru64.cmake ENH: add more search paths and add UnixPaths to all unix platforms 2006-03-27 10:46:42 -05:00
ULTRIX.cmake ENH: add more search paths and add UnixPaths to all unix platforms 2006-03-27 10:46:42 -05:00
UNIX_SV.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
UnixPaths.cmake Search MacPorts /opt/local prefix on Mac 2010-09-01 08:50:51 -04:00
UnixWare.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00
Windows-Borland-C.cmake Recognize Embarcadero compiler (#12604) 2012-02-20 10:09:44 -05:00
Windows-Borland-CXX.cmake Recognize Embarcadero compiler (#12604) 2012-02-20 10:09:44 -05:00
Windows-CXX.cmake Prefer generic system compilers by default for C, C++, and Fortran 2012-08-02 13:26:01 -04:00
Windows-Embarcadero-C.cmake Recognize Embarcadero compiler (#12604) 2012-02-20 10:09:44 -05:00
Windows-Embarcadero-CXX.cmake Recognize Embarcadero compiler (#12604) 2012-02-20 10:09:44 -05:00
Windows-Embarcadero.cmake Add platform variable for flags specific to shared libraries 2012-06-12 15:38:48 -04:00
Windows-G95-Fortran.cmake Teach CMake how to work with G95 on mingw. 2010-03-23 11:32:40 -04:00
Windows-GNU-C-ABI.cmake Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 2011-12-05 18:13:49 -05:00
Windows-GNU-C.cmake Modernize GNU compiler info on Windows 2009-12-02 11:27:59 -05:00
Windows-GNU-CXX-ABI.cmake Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 2011-12-05 18:13:49 -05:00
Windows-GNU-CXX.cmake Modernize GNU compiler info on Windows 2009-12-02 11:27:59 -05:00
Windows-GNU-Fortran-ABI.cmake Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 2011-12-05 18:13:49 -05:00
Windows-GNU-Fortran.cmake Fortran: Detect pointer size in gfortran on MinGW 2011-12-05 16:32:29 -05:00
Windows-GNU.cmake Ninja: disable work around when linking with mingw 2012-07-11 08:55:00 +02:00
Windows-Intel-ASM.cmake Add support for the Intel compiler used for ASM under Windows 2011-03-02 16:46:25 +01:00
Windows-Intel-C.cmake Modernize Intel compiler info on Windows 2010-12-16 09:50:05 -05:00
Windows-Intel-CXX.cmake Intel: On Windows use /EHsc instead of deprecated /GX (#13163) 2012-04-24 09:00:37 -04:00
Windows-Intel-Fortran.cmake Intel: Fix Windows per-config Fortran flags (#12642) 2012-01-02 13:56:33 -05:00
Windows-Intel.cmake Intel: On Windows use /RTC1 instead of deprecated /GZ (#13174) 2012-04-30 08:29:47 -04:00
Windows-NMcl.cmake ENH: add platform file for bounds checker 2008-08-15 15:07:56 -04:00
Windows-cl.cmake Ninja: don't define MSVC_IDE when using the ninja generator 2012-02-18 11:24:41 +01:00
Windows-cl.cmake.in Fix missing set of MSVC10 and add CheckCompilerRelatedVariables test. 2010-04-30 00:46:24 -04:00
Windows-df.cmake Add module-dir flag for Compaq Visual Fortran (#11248) 2010-09-20 09:53:45 -04:00
Windows-wcl386.cmake Add platform variable for flags specific to shared libraries 2012-06-12 15:38:48 -04:00
Windows-windres.cmake Add support for windows resources with mingw/msys. 2010-12-23 17:04:49 -05:00
Windows.cmake ENH: UNIX, CYGWIN, WIN32, APPLE, QNXNTO and BEOS are not longer set in 2007-08-09 14:45:23 -04:00
WindowsPaths.cmake Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Xenix.cmake ENH: add more search paths and add UnixPaths to all unix platforms 2006-03-27 10:46:42 -05:00
cl.cmake ENH: Handle large object file lists on some platforms 2008-02-27 17:10:45 -05:00
eCos.cmake guard eCos.cmake against multiple inclusion (#12987) 2012-03-20 22:13:47 +01:00
gas.cmake ENH: initial support for assembler in cmake, needs testing by our users 2007-06-28 09:14:27 -04:00
kFreeBSD.cmake multiarch: Set CMAKE_LIBRARY_ARCHITECTURE_REGEX for Linux|Hurd|kFreeBSD 2011-06-13 11:12:23 -04:00
syllable.cmake Add platform variables for position independent code flags 2012-06-12 15:37:53 -04:00