Commit Graph

666 Commits

Author SHA1 Message Date
Brad King dccd4949c0 Use first custom command for the same output (#14446)
In buggy code like

 add_custom_command(
   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/out.h
   MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/out.h.in
   ...)
 add_custom_command(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/out.h
   ...)

that has more than one rule to generate the same output CMake has always
used the first rule.  However, since commit 2268c41a (Optimize custom
command full-path dependency lookup, 2013-08-06) we update the map from
output to cmSourceFile for every rule generating an output, effectively
keeping the last command instead of the first.

Fix this regression by checking for each map update if the output
already has an entry.  If so, keep only the original entry.  The VS 8
generator triggers this with a special case for generate.stamp rules
that differ between ZERO_CHECK and normal targets, so do not warn for
now.  Leave a TODO comment for warning in the future.
2013-09-30 15:03:00 -04:00
Nicolas Despres 2268c41a05 Optimize custom command full-path dependency lookup
In the common case of custom command dependencies specified via full
path optimize the implementation of GetSourceFileWithOutput using a
(hash) map.  This is significantly faster than the existing linear
search.  In the non-full-path case fall back to the existing linear
suffix search.
2013-08-06 16:17:13 -04:00
Stephen Kelly 370bf55415 Add the ALIAS target concept for libraries and executables.
* The ALIAS name must match a validity regex.
* Executables and libraries may be aliased.
* An ALIAS acts immutable. It can not be used as the lhs
  of target_link_libraries or other commands.
* An ALIAS can be used with add_custom_command, add_custom_target,
  and add_test in the same way regular targets can.
* The target of an ALIAS can be retrieved with the ALIASED_TARGET
  target property.
* An ALIAS does not appear in the generated buildsystem. It
  is kept separate from cmMakefile::Targets for that reason.
* A target may have multiple aliases.
* An ALIAS target may not itself have an alias.
* An IMPORTED target may not have an alias.
* An ALIAS may not be exported or imported.
2013-08-02 15:21:00 +02:00
Brad King 58c5dc37d3 Merge topic '13582_configured_file_regeneration'
8fbf39a cmMakefile: Do not track configured files known to be temporary
2013-07-31 08:48:57 -04:00
Brad King 8fbf39a471 cmMakefile: Do not track configured files known to be temporary
Since commit ad502502 (cmMakefile: Track configured files so we can
regenerate them, 2013-06-18) cmMakefile::ConfigureFile records the
configured file as an output file generated by CMake.  The intention is
that for make and ninja we can re-run CMake when one of the files it
generates goes missing.  However, files configured temporarily in
CMakeTmp directories by Check* modules do not live past the CMake
invocation.

Teach cmMakefile::ConfigureFile to skip tracking files with "CMakeTmp"
in their path, just like cmCoreTryCompile::TryCompileCode does to
avoid adding dependencies on temporary source files.  In the future
we will need a more general filter to avoid recording as CMake
outputs any files that do not exist at the end of generation.
2013-07-30 14:43:59 -04:00
Stephen Kelly d8cb47f23c Docs: Trim trailing whitespace in generated doc. 2013-07-26 09:37:12 +02:00
Stephen Kelly 4f6bd7022b Remove the LINK_LANGUAGE generator expression.
It accepted an optional argument to test for equality, but no way
to get the linker language of a particular target.

TARGET_PROPERTY provides this flexibility and STREQUAL provides
the necessary API for equality test.

Extend the CompileDefinitions test to cover accessing the
property of another target.
2013-07-24 10:40:00 -04:00
Brad King 41a2fb5ba0 Merge topic 'tid-system-argument'
9cf3547 Add the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property.
1925cff Add a SYSTEM parameter to target_include_directories (#14180)
286f227 Extend the cmTargetPropCommandBase interface property handling.
83498d4 Store system include directories in the cmTarget.
f1fcbe3 Add Target API to determine if an include is a system include.
2679a34 Remove unused variable.
2013-07-16 13:59:07 -04:00
Stephen Kelly d7dd01083a Add target property debugging for COMPILE_DEFINITIONS
Use constructs similar to those for COMPILE_OPTIONS. This is a little
different because there is a command to remove_definitions(), so
we can't populate the equivalent target property until generate-time
in cmGlobalGenerator.
2013-07-12 16:57:36 +02:00
Stephen Kelly 83498d4135 Store system include directories in the cmTarget.
Entries from the cmMakefile are processed and maintained similarly
to other include directories. The include_directories(SYSTEM)
signature affects all following targets, and all prior targets
in the same makefile.
2013-07-02 16:40:02 +02:00
Robert Maynard ad502502df cmMakefile: Track configured files so we can regenerate them (#13582)
Currently when a configured file is removed from the build directory,
running the build command will not regenerate the file. Now detect
this and will rerun cmake properly when a user issues the build
command.
2013-06-25 08:51:20 -04:00
Robert Maynard 6dbd4a5f17 cmMakefile: Refactor AddCMakeDependFile and AddCMakeOutputFile.
AddCMakeDependFile and AddCMakeOutputFile both store as std::string
and all calling sites use std::string. So instead of creating more
temporary objects, lets just use std::strings.
2013-06-24 10:43:20 -04:00
Brad King 2cd8a6a3c6 Merge topic 'cleanups'
9efe359 Add some spaces to the INCLUDE_DIRECTORIES documentation.
db15713 Remove unused cmAddDefinitionsCommand::ParseDefinition method.
2013-06-05 09:39:12 -04:00
Stephen Kelly 9efe35906a Add some spaces to the INCLUDE_DIRECTORIES documentation. 2013-06-04 12:00:41 +02:00
Stephen Kelly a984f3257e Introduce add_compile_options command.
This command is similar to add_definitions, in that it affects
the compile options of all targets which follow it. The implementation
is similar to the implementation of the include_directories command,
in that it is based on populating a COMPILE_OPTIONS directory property
and using that to initialize the same property on targets.

Unlike the include_directories command however, the add_compile_options
command does not affect previously defined targets. That is, in
the following code, foo will not be compiled with -Wall, but bar
will be:

 add_library(foo ...)
 add_compile_options(-Wall)
 add_library(bar ...)
2013-06-04 11:36:55 +02:00
Andreas Mohr bf019d765d Fix spelling and typos (non-binary) 2013-05-07 08:39:19 -04:00
Andreas Mohr ddac8d3d2d Fix spelling and typos (affecting binary data / module messages) 2013-05-07 08:39:19 -04:00
Stephen Kelly 5a5e0fa9d3 Fix clearing of the INCLUDE_DIRECTORIES DIRECTORY property.
This was broken by commit 18a3195a (Keep track of INCLUDE_DIRECTORIES
as a vector of structs., 2012-11-19).
2013-04-10 18:12:56 +02:00
Stephen Kelly 5b88504f65 Rename the IncludeDirectoriesEntry to be more generic. 2013-02-12 10:39:35 +01:00
Brad King 813b519280 Merge topic 'minor-fixes'
ba48e63 Generate config-specific interface link libraries propeties.
deb51a7 Remove unused forward declarations.
9712362 Don't allow utility or global targets in the LINKED expression.
faa927e Make sure INTERFACE properties work with OBJECT libraries.
510fdcb Whitelist target types in target_{include_directories,compile_definitions}
4de7178 Ensure that the build interface includes have been added.
df74bc3 Only append build interface include dirs to particular targets.
d4e5c67 Don't keep track of content determined by target property values.
1fb545a Move a special case for PIC from the genex to the cmTarget code.
57175d5 Only use early evaluation termination for transitive properties.
4cf161a Fix determination of evaluating link libraries.
3a298c0 Fix generation of COMPILE_DEFINITIONS in DependInfo.cmake.
655e98b Ensure type specific compatible interface properties do not intersect.
46e2896 The COMPATIBLE_INTERFACE does not affect the target it is set on.
5f926a5 Test printing origin of include dirs from tll().
7c0ec75 De-duplicate validation of genex target names.
...
2013-02-11 13:59:48 -05:00
Brad King c0debb1f89 Merge branch 'master' into generator-toolset
We need the latest Tests/CMakeLists.txt so we can refactor all tests.
2013-02-07 11:09:01 -05:00
Brad King 4fd5342956 CMake: Add -T option to choose a generator toolset
Reject the option by default.  It will be implemented on a per-generator
basis.  Pass the setting into try_compile project generation.  Add cache
entry CMAKE_GENERATOR_TOOLSET and associated variable documentation to
hold the value persistently.

Add a RunCMake.GeneratorToolset test to cover basic "-T" option cases.
Verify that CMAKE_GENERATOR_TOOLSET is empty without -T, that -T is
rejected when the generator doesn't support it, and that two -T options
are always rejected.
2013-02-07 10:53:19 -05:00
Stephen Kelly 1714c27a74 Process generator expressions for 'system' include directories.
Since commit 08cb4fa4 (Process generator expressions in the
INCLUDE_DIRECTORIES property., 2012-09-18), it is possible to use
generator expressions with the include_directories command.

As that command can also have a SYSTEM argument, ensure that the
result of using that argument with generator expressions gives a
sane result.
2013-02-07 10:03:30 +01:00
Brad King 907f1e2227 Merge topic 'cmMakefile-comment-typos'
3853a6c spell: fix a few typos in comments
2013-01-24 08:25:53 -05:00
Yury G. Kudryashov 3853a6c3a7 spell: fix a few typos in comments 2013-01-23 10:51:31 -05:00
Stephen Kelly d70204a86a Only output includes once after the start of 'generate-time' when debugging.
During configure-time, GetIncludeDirectories may be called too, for example
if using the export() command. As the content can be different, it should
be output each time then.
2013-01-21 09:12:22 +01:00
Stephen Kelly 0d46e9a029 Store includes from the same include_directories call together.
Otherwise, we get a separate IncludeDirectoriesEntry for each include,
and that causes unnecessary and confusing splitting in the output when
debugging the INCLUDE_DIRECTORIES property.
2013-01-21 09:12:22 +01:00
Stephen Kelly 18a3195ad5 Keep track of INCLUDE_DIRECTORIES as a vector of structs.
The struct can keep track of where the include came from, which gives
us proper backtraces.
2013-01-03 13:45:40 -05:00
Brad King 711b63f7e0 Add policy CMP0019 to skip include/link variable re-expansion
Historically CMake has always expanded ${} variable references in the
values given to include_directories(), link_directories(), and
link_libraries().  This has been unnecessary since general ${}
evaluation syntax was added to the language a LONG time ago, but has
remained for compatibility with VERY early CMake versions.

For a long time the re-expansion was a lightweight operation because it
was only processed once at the directory level and the fast-path of
cmMakefile::ExpandVariablesInString was usually taken because values did
not have any '$' in them.  Then commit d899eb71 (Call
ExpandVariablesInString for each target's INCLUDE_DIRECTORIES,
2012-02-22) made the operation a bit heavier because the expansion is
now needed on a per-target basis.  In the future we will support
generator expressions in INCLUDE_DIRECTORIES with $<> syntax, so the
fast-path in cmMakefile::ExpandVariablesInString will no longer be taken
and re-expansion will be very expensive.

Add policy CMP0019 to skip the re-expansion altogether in NEW behavior.
In OLD behavior perform the expansion but improve the fast-path
heuristic to match ${} but not $<>.  If the policy is not set then warn
if expansion actually does anything.  We expect this to be encountered
very rarely in practice.
2012-12-07 09:51:19 -05:00
Petr Kmoch 694322ecea Define properties VS_GLOBAL_SECTION_*
Add definition and documentation of properties
VS_GLOBAL_SECTION_PRE_<section> and VS_GLOBAL_SECTION_POST_<section>.
2012-11-16 08:17:14 -05:00
Stephen Kelly 5285458342 Add convenience for getting a cmGeneratorTarget to use. 2012-09-19 15:32:25 +02:00
Peter Kümmel 7b2bf28e18 Ninja: suppress cmcldeps only for source file signature try_compiles 2012-09-05 14:38:49 +02:00
David Cole ae6f9b015f Merge topic 'module-no-soname'
56148fd Do not crash on SHARED library without language (#13324)
2012-06-21 11:55:15 -04:00
Brad King 56148fd2bc Do not crash on SHARED library without language (#13324)
Since commit e1409ac5 (Support building shared libraries or modules
without soname, 2012-04-22) CMake crashes on the code

 add_library(foo SHARED foo.nolang)

because the logic to lookup the language's soname flag was moved from
cmTarget::GetLibraryNames to cmMakefile::GetSONameFlag without its check
for a NULL language.  Restore the check for NULL.

Add RunCMake.Languages test to cover language error cases like this one.
2012-06-20 11:26:05 -04:00
Brian Helba b3b095a933 Print any evaluated 'elseif'/'else' commands in trace mode (#13220)
In trace mode ('--trace'), any 'elseif' or 'else' commands that are
evaluated as part of a conditional block will be printed.  Previously,
only the opening 'if' command of a conditional block was printed.
2012-05-16 09:07:55 -04:00
David Cole 8df7aa54f0 Merge topic 'module-no-soname'
fdb3f87 Test NO_SONAME property (#13155)
e1409ac Support building shared libraries or modules without soname (#13155)
2012-05-01 14:09:59 -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 369e3464be Factor out custom command .rule file path generation
Add cmGlobalGenerator::GenerateRuleFile to compute a generator-specific
rule file location.  This will allow specific generators to override the
location of .rule files without changing the behavior of other
generators.
2012-04-18 15:49:38 -04:00
Brad King f9b758e91a Cleanup custom command .rule file internal handling
Teach cmMakefile::AddCustomCommandToOutput to return the cmSourceFile
instance to which the custom command is attached.  Use the return value
instead of separately adding a .rule extension and searching for the
source.  Mark CMake-generated .rule files explicitly with a property
instead of trusting the file extension.
2012-04-18 15:48:50 -04:00
Brad King 9a2c60eb83 Classify known header file extensions as headers
Commit 328c0f65 (Simplify cmVisualStudio10TargetGenerator source
classification, 2012-03-19) introduced the first use of source
classification from cmGeneratorTarget (which originated as Makefile
generator logic) in a Visual Studio generator for handling of header
files.  Fix classification of header files to match known header
extensions instead of only the HEADER_FILE_ONLY property.  Make it
consistent with the "Header Files" source group.
2012-03-28 08:59:14 -04:00
David Cole b063599603 Add a default source group for object files. 2012-03-16 14:25:21 -04:00
Brad King b87d7a60a0 Add OBJECT_LIBRARY target type
This library type can compile sources to object files but does not link
or archive them.  It will be useful to reference from executable and
normal library targets for direct inclusion of object files in them.

Diagnose and reject the following as errors:

* An OBJECT library may not be referenced in target_link_libraries.

* An OBJECT library may contain only compiling sources and supporting
  headers and custom commands.  Other source types that are not normally
  ignored are not allowed.

* An OBJECT library may not have PRE_BUILD, PRE_LINK, or POST_BUILD
  commands.

* An OBJECT library may not be installed, exported, or imported.

Some of these cases may be supported in the future but are not for now.

Teach the VS generator that OBJECT_LIBRARY targets are "linkable" just
like STATIC_LIBRARY targets for the LinkLibraryDependencies behavior.
2012-03-13 14:37:32 -04:00
Brad King 9c0a00d6dd Rename/constify build-time config placeholder lookup
Rename cmGlobalGenerator::GetCMakeCFG{InitDirectory => IntDir} to
have a shorter name without a typo.  Add a 'const' qualifier since
the method is only for lookup and never needs to modify anything.
2012-03-09 15:16:03 -05:00
David Cole 580171185b Merge topic 'target-include-directories'
d662dff Fix shadowed variable warning on dashboard results
f66e735 Fix compiler warning reported on older Borland dashboard.
d90eed4 Fix compiler error reported on older Borland dashboard.
8233636 Update the documentation regarding INCLUDE_DIRECTORIES.
d899eb7 Call ExpandVariablesInString for each target's INCLUDE_DIRECTORIES
c21db87 Make search paths ordered and unique
22021f0 Remove cmMakefile::GetIncludeDirectories
9106b56 Extract and use the INCLUDE_DIRECTORIES target properties.
840509b Keep the INCLUDE_DIRECTORIES target property up to date.
a4d5f7b Add API to get the ordered includes for a target.
8adaee2 CMake: Eliminate cmMakefile::IncludeDirectories
7620932 Remove include flags memoization.
97a5faa Make it safe to call this method without creating duplicates.
edd5303 Refactor GetIncludeFlags to take includes instead of fetching them
2012-03-08 15:13:15 -05:00
Yury G. Kudryashov 89403bf87f Rename UsedCommands to FinalPassCommands
When I read 'UsedCommands' I thought that it holds all commands used in the
file, not only those that have FinalPass().
2012-02-29 11:49:42 +04:00
David Cole d662dff769 Fix shadowed variable warning on dashboard results 2012-02-23 08:11:09 -05:00
David Cole 8233636dbe Update the documentation regarding INCLUDE_DIRECTORIES.
It is now a target property and is affected by the use
of the include_directories command.
2012-02-22 15:22:03 -05:00
David Cole d899eb71b5 Call ExpandVariablesInString for each target's INCLUDE_DIRECTORIES
For strict backwards compatibility only. This should be unnecessary at
this point, but introducing a policy to deprecate it properly is a
whole different topic branch...
2012-02-22 07:29:32 -05:00
David Cole 22021f07f8 Remove cmMakefile::GetIncludeDirectories
After making the changes to use the new target level INCLUDE_DIRECTORIES
property, there are no more callers of this method.
2012-02-22 07:29:32 -05:00
Stephen Kelly 840509babb Keep the INCLUDE_DIRECTORIES target property up to date.
The directory level property changes need to be added to it.
2012-02-22 06:31:50 -05:00