Commit Graph

125 Commits

Author SHA1 Message Date
Bill Hoffman 96242f8022 Add options to run `ldd -u -r` as a "link-what-you-use" tool
Create a LINK_WHAT_YOU_USE target property and corresponding
CMAKE_LINK_WHAT_YOU_USE variable to enable this behavior.
Extend link commands by running `ldd -u -r` to detect shared
libraries that are linked but not needed.
2016-06-17 10:56:40 -04:00
Daniel Pfeifer 1b2bb93302 Remove redundant c_str() calls.
Run clang-tidy's readability-redundant-string-cstr checker.
Ignore findings in kwsys.
2016-05-26 22:52:22 +02:00
Daniel Pfeifer 25d1ef6424 Use enums defined in cmOutputConverter using their fully qualified name.
Mostly automated:

values=("RelativeRoot" "NONE" "FULL" "HOME" "START" "HOME_OUTPUT" "START_OUTPUT"
        "OutputFormat" "UNCHANGED" "MAKERULE" "SHELL" "WATCOMQUOTE" "RESPONSE"
        "FortranFormat" "FortranFormatNone" "FortranFormatFixed" "FortranFormatFree")
for i in "${values[@]}"; do git grep -l cmLocalGenerator::$i | xargs sed -i "s|cmLocalGenerator::$i|cmOutputConverter::$i|g"; done
2016-05-25 09:20:09 -04:00
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Stephen Kelly 3f8aa62bfb cmGeneratorTarget: Add API for target-relative commands. 2015-10-26 22:02:13 +01:00
Stephen Kelly 4bc65d76f1 Makefiles: Port to cmGeneratorTarget. 2015-10-24 09:19:53 +02:00
Stephen Kelly 83703bda7d cmGeneratorTarget: Copy IsExecutableWithExports from cmTarget. 2015-10-21 00:36:09 +02:00
Stephen Kelly 88d10d55ac cmGeneratorTarget: Copy IsAppBundleOnApple from cmTarget.
Leave the cmTarget method behind for now to implement cmInstallCommand.
2015-10-19 20:27:41 +02:00
Stephen Kelly 3e8ef64273 cmLocalGenerator: Port some API to cmGeneratorTarget. 2015-10-17 17:30:38 +02:00
Stephen Kelly cfb2f7508a Use cmGeneratorTarget for property access. 2015-10-17 17:30:38 +02:00
Stephen Kelly b857f0d84b Use GetName from cmGeneratorTarget. 2015-10-17 17:30:37 +02:00
Stephen Kelly 12e4790a0b cmGeneratorTarget: Move GetTargetVersion from cmTarget. 2015-10-16 20:24:44 +02:00
Stephen Kelly ce75c86ec3 cmGeneratorTarget: Move GetSupportDirectory from cmTarget. 2015-10-12 18:39:59 +02:00
Stephen Kelly 8d2e3e53b9 cmGeneratorTarget: Move HasImplibGNUtoMS from cmTarget. 2015-10-12 18:39:59 +02:00
Stephen Kelly 50dc9b4440 cmGeneratorTarget: Move GetPDBDirectory from cmTarget. 2015-10-09 01:04:37 +02:00
Stephen Kelly 8b0168863e cmGeneratorTarget: Move GetDirectory from cmTarget. 2015-10-09 01:04:37 +02:00
Brad King e134e53b47 Add support for *.manifest source files with MSVC tools
Classify .manifest sources separately, add dependencies on them, and
pass them to the MS manifest tool to merge with linker-generated
manifest files.

