Commit Graph

255 Commits

Author SHA1 Message Date
Clinton Stimpson 0ddfc51f6a Add -DNDEBUG to RelWithDebInfo flags where where Release flags had it.
Previously, it was inconsistent in that some platforms/compilers
had this flag for the RelWithDebInfo configuration and some didn't.
This fixes issue #11366.
2012-08-15 20:00:45 -06:00
Brad King 7e8471ce7b Recognize Clang ASM support (#13473)
Since commit 571dc748 (Recognize Clang C and C++ compilers, 2010-05-17)
we recognize Clang C and C++ support.  Add Compiler/Clang-ASM.cmake to
enable use of Clang for ASM too.  Also teach Assembler test to try Clang
as an assembler.

Suggested-by: Tobias Pape <tobiaspape@gmail.com>
2012-08-15 09:40:20 -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
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
Peter Collingbourne 6b5614f164 Ninja: Substitute <OBJECT> and <CMAKE_C_COMPILER> in depfile flags
Patch by Amine Khaldi!

Also, start using the -MT flag to set a target name for depfiles.
This works around a bug observed in distcc, as explained in the
comment.  Based on a patch by Alexander Usov.
2012-03-26 04:46:12 +01:00
Peter Collingbourne 7eb8d9036c Provide dependency file flags to generator
Causes compiler modules (currently only GNU) to set a
CMAKE_DEPFILE_FLAGS_${lang} variable, which communicates to
the generator the flags required to cause the compiler to create
dependency files.
2012-02-02 23:36:49 +00:00
Mathieu Malaterre 0efe602c59 TinyCC: Add default compilation flags (#12605) 2011-12-05 08:59:50 -05:00
Brad King ec636e299f TinyCC: Add compiler info for shared libs on Linux (#12605)
Use the "-shared" option to link shared libraries.  The compiler does
not support "-Wl," or "-rpath" but does know how to pass "-soname"
through to the linker.
2011-12-02 10:23:48 -05:00
David Cole d9ad72542a Merge topic 'fortran-format'
90efed6 Xcode: Honor Fortran_FORMAT target and source file property
5c0c635 Fortran: Add support for free- and fixed-form flags
47a0c75 VS: Map Fortran free- and fixed-format flags to IDE options
d6e2a06 VS: Map per-source Fortran flags to IDE options
2011-09-07 15:37:27 -04:00
Brad King 5c0c635a09 Fortran: Add support for free- and fixed-form flags
Define a "Fortran_FORMAT" target and source file property.  Initialize
the target property from a "CMAKE_Fortran_FORMAT" variable.  Interpret
values "FIXED" and "FREE" to indicate the source file format.  Append
corresponding flags to the compiler command line.
2011-08-31 10:24:43 -04:00
Todd Gamblin d1697625f8 Fix XL compilers on non-AIX machines.
Linking broken on non-AIX machines when using XL compilers due to those
machines not using the CreateExportList tool.  Made use of this tool
conditional on finding it.
2011-08-28 22:04:41 -07:00
Brad King 33f5a83a5d GNU: Fix CMAKE_INCLUDE_SYSTEM_FLAG_<lang> value (#12258)
Fix typo introduced by commit e28c16b4 (Split GNU compiler information
files, 2009-12-02).

Reported-by: Campbell Barton <ideasman42@gmail.com>
Suggested-by: Michael Hertling <mhertling@online.de>
2011-06-13 17:54:36 -04:00
Brad King 3bb8566868 XL: Place Fortran modules with -qmoddir= flag (#12246)
Suggested-by: Luis Kornblueh <luis.kornblueh@zmaw.de>
2011-06-01 12:00:48 -04:00
Brad King 1605784f47 Merge topic 'absoft-fortran-compiler'
8bd3e51 Absoft: Enable FortranCInterface check in Fortran test
d7b376b Absoft: Detect implicit link libraries on Linux and Mac
ac5b999 Add Absoft Fortran compiler id and basic flags
2011-05-24 14:34:40 -04:00
Brad King ac5b999fff Add Absoft Fortran compiler id and basic flags
Identification at preprocessing time depends on definition of __ABSOFT__
to be added in service pack V11.1.2 of the compiler.
2011-05-20 08:53:36 -04:00
Brad King d468a2c2cb XL: Avoid copying archives into shared libraries that link them
The XL toolchain supports shared object files stored in archives.  Since
CMake lists libraries on link lines by full path it is common for a
shared library link line to contain the path to an archive file.

When linking a shared library the compiler front-end by default runs
CreateExportList to construct the list of symbols to be exported.
Unfortunately it passes all files found on the command line to the tool
so archive and library files get processed along with the object files.
The tool returns a list of all symbols in all objects, archives, and
libraries on the command line.  This causes the linker to copy every
object file out of every archive into the shared library whether they
are dependencies of the original object files or not.

Work around this problem by running CreateExportList ourselves with just
the original object files intended for inclusion in the shared library.
Then pass the list it produces on the link line to prevent the compiler
front-end from constructing its own.  This tells the linker to export
only the symbols provided by the original source files of the shared
library.
2011-04-08 08:41:36 -04:00
Brad King 2f3eee7490 XL: Consolidate compiler flag information
Factor duplicate information out of Compiler/XL-<lang>.cmake modules
into a macro in a new Compiler/XL.cmake module.  Invoke it from the
per-language files to produce the original settings.
2011-04-07 17:09:05 -04:00
Brad King 3a40c7faa4 XL: Set C++ and Fortran flags consistently with C
Since commit e1729238 (Add initial XL C compiler flags for safer builds,
2009-09-30) CMake sets the initial XL C flags to include "-qthreaded"
and "-qhalt=e".  Do the same for C++ and Fortran with this toolchain.
2011-04-07 17:07:23 -04:00
Alex Neundorf 17c658f819 Add support for the Intel compiler used for ASM under Windows
Alex
2011-03-02 16:46:25 +01:00
Alex Neundorf 66614a868d Add assemble- and preprocess commands for HP
Also restore HP-C.cmake, I had accidentially overwritten it with HP-ASM.cmake

Alex
2011-02-23 21:30:21 +01:00
Alex Neundorf 78f7c592eb Fix the default CMAKE_ASM_COMPILE_OBJECT, make XL-ASM use it
Alex
2011-02-23 21:29:05 +01:00
Alex Neundorf 7456461588 Change the default rules so they fit better to the new ASM handling
CMAKE_ASM_COMPILE_OBJECT is now so that it fits for GNU, Intel, HP and Sun
ASM_ATT had to be adjusted. Also adjusted the default
CMAKE_ASM_LINK_EXECUTABLE

Alex
2011-02-23 21:21:41 +01:00
Alex Neundorf 5542d58014 Set the HP asm file suffix
Alex
2011-02-23 21:18:55 +01:00
Alex Neundorf f745220a32 Add support for ASm for the HP compiler.
Alex
2011-02-23 21:16:44 +01:00
Alex Neundorf 00735d4055 Add suport for ASM for the IBM XL compiler
Alex
2011-02-23 21:16:22 +01:00
Alex Neundorf d3e9e8a078 Add support for ASM for the SunPro compiler
Alex
2011-02-23 21:16:00 +01:00
Alex Neundorf 64e66ebdc8 Actually use CMAKE_ASM_COMPILER for asm, instead of CMAKE_C_COMPILER
Alex
2011-02-23 21:15:41 +01:00
Alex Neundorf 38f92bfbe1 Add ASM support for the Intel compiler
Alex
2011-02-23 21:15:18 +01:00
Alex Neundorf 4b40d4297a Rework the way assembler is handled, use the C/CXX compiler by default
This commit changes the way how the assembler support works in cmake.
The language "ASM" now always uses the C/Cxx compiler instead
of the assembler directly. This fixes #8392, assembler files are
not preprocessed.
If one wants to use the assembler directly, the specific
assembler "dialect" has to be enabled. I.e. to get as/gas,
you have to use now ASM-ATT, the same way for ASM_MASM and ASM_NASM.

Implemented this now for gcc.
SunStudio, IBM, HP and Intel still todo.

Alex
2011-01-30 21:03:37 +01:00
Brad King e60c8ec6c7 Factor SCO compiler info out of platform file (#11700)
Move these flags out of the SCO_SV platform file so that other compilers
may be used on that platform without interference.
2011-01-17 09:57:17 -05:00
Brad King 72163de0a5 Merge topic 'NAG-Fortran'
09d1c10 FortranCInterface: Recognize NAG Fortran module symbols
af2ad90 Add NAG Fortran compiler information files
24cc3d4 Recognize the NAG Fortran compiler
83892c4 Allow Fortran platform files to set empty values
fe3f878 Detect object files in implicit link information
2010-12-16 13:59:52 -05:00
Brad King af2ad90991 Add NAG Fortran compiler information files
On Linux the NAG Fortran compiler uses gcc under the hood to link.  Use
"-Wl,-v" to pass "-v" to the underlying gcc compiler to get verbose link
output.  Detect the NAG Fortran directory (using -dryrun) and then honor
object files in the directory referenced in the implicit link line.
Pass real linker options with "-Wl,-Xlinker,".  The -Wl, gets through
the NAG front-end and the -Xlinker gets through the gcc front-end.
2010-12-09 18:12:34 -05:00
Brad King 53e76c8f12 Teach CMake about Cray C, C++, and Fortran compilers
The Cray Fortran compiler needs "-em" to enable module output and also
"-J." to place the .mod files in the current working directory (instead
of next to the .o file).
2010-11-12 09:12:08 -05:00
Todd Gamblin 2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Brad King 571dc74891 Recognize Clang C and C++ compilers (see #10693)
Map to the platform and compiler information for GNU because the
compilers are command-line compatible for common operations.  Later we
can add Clang-specific features as necessary.  We honor the preferred
capitalization is "Clang", not the common mis-spelling "CLang".
2010-05-17 14:11:20 -04:00
Kovarththanan Rajaratnam db3134d2a1 Make VERBOSE_FLAG appear as first statement for consistency 2010-04-17 07:49:21 +02:00
Brad King da36cde059 PathScale C/C++/Fortran Compiler Information
We add compiler information files

  Compiler/PathScale-<lang>.cmake

to specify PathScale compiler information for C, C++, and Fortran
languages.  We use a macro in Compiler/PathScale.cmake to consolidate
the information common to all languages.
2010-01-13 12:14:31 -05:00
Brad King c106cb2e2f Generalize support for Portland Group Compiler
We factor flags from Platform/Linux-PGI-Fortran.cmake into language
independent helper modules

  Compiler/PGI.cmake
  Platform/Linux-PGI.cmake

and invoke the macros from

  Compiler/PGI-<lang>.cmake
  Platform/Linux-PGI-<lang>.cmake

This enables general support for the PGI compilers.
2009-12-04 10:21:57 -05:00
Brad King e28c16b482 Split GNU compiler information files
This moves GNU compiler flags into new-style modules

  Compiler/GNU-<lang>.cmake
  Platform/<os>-GNU-<lang>.cmake

We use language-independent helper modules

  Compiler/GNU.cmake
  Platform/<os>-GNU.cmake

to define macros consolidating the information.
2009-12-02 09:52:00 -05:00
Brad King 1f06c33f8e Drop -rdynamic from Linux build rules
This is a GNU-specific option that should not be specified for all
compilers on Linux.  It tells the GNU compiler to pass -export-dynamic
to the linker to export symbols from executables for use by plugins.
Since we provide the ENABLE_EXPORTS target property to do the same thing
in a cross-platform way, there is no need to pass -rdynamic always.

Since the option is not useful for GNU tools and breaks other tools on
Linux we simply remove it from CMAKE_SHARED_LIBRARY_LINK_<lang>_FLAGS.
This also allows us to stop setting the variable in other Linux compiler
files just to erase the bad flag.

See issue #9985.
2009-12-01 14:25:21 -05:00
Brad King 83816cc6ec Add support for the g95 Fortran compiler
This commit teaches CMake about the g95 compiler from

  http://www.g95.org

We use 'G95' as the compiler id string, and add some basic flags.

See issue #9241.
2009-10-23 08:25:43 -04:00
Brad King e1729238c9 Add initial XL C compiler flags for safer builds
This commit adds some default initial C flags for the XL compiler.  The
most important is "-qhalt=e" which causes the compiler to error-out on
non-severe error messages.  This is necessary to get try-compiles to
fail when bad arguments are passed to a function.
2009-09-30 09:38:23 -04:00
Brad King 6d434ee6cc Split XL compiler information files
This moves platform-independent XL compiler flags into separate
"Compiler/XL-<lang>.cmake" modules.  Platform-specific flags go in
"Platform/<os>-XL-<lang>.cmake" modules.
2009-09-30 09:37:35 -04:00
Alexander Neundorf 196d9a54aa The preprocessing and assembly rules also need the <DEFINES>, otherwise different reults are created.
Alex
2009-09-19 04:33:10 -04:00
Brad King 2eca4dd2d1 Use Intel for Linux flags only on Linux
The commit "Split Intel compiler information files" moved some Linux
specific flags into the platform-independent Intel compiler info files.
This moves them back.
2009-09-01 13:55:13 -04:00
Brad King 9ee0f9801a Split SunPro compiler information files
This moves platform-independent SunPro compiler flags into separate
"Compiler/SunPro-<lang>.cmake" modules.  Platform-specific flags are
left untouched.
2009-08-21 10:32:26 -04:00
Brad King 2ce6a7d0fb Split Intel compiler information files
This moves platform-independent Intel compiler flags into separate
"Compiler/Intel-<lang>.cmake" modules.  Platform-specific flags are
left untouched.
2009-08-21 09:54:42 -04:00
Brad King 115ecc5750 Teach compiler id about VisualAge -> XL rebranding
IBM rebranded its VisualAge compiler to XL starting at version 8.0.  We
use the compiler id "XL" for newer versions and "VisualAge" for older
versions.  We now also recognize the "z/OS" compiler, which is distinct
from XL.
2009-08-07 10:13:07 -04:00
Brad King 34c6588b6e Move flag to Compiler/VisualAge-Fortran module
The CMAKE_Fortran_DEFINE_FLAG value applies to the IBM Fortran compilers
on all platforms.  This moves the setting to the platform-independent
compiler information file.
2009-08-07 10:12:34 -04:00
Brad King 35f36727c5 Set CMAKE_<LANG>_VERBOSE_FLAG variables for PGI
We set the variables to contain "-v", the verbose front-end output
option for PGI compilers.  This enables detection of implicit link
libraries and directories for these compilers.
2009-07-29 16:38:06 -04:00
Brad King 0ea43ee128 Set CMAKE_<LANG>_VERBOSE_FLAG variables for Intel
We set the variables to contain "-v", the verbose front-end output
option for Intel compilers.  This enables detection of implicit link
libraries and directories for these compilers.
2009-07-29 16:07:27 -04:00
Brad King 07ea19ad1f ENH: Implicit link info for C, CXX, and Fortran
This teaches CMake to detect implicit link information for C, C++, and
Fortran compilers.  We detect the implicit linker search directories and
implicit linker options for UNIX-like environments using verbose output
from compiler front-ends.  We store results in new variables called

  CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES
  CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES

The implicit libraries can contain linker flags as well as library
names.
2009-07-23 10:07:25 -04:00