Commit Graph

160 Commits

Author SHA1 Message Date
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 d8f8940bc6 cmGeneratorTarget: Move IsCFBundleOnApple from cmTarget. 2015-10-19 20:27:41 +02:00
Stephen Kelly b5f5de70c0 cmGeneratorTarget: Copy IsFrameworkOnApple 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
Brad King f13521317a Merge topic 'clean-up-cmTarget'
55474e61 cmState: Move GetTargetTypeName from cmTarget.
38df5c36 Remove now-obsolete casts.
4ee2b267 cmGeneratorTarget: Use enum for GetType.
eac15298 cmState: Move TargetType enum from cmTarget.
482b3811 cmTarget: Move link type enum out.
2ee1cb85 cmTarget: Move ImportInfoMap out of internal class.
a48bcabd cmTarget: Move backtrace member out of internal class.
6694d993 cmTarget: Remove unneeded constructors.
983c00f8 Generators: Use GetType from the cmGeneratorTarget.
2015-10-16 09:35:34 -04:00
Stephen Kelly eac15298a8 cmState: Move TargetType enum from cmTarget.
Mostly automated:

 values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType")
 for i in "${values[@]}"; do     git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
2015-10-15 00:41:39 +02:00
Stephen Kelly 983c00f8f9 Generators: Use GetType from the cmGeneratorTarget. 2015-10-15 00:41:19 +02:00
Stephen Kelly 06f56d3bf5 cmLocalUnixMakefileGenerator3: Port AppendCleanCommand to cmGeneratorTarget. 2015-10-15 00:23:53 +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 d560bfd273 cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. 2015-08-05 18:20:47 +02:00
Stephen Kelly 8d2de00244 cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. 2015-08-05 18:20:47 +02:00
Stephen Kelly f0aa660772 cmGeneratorTarget: Move HasSOName from cmTarget. 2015-08-05 18:20:46 +02:00
Stephen Kelly 766839c56d cmGeneratorTarget: Move GetLibraryNames from cmTarget. 2015-08-05 18:20:46 +02:00
Bill Hoffman 8f86407cfd Windows: Optionally generate DLL module definition files automatically
Create target property WINDOWS_EXPORT_ALL_SYMBOLS to automatically
generate a module definition file from MS-compatible .obj files and give
it to the linker in order to export all symbols from the .dll part of a
SHARED library.
2015-07-06 11:11:02 -04:00
Stephen Kelly 5aa556be56 cmMakefileTargetGenerator: Require cmGeneratorTarget. 2015-06-22 13:23:45 -04:00
Stephen Kelly e54d2fdf50 Convert: Remove specification of default parameter. 2015-05-20 11:21:10 -04:00
Stephen Kelly 32b8f03acc cmMakefile: Port users of GetStart* methods to new names. 2015-04-21 00:15:20 +02:00
Brad King 387466dd95 Merge topic 'custom-command-multiple-outputs'
66a9c90c Makefile: Fix multiple custom command outputs regression (#15116)
2015-03-09 09:45:51 -04:00
Brad King 66a9c90c4b Makefile: Fix multiple custom command outputs regression (#15116)
In commit v3.2.0-rc1~272^2~2 (Makefile: Fix rebuild with multiple custom
command outputs, 2014-12-05) we changed the generated makefile pattern
for multiple outputs from

  out1: depends...
          commands...
  out2: out1

to

  out1 out2: depends...
          commands...

This was based on the incorrect assumption that make tools would treat
this as a combined output rule and run the command(s) exactly once for
them.  It turns out that instead this new pattern is equivalent to

  out1: depends...
          commands...
  out2: depends...
          commands...

so the commands may be run more than once.

Some documents suggest using a "dedicated witness" stamp file:

  stamp: depends...
          rm -f stamp
          touch stamp.tmp
          commands...
          mv stamp.tmp stamp
  out1 out2: stamp

However, if the commands fail the error message will refer to the stamp
instead of any of the real outputs, which may be confusing to readers.
Also, this approach seems to have the same behavior of the original
approach that motiviated the above commit: multiple invocations are
needed to bring consumers of the outputs up to date.

Instead we can return to the original approach but add an explicit
touch to each extra output rule:

  out1: depends...
          commands...
  out2: out1
          touch -c out2

This causes make tools to recognize that all outputs have changed and
therefore to execute any commands that consume them.
2015-03-06 19:58:30 -05: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
Brad King 644b4688d7 Makefile: Fix rebuild with multiple custom command outputs (#15116)
Fix the generated makefiles for custom commands with multiple outputs to
list all the outputs on the left hand side of the build rule.  This is
much simpler and more reliable than the old multiple-output-pair
infrastructure.
2014-12-05 09:55:49 -05:00
Ben Boeckel 6fa6bedf78 LocalGenerator: Add a string overload for AppendFlags 2014-05-07 14:30:31 -04: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
Ben Boeckel 3742bb0d32 stringapi: Use strings for variable names
Variable names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -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 97fae68b81 Remove INTERFACE build targets.
Commit b04f3b9a (Create make rules for INTERFACE_LIBRARY
targets., 2013-08-21) extended the makefile generator to create
build targets for INTERFACE_LIBRARY targets. No other generators
were extended with this feature.

This conflicts with the feature of whitelisting of target properties
read from INTERFACE_LIBRARY targets. The INTERFACE_* properties
of the INTERFACE_LIBRARY may legitimately contain TARGET_PROPERTY
generator expressions for reading properties from the 'head target'.
The 'head target' would be the INTERFACE_LIBRARY itself when creating
the build rules for it, which means that non-whitelisted properties
would be read.
2013-12-10 17:58:36 +01:00
Stephen Kelly 0bfcb450e6 INTERFACE_LIBRARY: Avoid codepaths which set unneeded properties.
As an INTERFACE_LIBRARY has no direct link dependencies, we can
short-circuit in cmGeneratorExpressionEvaluator and
in cmGlobalGenerator::CheckLocalGenerators.

As they do not generate any output directly, any generate- or install-
related code acn also be short-circuited. Many of the local generators
already do this.

Because only INTERFACE related properties make sense on INTERFACE_LIBRARY
targets, avoid setting other properties, for example via defaults.
2013-11-25 16:17:50 +01: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 b04f3b9a2a Create make rules for INTERFACE_LIBRARY targets.
The result is that the depends of the target are created.

So,

 add_library(somelib foo.cpp)
 add_library(anotherlib EXCLUDE_FROM_ALL foo.cpp)
 add_library(extra EXCLUDE_FROM_ALL foo.cpp)
 target_link_libraries(anotherlib extra)

 add_library(iface INTERFACE)
 target_link_libraries(iface INTERFACE anotherlib)

Executing 'make iface' will result in the anotherlib and extra targets
being made.

Adding a regular executable to the INTERFACE of an INTERFACE_LIBRARY
will not result in the executable being built with 'make iface' because
of the logic in cmComputeTargetDepends::AddTargetDepend.

So far, this is implemented only for the Makefile generator. Other
generators will follow if this feature is possible for them.

Make INTERFACE_LIBRARY targets part of the all target by default.
Test this by building the all target and making the expected library
EXCLUDE_FROM_ALL.
2013-10-21 09:46:27 -04:00