Inspired-by: Gilles Khouzam <gillesk@microsoft.com>
2015-09-17 10:21:32 -04:00
Stephen Kelly b3f0e35308 cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. 2015-08-05 18:20:50 +02:00
Stephen Kelly 7c809fa2a6 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 2015-08-05 18:20:48 +02:00
Stephen Kelly 8d2de00244 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. 2015-08-05 18:20:47 +02:00
Stephen Kelly 47803e6f8e cmGeneratorTarget: Move GetExecutableNames from cmTarget. 2015-08-05 18:20:46 +02:00
Stephen Kelly 5aa556be56 cmMakefileTargetGenerator: Require cmGeneratorTarget. 2015-06-22 13:23:45 -04:00
Stephen Kelly 32b8f03acc cmMakefile: Port users of GetStart* methods to new names. 2015-04-21 00:15:20 +02:00
Brad King 7bb50e4a31 Makefile: Add progress to link step messages 2015-02-06 19:07:24 -05:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Jiri Malak cb9b1e13e4 Watcom: Use single quote for all file/path items in wlink command
Watcom Linker use single quote if necessary for quoting target name,
libraries names and libraries search path.  Object names were already
fixed.
2014-04-08 13:28:54 -04:00
Jiri Malak 423009c17f Makefile: Generate single-quoted object lists for Watcom
Drop the CMAKE_NO_QUOTED_OBJECTS internal variable from the Makefile
generators.  The underlying problem is with the Watcom linker, not with
WMake.  The Watcom linker wants object files to be single-quoted.  Add
<LINK-RULE>_USE_WATCOM_QUOTE platform information variables to tell the
generators to use Watcom-style single quotes for object files on link
lines.

On Windows, Watcom uses the GetCommandLine API to get the original
command-line string and do custom parsing that expects single quotes.
On POSIX systems, Watcom approximates the original command line by
joining all argv[] entries separated by a single space.  Therefore we
need to double-quote the single-quoted arguments so that the shell does
not consume them and they are available for the parser to see.
2014-03-27 13:45:29 -04:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel fabf1fbabb stringapi: Use strings in target name 2014-03-08 13:05:31 -05:00
Ben Boeckel ce5114354c stringapi: Use strings for the languages 2014-03-08 13:05:30 -05:00
Brad King 489b1c23b9 Windows: Use response files to specify link libraries for GNU tools
Work around the command-line-length limit by using an @linklibs.rsp
response file to pass the flags for link libraries.  This allows
very long lists of libraries to be used in addition to the existing
support for passing object files via response file.

