Commit Graph

58 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
Brad King 3643390d49 Strip CMAKE_<LANG>_FLAGS[_<CONFIG>] initializer whitespace 2016-07-01 14:01:41 -04:00
Chuck Atkins 5eaac0c96a Compiler: Add infrastructure for detecting compiler wrappers 2015-12-07 11:09:06 -05:00
Brad King 9682de566e Revert "Disable shared library support when compiler links statically" (#15855)
In commit v3.4.0-rc1~18^2 (Disable shared library support when compiler
links statically, 2015-09-30) we tried to detect when the compiler is
not capable of linking shared libraries (possibly due to flags in use).
However, the approach is not robust against flags like `-nostdlib`.
Revert it for now pending another solution to the original problem.
2015-11-23 10:16:32 -05:00
Brad King 8b4873a1b0 Disable shared library support when compiler links statically
When a user or a compiler wrapper adds '-static' to the compiler flags
then it will always link static binaries.  Detect this from the compiler
id binary and disable TARGET_SUPPORTS_SHARED_LIBS.  This will prevent
projects from accidentally adding shared libraries when the toolchain
does not support them.  It also helps CMake avoid linking with flags
that require shared libraries to be supported.
2015-09-30 15:01:23 -04:00
Brad King 08659ff4cb Re-order 'ar' options 'cq' => 'qc'
The documetnation of binutils:

  https://sourceware.org/binutils/docs/binutils/ar-cmdline.html

suggests to use the parameters "q" and "c" in this order ("q" is
operation, and "c" is the modifier).

Suggested-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
2015-09-09 11:08:20 -04:00
Brad King c736de7b28 Factor an <INCLUDES> placeholder out of <FLAGS> in rule variables
Teach the Makefile and Ninja generators to substitute for an <INCLUDES>
placeholder instead of putting -I in <FLAGS>.  Update our values for

  CMAKE_<LANG>_COMPILE_OBJECT,
  CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE, and
  CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE

to place <INCLUDES> just before <FLAGS>.
2015-07-13 10:49:46 -04:00
Brad King 1ec6485c6a Support duplicate object names in large archives (#14874)
Generalize the change from commit 39d0ade0 (Windows-GNU: Support
duplicate object names in large archives, 2014-04-14) to the default
archive rules.  These rules have used an incremental append approach
since commit v2.8.0~1856 (Build large archives incrementally,
2008-08-04).  Switch from "ar r" to "ar q" to be sure we always append
objects instead of replacing them.
2014-04-16 13:19:43 -04:00
Brad King 5d2452d89a Fix CMAKE_(C|CXX|Fortran)_STANDARD_LIBRARIES helpstrings (#14622)
s/defalut/default/

Reported-by: Stephan Tolksdorf <st@quanttec.com>
2013-12-03 09:21:33 -05:00
Brad King 2b77b53280 Make CMAKE_(C|CXX|Fortran)_<CONFIG> help strings more consistent (#14606)
Use consistent capitalization and write all words out in the cache entry
descriptions.
2013-12-02 10:41:12 -05:00
Brad King 424c6fcc76 Fix CMAKE_(C|CXX|Fortran)_RELEASE helpstrings (#14606)
Remove the platform-specific description from the cache entry help
strings for these variables.
2013-12-02 10:25:52 -05:00
Brad King 4ac75fdfe6 Prefer CMAKE_MAKE_PROGRAM over CMAKE_BUILD_TOOL (#14548)
Historically these were both added for the Makefile and Visual Studio
generators, respectively.  Later the VS generators started using the
CMAKE_MAKE_PROGRAM cache entry to find the IDE build tool, and the
CMAKE_BUILD_TOOL was simply set as an alias.

Fix the documentation to explain that CMAKE_MAKE_PROGRAM is the modern
variable and that CMAKE_BUILD_TOOL is the compatibility alias, not the
other way around.  Replace uses of CMAKE_BUILD_TOOL with
CMAKE_MAKE_PROGRAM in CMake-provided modules.  Nothing needs to lookup
CMAKE_BUILD_TOOL in the cache, so simply set it as a normal variable.
2013-11-18 08:26:23 -05:00
Brad King 705ae00491 Quote ${CMAKE_<LANG>_COMPILER} while enabling a language
Even though this variable gets set to CMAKE_<LANG>_COMPILER-NOTFOUND when
the compiler is not found, CMake<LANG>Compiler.cmake gets removed by
cmGlobalGenerator::EnableLanguage so in try compiles the value is empty.
Quote references to the variable in

 Modules/CMake(C|CXX|Fortran)Information.cmake
 Modules/CMakeDetermineCompilerId.cmake

to avoid dropping arguments from commands that expect them.
2013-10-22 14:09:37 -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
Kitware Robot 7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Stephen Kelly 55d7aa4c44 Add platform variable for flags specific to shared libraries
Store in CMAKE_${lang}_COMPILE_OPTIONS_DLL flags from
CMAKE_SHARED_LIBRARY_${lang}_FLAGS that are truly exclusive to shared
libraries.
2012-06-12 15:38:48 -04:00
Stephen Kelly 31d7a0f2e3 Add platform variables for position independent code flags
Store in new platform variables

  CMAKE_${lang}_COMPILE_OPTIONS_PIC
  CMAKE_${lang}_COMPILE_OPTIONS_PIE

flags for position independent code generation.

In almost all cases, this means duplication of the
CMAKE_SHARED_LIBRARY_${lang}_FLAGS for the _PIC case and using the
assumed pie equivalent for the _PIE case.  Note that the GNU compiler
has supported -fPIE since 3.4 and that there is no -fPIC on GNU for
Windows or Cygwin.

There is a possibility that the _PIE variables are not correct.
However, as there is no backwards compatibility to be concerned about
(as the POSITION_INDEPENDENT_CODE property is not used anywhere yet),
the current state suffices.
2012-06-12 15:37:53 -04:00
Modestas Vainius e1409ac59b Support building shared libraries or modules without soname (#13155)
Add a boolean target property NO_SONAME which may be used to disable
soname for the specified shared library or module even if the platform
supports it.  This property should be useful for private shared
libraries or various plugins which live in private directories and have
not been designed to be found or loaded globally.

Replace references to <CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG> and
hard-coded -install_name flags with a conditional <SONAME_FLAG> which is
expanded to the value of the CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG
definition as long as soname supports is enabled for the target in
question.  Keep expanding CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG in
rules in case third party projects still use it.  Such projects would
not yet use NO_SONAME so the adjacent <TARGET_SONAME> will always be
expanded.  Make <TARGET_INSTALLNAME_DIR> NO_SONAME aware as well.  Since
-install_name is soname on OS X, this should not be a problem if this
variable is expanded only if soname is enabled.

The Ninja generator performs rule variable substitution only once
globally per rule to put its own placeholders.  Final substitution is
performed by ninja at build time.  Therefore we cannot conditionally
replace the soname placeholders on a per-target basis.  Rather than
omitting $SONAME from rules.ninja, simply do not write its contents for
targets which have NO_SONAME.  Since 3 variables are affected by
NO_SONAME ($SONAME, $SONAME_FLAG, $INSTALLNAME_DIR), set them only if
soname is enabled.
2012-04-30 11:50:27 -04:00
Brad King 749584509e Fix CXX/Fortran MODULE flags when enabled before C (#12929)
If CXX or Fortran is enabled before C then the values of

  CMAKE_SHARED_MODULE_C_FLAGS
  CMAKE_SHARED_MODULE_CREATE_C_FLAGS

may not be available.  On platforms where MODULE library (plugin) creation
is the same as SHARED library creation initialize the MODULE creation
flags from the SHARED creation flags of the matching language instead of
assuming that C has been enabled first.

Teach the COnly and CxxOnly tests to build MODULE libraries.  The latter
covers this specific case.
2012-02-03 15:45:13 -05:00
Brad King a603250a13 Load platform files that need to know the ABI when possible
Load platform files named in CMAKE_<lang>_ABI_FILES for each language
once the ABI sizeof(void*) is known.  During the first configuration
this is after the test for working compiler and ABI detection checks.
During later configurations the ABI information is immediately available
because it has been saved in CMake<lang>Compiler.cmake.
2011-12-05 16:35:42 -05:00
Brad King 7e6a004659 Merge topic 'relative-CMAKE_USER_MAKE_RULES_OVERRIDE'
a146e03 Fix relative CMAKE_USER_MAKE_RULES_OVERRIDE (#11725)
2011-01-26 15:24:05 -05:00
Brad King a146e03422 Fix relative CMAKE_USER_MAKE_RULES_OVERRIDE (#11725)
In commit 295b5b60 (Honor CMAKE_USER_MAKE_RULES_OVERRIDE in try_compile,
2010-06-29) we started passing the value of this variable when building
a try_compile project.  If the variable contains a relative path it must
be treated with respect to the file where it is first used.  Ensure that
the value is converted to a full path so that it is correctly referenced
in the try_compile projects.
2011-01-19 18:15:36 -05:00
Brad King c2d73c938a Allow platform files to set large archive rules (#11674)
Commit aaa88d33 (Build large archives incrementally, 2008-08-04)
hard-coded rules to create static archives incrementally in each
language information file.  Set each rule conditionally to allow
compiler and platform information files to override the language
default rules.

Inspired-by: Harald Pohl <pohl.h@eppendorf.de>
2011-01-10 09:58:55 -05:00
Brad King 20f49730ae Reset platform/compiler info status for each language
In each CMake<lang>Information.cmake file we use an _INCLUDED_FILE
variable to track whether a compiler information file has been loaded.
Reset this variable for each language.

This fixes Fortran under VS generators with the Intel plugin.
Previously the variable would be left set true from C and C++ and then
Fortran would not load old-style files like Platform/Windows-ifort.
2010-09-28 09:49:20 -04:00
Todd Gamblin 2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Brad King 4d72006bd6 Reduce duplication in Platform/<os>.cmake files
Several platform-wide linker flag variables are defined in
Modules/Platform/<os>.cmake files for C and then copied by the
Modules/CMake<lang>Information.cmake file for each language.
We now use this approach for the variables

  CMAKE_EXE_EXPORTS_${lang}_FLAG
  CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG
  CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS

to avoid duplication for multiple languages in each platform file.
2009-12-02 15:17:53 -05:00
Brad King 9daa4a6c3f Remove CMAKE_SHARED_MODULE_RUNTIME_${lang}_FLAG
This platform configuration variable is unused.  Modules are built using
the value of CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG.
2009-12-02 15:17:32 -05:00
Brad King d0c03f804f Use work-around from bug 4772 for C++ and Fortran
The commit "fix for bug 4772" added a work-around to CMakeCInformation
for platform config files that put compiler information in the system
file (like SunOS flags for GCC).  This commit adds the same work-around
for CXX and Fortran.  It is necessary to support enabling these
languages separately from C in other subdirectories.

The commit "Avoid (Unix|Windows)Paths.cmake multiple include" added
include blockers that prevent the files from multiple inclusion, so it
is safe to include the system information files from every language.

See issue #4772 and issue #9656.
2009-10-06 11:06:38 -04: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 797e49a1cc ENH: Load platform-independent per-compiler files
This teaches the language configuration modules to load per-compiler
information for each language using the compiler id but no system name.
They look for modules named "Compiler/<id>-<lang>.cmake".  Such modules
may specify compiler flags that do not depend on the platform.
2009-07-23 10:06:31 -04:00
Bill Hoffman 9d9582ffef ENH: fix problem where rc language recursively included itself because CMAKE_BASE_NAME was used from c compiler, do the same fix for other uses of CMAKE_BASE_NAME 2008-10-14 16:07:11 -04:00
Brad King aaa88d33a9 ENH: Build large archives incrementally
Creation of archive libraries with the unix 'ar' tool should be done
incrementally when the number of object files is large.  This avoids
problems with the command line getting too many arguments.
2008-08-04 11:37:19 -04:00
Bill Hoffman aa10b4e33c ENH: fix init flags getting stuffed into the compile line by force. 2008-04-21 13:04:15 -04:00
Brad King 82fcaebe28 ENH: Pass dependent library search path to linker on some platforms.
- Move runtime path ordering out of cmComputeLinkInformation
    into its own class cmOrderRuntimeDirectories.
  - Create an instance of cmOrderRuntimeDirectories for runtime
    path ordering and another instance for dependent library
    path ordering.
  - Replace CMAKE_DEPENDENT_SHARED_LIBRARY_MODE with explicit
    CMAKE_LINK_DEPENDENT_LIBRARY_FILES boolean.
  - Create CMAKE_LINK_DEPENDENT_LIBRARY_DIRS boolean.
  - Create variables to specify -rpath-link flags:
      CMAKE_SHARED_LIBRARY_RPATH_LINK_<LANG>_FLAG
      CMAKE_EXECUTABLE_RPATH_LINK_<LANG>_FLAG
  - Enable -rpath-link flag on Linux and QNX.
  - Documentation and error message updates
2008-02-01 08:56:00 -05:00
Brad King 4d4c0c8466 BUG: CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG should get its default value from CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG, not CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG. 2008-01-23 16:35:25 -05:00
Brad King 96fd5909d9 ENH: Implement linking with paths to library files instead of -L and -l separation. See bug #3832
- This is purely an implementation improvement.  No interface has changed.
  - Create cmComputeLinkInformation class
  - Move and re-implement logic from:
      cmLocalGenerator::ComputeLinkInformation
      cmOrderLinkDirectories
  - Link libraries to targets with their full path (if it is known)
  - Dirs specified with link_directories command still added with -L
  - Make link type specific to library names without paths
    (name libfoo.a without path becomes -Wl,-Bstatic -lfoo)
  - Make directory ordering specific to a runtime path computation feature
    (look for conflicting SONAMEs instead of library names)
  - Implement proper rpath support on HP-UX and AIX.
2008-01-22 09:13:04 -05:00
Brad King 8262ccfd4e 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
Bill Hoffman 9eb207aa89 BUG: fix for bug 6167 get rid of extra space in flags 2007-12-17 12:04:15 -05:00
Alexander Neundorf 930bb0cd37 ENH: remove support for presetting CMAKE_SYSTEM_INFO_FILE,
CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE, CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE,
CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE and CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE

Instead of presetting these variables to arbitrary filenames, users should
set up CMAKE_SYSTEM_NAME and the compilers correctly and also create a
Platform/ directory so these files will all follow the official cmake style,
which should make it easier to understand and debug project which have their
own platform/toolchain support files.

-remove support for a suffix to MS crosscompilers, since this is not (yet)
supported by cmake and might confuse users

Alex
2007-07-02 13:29:36 -04:00
Alexander Neundorf df1edcb9d3 ENH: first include the processor specific file, then the compiler file, this
way the specific hardware file can set variables which can be used in the
toolchain rules (like CMAKE_C_COMPILE_OBJECT etc.)

Alex
2007-06-12 16:41:50 -04:00
Alexander Neundorf 422dc631b6 ENH: split cmGlobalGenerator::SetLanguageEnabled() in two parts, where the
second part copies the values from the cmake variables into internal maps.
So this can now be done after the compiler-specific information has been
loaded, which can now overwrite more settings.

Alex
2007-06-11 15:31:42 -04:00
Alexander Neundorf eab5a4350d ENH: also load a processor-specific file if exists
-also try the basename file if the compiler id file doesn't exist
-don't rely so much on the CMAKE_TOOLCHAIN_FILE

Alex
2007-06-05 10:28:43 -04:00
Alexander Neundorf 61d3444f93 ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions

Alex
2007-05-17 13:20:44 -04:00
Brad King 44ab336a0c ENH: Merging CompilerId updates from branch CMake-Modules-CompilerId to the main tree. Changes between CMake-Modules-CompilerId-mp1 and CMake-Modules-CompilerId-mp2 are included. 2007-05-03 08:24:32 -04:00
Brad King 1d0502927c ENH: Adding support to link specifically to an archive or a shared library based on the file name specified. This fixes the problem of having -lfoo linking to libfoo.so even when it came from libfoo.a being specified. 2006-09-15 14:09:10 -04:00
Brad King 08289893b8 ENH: Split CMAKE_STANDARD_LIBRARIES into per-language variables CMAKE_<lang>_STANDARD_LIBRARIES. This is needed to get programmable language support working with Visual Studio generators. It makes sense anyway. 2006-04-11 16:55:49 -04:00
Bill Hoffman 3f532f5489 ENH: add support for language flags at rule expansion time 2006-03-06 15:14:23 -05:00
Bill Hoffman 2f78d874a7 ENH: fix for bug 2921, move _OVERRIDE variable to a better position to allow changing _INIT variables 2006-03-02 07:52:52 -05:00
Bill Hoffman 718de4cea5 ENH: fix spelling errors 2006-02-27 12:14:10 -05:00