Commit Graph

105 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Ben Boeckel 2bdba83e4b issues: update references to the CMake issue tracker
References to specific comments are left as-is since comments were not
migrated.
2016-08-15 09:34:06 -04:00
Brad King f6c2189495 Modules: Rename internal platform-specific compiler determination modules
Rename Modules/Platform/<os>-<lang>.cmake files to
Modules/Platform/<os>-Determine-<lang>.cmake to clarify their role.
For compatibility with user-provided modules, load the old names
if they exist.
2016-06-02 09:51:43 -04:00
Paweł Stankowski 53c0dc2dd2 Add support for Bruce C Compiler (BCC)
Revise C compiler detection code to be K&R compatible.
2016-03-21 10:51:50 -04:00
Brad King da7276cf94 Replace http://www.cmake.org URLs with https://cmake.org
The latter is now the preferred URL for visiting cmake.org with a
browser.  Convert using the shell code:

 git ls-files -z | xargs -0 sed -i 's|http://www\.cmake|https://cmake|g'
2015-09-25 15:47:39 -04:00
Brad King 109a7a245a Ninja: Detect MSVC /showIncludes prefix with compiler flags (#15596)
Move detection over to the compiler id logic where we have already
constructed the list of compiler flags from ARG1 and CMAKE_<LANG>_FLAGS.
Pass the flags when we execute "cl" with "/showIncludes".  Also pass "/c"
because we only need to compile, not link.  Check the compiler process
exit code before trusting its output.
2015-09-18 10:02:53 -04:00
Brad King 162e7b5675 Merge topic 'determine-compiler-CMP0054'
dc8822f0 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments
2015-08-21 09:28:50 -04:00
Matt McCormick dc8822f0a7 CMakeDetermine{C,CXX}Compiler: Avoid if() auto-dereferene in quoted arguments
Exposed by a CMP0054 warning with code like:

  cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
  project(MyProj NONE)
  enable_language(C)
  enable_language(CXX)

While at it, use STREQUAL for testing the compiler id against "GNU".

Suggested-by: Rolf Eike Beer <eike@sf-mail.de>
2015-08-20 09:35:16 -04:00
Brad King 99d160385e CMakeDetermineCompilerId: Use per-language regex to match Xcode compiler tool
Move the Ld invocation match expression from CMakeDetermineCompilerId
into CMakeDetermine{C,CXX,Fortran}Compiler so that it can be specified
on a per-language basis.
2015-06-30 10:14:08 -04:00
Brad King c65a060e1b CMakeDetermineCompilerId: Optionally try some flags before no flags
Teach CMAKE_DETERMINE_COMPILER_ID to optionally try detecting the
compiler id using some given flags before trying to detect it with no
special flags.  This will be useful for Fortran detection to distinguish
some compilers that use the preprocessors of others but have no macro of
their own by getting verbose output.
2015-06-18 10:59:35 -04:00
Ben Boeckel 29c3edb87a Avoid if() quoted auto-dereference
When testing CMAKE_<LANG>_COMPILER_ID values, do not explicitly
dereference or quote the variable. We want if() to auto-dereference the
variable and not its value. Also replace MATCHES with STREQUAL where
equivalent.
2014-10-20 11:49:16 -04:00
Brad King d11a19528e Merge topic 'fix-clang-cross-compile-find-binutils'
72d66818 Fix finding binutils when cross-compiling with Clang
2014-09-08 12:57:01 -04:00
Brad King 72d6681826 Fix finding binutils when cross-compiling with Clang
Since commit v3.0.0-rc1~342^2~2 (Add compiler target compile options,
2013-05-19) we use CMAKE_<LANG>_COMPILER_TARGET as the binutils prefix
when cross-compiling with Clang.  Fix the implementation to use the
compiler target as the prefix only when it is set.  Otherwise toolchain
files not using CMAKE_<LANG>_COMPILER_TARGET cause the logic to use
a prefix of just "-" and of course cannot find "-ar" or "-ld".
2014-09-05 12:06:27 -04:00
Rolf Eike Beer 7eacbaed4d Replace MATCHES ".+" tests with NOT STREQUAL "" 2014-04-14 18:17:23 +02:00
Rolf Eike Beer b0b4b4602f Remove .* expressions from beginning and end of MATCHES regexs
All these expressions work the same:
  "foo"
  ".*foo.*"
  "^.*foo.*$"

This assumes that the "Intel*" expressions were meant to be "Intel.*".
2014-04-14 18:17:11 +02:00
Brad King 8c9bfac384 Xcode: Convert forced CMAKE_<LANG>_COMPILER to full path if possible
During cross-compiling the toolchain file may use CMakeForceCompiler to
force a compiler setting.  When using the Xcode generator try to convert
it to a full path by searching the PATH as is done for the Makefile
generators.
2014-03-10 17:12:00 -04:00
Brad King 6852fb8034 CMakeDetermine*Compiler: Factor out search for compiler in PATH
Factor out a _cmake_find_compiler_path helper macro to avoid duplication
of the search for a full path to the compiler.
2014-03-10 17:12:00 -04:00
Stephen Kelly d2dea79b36 CMakeDetermine*Compiler: Fix typo 'lile' => 'like' 2014-01-22 08:43:58 -05:00
Stephen Kelly 76552d595d Add compiler target compile options.
For clang, this allows passing -target <triple> to the compiler, and
for qcc, -V<arch> using toolchain files containing something like

 set(triple arm-linux-gnueabihf)
 set(CMAKE_C_COMPILER "/usr/bin/clang")
 set(CMAKE_C_COMPILER_TARGET ${triple})
 set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
 set(CMAKE_CXX_COMPILER_TARGET ${triple})

or

 set(arch gcc_ntoarmv7le)
 set(CMAKE_C_COMPILER /opt/qnx650/host/linux/x86/usr/bin/qcc)
 set(CMAKE_C_COMPILER_TARGET ${arch})
 set(CMAKE_CXX_COMPILER /opt/qnx650/host/linux/x86/usr/bin/QCC)
 set(CMAKE_CXX_COMPILER_TARGET ${arch})

Both clang and qcc are inherently cross compiler( driver)s.

When cross-compiling with clang, use the CMAKE_${lang}_COMPILER_TARGET
as the _CMAKE_TOOLCHAIN_PREFIX to find the appropriate binutils.

When cross-compiling with QNX qcc, use the CMAKE_${lang}_COMPILER_TARGET
to set the appropriate _CMAKE_TOOLCHAIN_PREFIX.
2013-11-19 12:38:53 -05:00
Daniele E. Domenichelli 15610bb5b1 Drop use of configure_file IMMEDIATE option
Since commit 7d47c693 (Drop compatibility with CMake < 2.4, 2013-10-08)
we no longer need to use the configure_file IMMEDIATE option to support
compatibility modes less than 2.0.
2013-11-13 10:12:17 -05:00
Brad King 16df2456a4 Merge topic 'enable-language-require-compiler'
3e04946 Require CMAKE_<LANG>_COMPILER to be found as a full path
6007f7c CMakeDetermineCompilerId: Always use compiler detected from IDE
332771c CMakeDetermine*Compiler: Remove temporary cache entry
2013-10-28 08:39:29 -04:00
Brad King e378bc6441 Merge topic 'ninja-use-deps'
eeb4aec Ninja: use deps = gcc/msvc feature
2013-10-28 08:38:40 -04:00
Stephen Kelly b84f5c2ef1 Find appropriate binutils when cross-compiling with clang
One way to use clang as a cross-compiler is to create
a symlink named <target>-clang, which is equivalent to
running

 clang -target <target>

Extract the toolchain prefix to find the binutils executables.
2013-10-25 07:01:38 +02:00
Peter Kümmel eeb4aece1c Ninja: use deps = gcc/msvc feature
cmcldeps is now only used for .rc file processing
2013-10-24 19:48:18 +02:00
Brad King 332771c942 CMakeDetermine*Compiler: Remove temporary cache entry
When the user or toolchain file sets CMAKE_<LANG>_COMPILER to a name
without a path we use find_program with CMAKE_<LANG>_COMPILER_WITH_PATH
to search for the tool.  Remove the temporary cache entry afterward to
avoid exposing it to projects.  It is not set by other logic paths so no
one should be using it.
2013-10-24 11:34:07 -04:00
Alex Neundorf d33f40638d Add regexps for the IAR toolchain to the vendor list.
The IAR compilers produce object files where the plain strings at least
sometimes can't be found, see:

  http://www.cmake.org/Bug/view.php?id=10176#c19598

Alex
2013-04-15 09:13:10 -04:00
Alex Neundorf 27e6f6ef39 TI compiler: add automatic detection of prefix and suffixes
The TI cross compilers are named e.g. cl6x or armcl, the accompanying
strip and ar have the same prefixes/suffixes.

Alex
2013-03-14 21:48:09 +01:00
Alex Neundorf 12b25df882 Determine C/CXX/Fortran compiler: fix indentation
Alex
2013-03-14 21:47:49 +01:00
Alex Neundorf 7baa55ac0b Determine C/CXX/Fortran compiler: minor restructuring
No functional changes, only change the way the if()-condition works,
to make it easier to add more cases.

Alex
2013-03-14 21:47:38 +01:00
Brad King a4c47fe0c7 Merge topic 'cmake-platform-info-version'
e5fee8a Store ABI detection results in compiler information files
3df81b4 Move CMAKE_<LANG>_COMPILER_WORKS to compiler information files
7195aca Make platform information files specific to the CMake version
2012-08-30 11:06:15 -04:00
David Cole 34a0284603 Merge topic 'ide-compiler-id'
403ead6 Document CMAKE_<LANG>_COMPILER_(ID|VERSION) values
8be51f6 Test variables CMAKE_(C|CXX|Fortran)_COMPILER(|_ID|_VERSION)
ec22a9b Cleanly enable a language in multiple subdirectories
66cb335 VS: Detect the compiler id and tool location
89595d6 VS10: Define CMAKE_VS_PLATFORM_TOOLSET variable
965a69d Xcode: Detect the compiler id and tool location
9a9e1ee CMakeDetermineCompilerId: Prepare to detect IDE compiler id
b8b5c83 Re-order C/C++/Fortran compiler determination logic
2012-08-24 14:25:40 -04:00
Brad King 7195aca54f Make platform information files specific to the CMake version
At the top of a build tree we configure inside the CMakeFiles directory
files such as "CMakeSystem.cmake" and "CMake<lang>Compiler.cmake" to
save information detected about the system and compilers in use.  The
method of detection and the exact results store varies across CMake
versions as things improve.  This leads to problems when loading files
configured by a different version of CMake.  Previously we ignored such
existing files only if the major.minor part of the CMake version
component changed, and depended on the CMakeCache.txt to tell us the
last version of CMake that wrote the files.  This led to problems if the
user deletes the CMakeCache.txt or we add required information to the
files in a patch-level release of CMake (still a "feature point" release
by modern CMake versioning convention).

Ensure that we always have version-consistent platform information files
by storing them in a subdirectory named with the CMake version.  Every
version of CMake will do its own system and compiler identification
checks even when a build tree has already been configured by another
version of CMake.  Stored results will not clobber those from other
versions of CMake which may be run again on the same tree in the future.
Loaded results will match what the system and language modules expect.

Rename the undocumented variable CMAKE_PLATFORM_ROOT_BIN to
CMAKE_PLATFORM_INFO_DIR to clarify its purpose.  The new variable points
at the version-specific directory while the old variable did not.
2012-08-24 10:52:23 -04:00
Brad King 66cb3356f5 VS: Detect the compiler id and tool location
Configure a hand-generated Visual Studio project to build the compiler id
source file since we cannot run the compiler command-line tool directly.
Add a post-build command to print out the full path to the compiler tool.
Parse the full path to the compiler tool from the build output.
2012-08-22 16:35:54 -04:00
Brad King 965a69dcaa Xcode: Detect the compiler id and tool location
Configure a hand-generated Xcode project to build the compiler id source
file since we cannot run the compiler command-line tool directly.  Add a
post-build shell script phase to print out the compiler toolset build
setting.  Run xcodebuild to compile the identification binary.  Parse
the full path to the compiler tool from the xcodebuild output.
2012-08-22 15:14:33 -04:00
Brad King b8b5c8342a Re-order C/C++/Fortran compiler determination logic
Re-organize CMakeDetermine(C|CXX|Fortran)Compiler.cmake to search for
the compiler command-line tool only under generators for which it makes
sense.  For the Visual Studio generators we do not expect to find the
compiler tool from the environment, nor would we use the result anyway.

Furthermore, set CMAKE_${lang}_COMPILER_ID_TEST_FLAGS only when it has a
chance to be used.  Extract _CMAKE_TOOLCHAIN_LOCATION from the compiler
path after running the compiler id step so in the future that step can
help find the path to the compiler.
2012-08-22 15:14:33 -04:00
Marcin Wojdyr 84b49be8f0 Remove CMake multiline block-end command arguments
removing arguments omitted in 9db3116226
2012-08-15 16:50:29 -04:00
Kitware Robot 9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Kitware Robot 77543bde41 Convert CMake-language commands to lower case
Ancient CMake versions required upper-case commands.  Later command
names became case-insensitive.  Now the preferred style is lower-case.

Run the following shell code:

cmake --help-command-list |
grep -v "cmake version" |
while read c; do
    echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
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
Brad King 796e33734d Factor common code out of CMakeDetermine(ASM|C|CXX|Fortran)Compiler
The compiler candidate list selection and search code for C, C++, ASM,
and Fortran languages was duplicated across four modules.  To look for
compilers adjacent to already-enabled languages the C and CXX modules
each used _CMAKE_USER_(C|CXX)_COMPILER_PATH and the ASM module used
_CMAKE_TOOLCHAIN_LOCATION.  Since commit 4debb7ac (Bias Fortran compiler
search with C/C++ compilers, 2009-09-09) CMake prefers Fortran compilers
matching the vendor and directory of an enabled C or C++ compiler.

Factor out the common functionality among the four languages into a new
CMakeDetermineCompiler module.  Generalize the Fortran implementation so
that all languages may each use the vendor and directory of the other
languages that have already been enabled.  For now do not list any
vendor-specific names for C, C++, or ASM so that only the directory
preference is used for these languages (existing behavior).
2012-08-02 11:33:18 -04:00
Brad King b708f1a2b9 CMakeDetermine(C|CXX)Compiler: Consider Clang compilers
Look for "clang" or "clang++" compiler executables so Clang will be used
when it is the only compiler available.  Prefer them last to avoid
changing compiler default preferences for existing scripts.
2012-07-31 14:30:30 -04:00
Brad King b9ccaf5f79 CMakeDetermineCCompiler: Fix typo "_CXX_" -> "_C_" (#13330)
Initialize CMAKE_C_COMPILER_INIT before using it, rather than
CMAKE_CXX_COMPILER_INIT.
2012-06-20 15:38:53 -04:00
Peter Kuemmel 941afa571c Ninja: allow spaces in source path
And make /showIncude prefix visible for all build rules
2012-06-08 22:59:18 +02:00
Brad King 38aab37962 Set CMAKE_<lang>_COMPILER_ID for VS generators
Currently the VS generators do not support Intel C/C++ .icproj files and
the MS tools do not include a Fortran compiler.  Therefore we can always
set the C and CXX compiler IDs to "MSVC" and the Fortran ID to "Intel".

This fixes a regression in support for the Intel Fortran compiler under
the VS plugin introduced by commit cd43636c (Modernize Intel compiler
info on Windows, 2010-12-16).  The commit moved the compiler information
into platform files that only load when the proper compiler id is set.
It worked for the NMake Makefiles generator but not for the VS IDE
generator because it did not set the compiler id.
2011-09-02 08:56:01 -04:00
Alex Neundorf 5883c5191e Fix parsing of compiler name with a version number
This fixes #11679, the toolchain prefix was not correctly detected
for arm-eabi-gcc-4.5.2

Alex
2011-01-26 20:52:34 +01:00
Alex Neundorf bd57bc5312 Strip trailing whitespace.
Alex
2011-01-26 20:51:25 +01:00
Todd Gamblin 2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Bill Hoffman 4430bccc70 Change the way 32/64 bit compiles are detected with MSVC and intel makefile builds. Use the platform ID preprocessor approach. 2009-11-19 21:58:42 -05:00
Brad King 3a666595c9 Convert CMake non-find modules to BSD License
This adds copyright/license notification blocks CMake's non-find
modules.  Most of the modules had no notices at all.  Some had notices
referring to the BSD license already.  This commit normalizes existing
notices and adds missing notices.
2009-09-28 11:46:51 -04:00
Brad King a30a41e5ca ENH: Identify HP C compiler
This compiler does not enable ANSI mode by default.  When identifying
the C compiler we try passing -Aa in case it is the HP compiler.
2009-07-08 09:14:56 -04:00