Suggested-by: Peter Keuschnigg <peter.keuschnigg@pmu.ac.at>
2014-03-05 13:07:41 -05:00
Brad King 745caae6dd Makefile: Rename linker response file boolean to be more specific
Rename local variable useResponseFile to useResponseFileForObjects
when it represents CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS.
2014-03-05 08:54:14 -05:00
Brad King c87517099a Makefile: Factor out some duplicate link libraries generation
The generators for executable and library targets duplicate the logic to
call the OutputLinkLibraries helper on the local generator.  Factor it
out into a cmMakefileTargetGenerator::CreateLinkLibs method to avoid
dpulication.
2014-03-04 11:20:27 -05:00
Brad King fba51b096e MSVC: Add properties to configure compiler PDB files (#14762)
Since commit v2.8.12~437^2~2 (VS: Separate compiler and linker PDB files
2013-04-05) we no longer set /Fd with the PDB_NAME or PDB_OUTPUT_DIRECTORY
properties.  Those properties now exclusively handle linker PDB files.
Since STATIC libraries do not link their compiler PDB file becomes more
important.  Add new target properties "COMPILE_PDB_NAME[_<CONFIG>]" and
"COMPILE_PDB_OUTPUT_DIRECTORY[_<CONFIG>]" to specify the compiler PDB
file location and pass the value to the MSVC /Fd option.
2014-02-26 09:34:38 -05:00
Brad King b4aac0caca Makefile: Fix per-config linker PDB output directory
Also, now that all call sites of cmTarget::GetPDBName and
cmTarget::GetPDBDirectory pass the configuration, make the
argument non-optional.
2014-02-24 13:44:24 -05:00
Brad King 7a63192074 Merge topic 'fix-compile-OBJECT_DIR'
03f3b4e Replace <OBJECT_DIR> rule placeholder consistently (#14667)
2014-01-02 14:23:52 -05:00
Brad King 03f3b4e727 Replace <OBJECT_DIR> rule placeholder consistently (#14667)
The <OBJECT_DIR> placeholder is supposed to be the base intermediate
files directory for the current target.  This is how it gets replaced
during link line generation.  However, during compile line generation
we replace it with the directory containing the current object file
which may be a subdirectory.  Fix replacement of <OBJECT_DIR> in the
generated compile lines to be the base intermediate files directory.

This was expoxed by commit 42ba1b08 (VS: Separate compiler and linker
PDB files, 2013-04-05) when we added a "/Fd<OBJECT_DIR>/" flag to the
MSVC compile line in order to match the VS IDE default compiler program
database location in the intermediate files directory.  For source files
in a subdirectory relative to the current target this caused the wrong
location to be used for the compiler program database.  This becomes
particularly important when using precompiled headers.

While at it, use the cmTarget::GetSupportDirectory method to compute the
intermediate files directory for the current target instead of repeating
the logic in a few places.
2014-01-02 13:45:41 -05:00
Stephen Kelly c34968a9aa Port some of the generator API to cmGeneratorTarget.
Just enough to reach the BuildMacContentDirectory method and the
NeedRelinkBeforeInstall methods.

In the future, those methods can be moved to cmGeneratorTarget.
2013-11-22 15:06:25 +01:00
Stephen Kelly 0416c94f64 Revert "Use --sysroot when cross compiling."
This reverts commit de4da665d3.

This feature is not yet ready for release. It needs to be
merged with the CMAKE_OSX_SYSROOT feature.
2013-07-12 15:44:38 +02:00
Stephen Kelly de4da665d3 Use --sysroot when cross compiling.
As CMAKE_ROOT_FIND_PATH can be a list, a new CMAKE_SYSROOT is
introduced, which is never a list.

The contents of this variable is passed to supporting compilers
as --sysroot. It is also accounted for when processing implicit
link directories reported by the compiler, and when generating
RPATH information.
2013-06-07 13:32:52 +02:00
Clinton Stimpson 373faae5e1 Refactor how bundles and frameworks are supported.
Make handling of directory separators consistent between
non-bundle and bundle code.

Remove xcode specific flag from cmTarget when getting install_name.

Add (more) consistent convenience functions in cmTarget to get
directories inside of bundles and frameworks to add files to.

This refactor also fixes bug #12263 where frameworks
had the wrong install name when SKIP_BUILD_RPATH.

Also make install_name for frameworks consistent between Makefile
and Xcode generator.
2013-05-23 10:42:49 -04:00
Brad King 47e50423bf Merge topic 'ninja-LIBPATH'
1e47ccb Ninja: add option to enforce usage of response files
e31df03 Ninja: move <OBJECTS> in front of the first linker option
8d674e7 Ninja: move -LIBPATH behind -link option
2012-10-02 10:07:32 -04:00
Peter Kümmel 8d674e7844 Ninja: move -LIBPATH behind -link option
Don' pass linker option to the compile
2012-10-01 17:06:38 -04:00
Brad King 7dce31f3d0 Merge topic 'vs-pdb-output'
2ccca05 Run PDBDirectoryAndName test on MSVC and Intel
efc83b3 Document that PDB_(NAME|OUTPUT_DIRECTORY) are ignored for VS 6
b294457 Verify that PDB_(NAME|OUTPUT_DIRECTORY) are honored in test
3f60dbf Add PDB_OUTPUT_DIRECTORY and PDB_NAME target properties (#10830)
2012-10-01 14:05:11 -04:00
Yuchen Deng 3f60dbf148 Add PDB_OUTPUT_DIRECTORY and PDB_NAME target properties (#10830)
This enables changing the name and output folder of the debug symbol
files produced by MS compilers.

Inspired-by: Thomas Bernard <thomas.bernard@ipetronik.com>
2012-09-25 15:23:35 -04:00
Stephen Kelly f9146f6b90 Port cmLocalGenerator::GetTargetFlags to cmGeneratorTarget. 2012-09-19 15:31:39 +02:00
Stephen Kelly 78bfee35d5 Make cmLocalGenerator::AddArchitectureFlags take a cmGeneratorTarget. 2012-09-19 15:31:29 +02:00
Nicolas Despres 5d885db416 Re-factor bundle content copying rules generation. 2012-07-17 14:03:10 +02:00
Nicolas Despres a1b803349b Re-factor OS X bundle and framework generation. 2012-07-17 14:03:07 +02:00