Commit Graph

383 Commits

Author SHA1 Message Date
Stephen Kelly 95d590ddba GenEx: Create cmGeneratorTargets for imported targets.
We're going to need to link to them, and all the linking API is moving
to cmGeneratorTarget.

Skip imported targets when iterating over cmGeneratorTargets in places
where we only want targets we build.  The GetGeneratorTargets result now
includes IMPORTED targets where it didn't before.  The GetTargets
result, which was what used to be called in these methods does not
include IMPORTED targets.  This doesn't relate to any known bugs, but in
some future uses of GetGeneratorTargets it will be important, so
starting the convention and being deliberate now is a good idea.
2012-10-22 14:03:51 -04:00
Stephen Kelly 2a6bd96c13 Fix config-specific INCLUDE_DIRECTORIES in multi-config generators
Commit 08cb4fa4 (Process generator expressions in the
INCLUDE_DIRECTORIES property, 2012-09-18) contained an incorrect
assumption that CMAKE_BUILD_TYPE was set on the makefile for each
generated configuration in multi-config generators. Fix that by making
the GetIncludeDirectories API depend on the config.
2012-10-17 16:24:14 -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 103d99338a Merge topic 'generator-expression-target-properties'
083de7e Process generator expressions in the COMPILE_DEFINITIONS target property.
08cb4fa Process generator expressions in the INCLUDE_DIRECTORIES property.
0ef091d Early return if there is no target.
eb250cd Add a self-reference check for target properties.
7e80747 Add API to check that dependent target properties form a DAG.
239ac84 Add a generator expression for target properties.
e028381 Extend the generator expression language with more logic.
b8e61d6 Refactor GetCompileDefinitions a bit.
2c2b25b Return a std::string from GetCompileDefinitions.
b7e48e0 Add an AppendDefines std::string overload.
9a16087 Convert paths in INCLUDE_DIRECTORIES property to Unix slashes.
4557c8d Don't prepend a path before generator expressions in include_directories.
c6abc41 Add include guard for cmGeneratorExpression.
0ff4e3f Port remaining code to GetCompileDefinitions().
f178d53 Fix indentation in the code blocks generator.
2012-09-28 17:15:03 -04:00
Stephen Kelly 0ef091d986 Early return if there is no target.
The remainder of this method depends on the target existing (otherwise
the includes container would be empty), so make the code a little more
readable.
2012-09-28 08:49:21 -04:00
David Cole 3f3b731961 Merge topic 'use-generator-target'
879fd35 Revert "Move GenerateTargetManifest to cmGeneratorTarget."
6674583 Fix compiler warning with initialization order.
5285458 Add convenience for getting a cmGeneratorTarget to use.
c31f3d9 Add a wrapper for accessing config-specific compile-definitions.
d1446ca Append the COMPILE_DEFINITIONS from the Makefile to all targets.
290e92a Move GetIncludeDirectories to cmGeneratorTarget.
f9146f6 Port cmLocalGenerator::GetTargetFlags to cmGeneratorTarget.
9facfd1 Move GetCreateRuleVariable to cmGeneratorTarget.
78bfee3 Make cmLocalGenerator::AddArchitectureFlags take a cmGeneratorTarget.
4f5384e Move GetLinkInformation to cmGeneratorTarget
987e12e Move GenerateTargetManifest to cmGeneratorTarget.
14bf778 Store cmGeneratorTargets with the makefile.
f428ca2 Add more forwarding API to cmGeneratorTarget.
2012-09-25 15:18:34 -04:00
Brad King a0a0877a1e OS X: Always generate -isysroot if any SDK is in use
Drop the last use of CMAKE_OSX_SYSROOT_DEFAULT.  Replace internal
platform variable CMAKE_${lang}_HAS_ISYSROOT with a more general
CMAKE_${lang}_SYSROOT_FLAG variable.  If the -isysroot flag exists and
CMAKE_OSX_SYSROOT points to an SDK (not "/") then always add it to
compiler command lines.  This is already done in the Xcode IDE.
2012-09-21 08:53:42 -04:00
Stephen Kelly 879fd354c1 Revert "Move GenerateTargetManifest to cmGeneratorTarget."
This reverts commit 987e12e2f9.

GenerateTargetManifest is called by the global generator before it
creates the generator targets, so we can't move it to cmGeneratorTarget
yet.
2012-09-20 08:34:30 +02:00
Stephen Kelly 290e92ada8 Move GetIncludeDirectories to cmGeneratorTarget. 2012-09-19 15:32:09 +02:00
Stephen Kelly f9146f6b90 Port cmLocalGenerator::GetTargetFlags to cmGeneratorTarget. 2012-09-19 15:31:39 +02:00
Stephen Kelly 9facfd1336 Move GetCreateRuleVariable to cmGeneratorTarget. 2012-09-19 15:31:32 +02:00
Stephen Kelly 78bfee35d5 Make cmLocalGenerator::AddArchitectureFlags take a cmGeneratorTarget. 2012-09-19 15:31:29 +02:00
Stephen Kelly 4f5384e75c Move GetLinkInformation to cmGeneratorTarget 2012-09-19 15:30:57 +02:00
Stephen Kelly 987e12e2f9 Move GenerateTargetManifest to cmGeneratorTarget. 2012-09-19 15:30:49 +02:00
Stephen Kelly 3dae652b4e Don't duplicate -D defines sent to the compiler.
There is no need to do so. Be consistent with include directories and
ensure uniqueness.

This requires changing the API of the cmLocalGenerator::AppendDefines
method, and changing the generators to match.

The test unfortunately can't test for uniqueness, but it at least verifies
that nothing gets lost.
2012-08-20 22:30:11 +02:00
David Cole e5ebb77405 Merge topic 'no-source-language-crash'
2c2fbaf Do not crash on unknown source language (#13323)
2012-06-21 11:54:52 -04:00
Mariusz Plucinski 2c2fbaf0e5 Do not crash on unknown source language (#13323)
If a source file extension is not recognized as any language then
src.GetLanguage() may return NULL.  Check the result before
dereferencing in cmLocalGenerator::GetObjectFileNameWithoutTarget.
2012-06-20 08:59:54 -04:00
David Cole 565744bd3d Merge topic 'ninja-cldeps'
eb410e8 Ninja: disable cldeps for bcc32, it's too old, and ninja would also not build
5ead31d Ninja: try work around for bcc32 bug
1333b57 Ninja: build server fixes
9081e3a remove warning about unused parameter
f430bea Ninja: maybe this fixes the bcc32 build
f2c1288 Ninja: msvc6 for-scoping
44b9bbc Ninja: build with old msvc versions
57156a5 Ninja: build server fixes
f1abdce Ninja: some bytes of the rc files couldn't be piped correctly
2de963d Ninja: don't remove space between command and parameters
50b6f33 Ninja: build cmcldeps with mingw
c05653e Ninja: try to make GetProcessId visible
ab245ff Ninja: but cl supports /nologo ...
bf58e9a Ninja: no /nologo option in old rc.exe
2fb07fc Ninja: Eclipse and KDevelop fixes for ninja
518c065 Ninja: don't pollute build dir with preprocessed rc files
...
2012-06-19 14:42:41 -04:00
Peter Kuemmel 43200c145d Ninja: work with ninja/master, don't compile rc files with cl
Ninja generates for paths with spaces wrong results for $out.d,
using the new DEP_FILE variable instead.
2012-06-13 00:52:46 +02:00
Stephen Kelly bd34963002 Refactor generation of shared library flags
CMAKE_SHARED_LIBRARY_<lang>_FLAGS has flags on various platforms for a
variety of purposes that are correlated with shared libraries but not
exclusive to them.  Refactor generation of these flags to use new
purpose-specific platform variables

  CMAKE_<lang>_COMPILE_OPTIONS_DLL
  CMAKE_<lang>_COMPILE_OPTIONS_PIC
  CMAKE_<lang>_COMPILE_OPTIONS_PIE

Activate the DLL flags specifically for shared libraries.  Add a new
POSITION_INDEPENDENT_CODE target property to activate PIC/PIE flags, and
default to true for shared libraries to preserve default behavior.
Initialize the new property from CMAKE_POSITION_INDEPENDENT_CODE to
allow easy global configuration in projects.

Although the default behavior is unchanged by this refactoring, the new
approach ignores CMAKE_SHARED_LIBRARY_<lang>_FLAGS completely.  We must
leave it set in case projects reference the value.  Furthermore, if a
project modifies CMAKE_SHARED_LIBRARY_<lang>_FLAGS it expects the new
value to be used.  Add policy CMP0018 to handle compatibility with
projects that modify this platform variable.

Add a PositionIndependentCode test on platforms where we can get
meaningful results.
2012-06-12 15:38:48 -04:00
Peter Collingbourne d807aab28f Ninja: apply CMAKE_<LANG>_FLAGS_<TYPE> to executable targets (#13069)
Based on a patch by Zaheer Chothia!
2012-05-16 22:56:42 +01: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 c68cc06612 Merge branch 'object-library' into ninja-object-library 2012-03-16 10:18:01 -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 51b67366ed Merge branch 'cleanup-object-file-names' into object-library 2012-03-09 15:15:37 -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
Peter Kuemmel dbe3dce546 Ninja: add .def file support 2012-03-07 16:24:34 -05:00
Brad King 4ae7f3656b Remove unused partial OBJECT_FILES property implementation
Remove partial implementation added by commit ca0230a3 (check in initial
conv library stuff, 2007-02-16) since it was never finished.  It does
not make sense for multi-configuration generators since no specific
build configuration is processed at CMake time.
2012-03-06 13:20:17 -05:00
David Cole 881dc35579 Merge topic 'factor-install-type'
573fa3b Factor cmInstallType out of cmTarget::TargetType
2012-03-02 11:47:42 -05:00
Brad King 573fa3bf13 Factor cmInstallType out of cmTarget::TargetType
The purpose of the TargetType enumeration was overloaded for install
type because install rules were once recorded as targets.  Factor the
install types out into their own enumeration.
2012-02-27 13:19:57 -05:00
Yury G. Kudryashov 4f6fd961da Drop if(...) check because condition is always true
GetLocation returns std::string::c_str() which is never NULL
2012-02-27 11:59:15 -05:00
David Cole bada88e8e4 Merge branch 'target-include-directories' into ninja-generator 2012-02-22 16:21:48 -05:00
Stephen Kelly 9106b564ae Extract and use the INCLUDE_DIRECTORIES target properties.
Eliminate callers of cmMakefile::GetIncludeDirectories.

All callers of GetIncludeDirectories should go through the local generator
object.

Only the local generator calls cmTarget::GetIncludeDirectories directly.
2012-02-22 06:31:50 -05:00
David Cole 8adaee2b0b CMake: Eliminate cmMakefile::IncludeDirectories
Instead, re-implement it in terms of the directory property INCLUDE_DIRECTORIES.
2012-02-22 06:31:49 -05:00
Stephen Kelly 7620932d82 Remove include flags memoization. 2012-02-22 06:31:49 -05:00
Stephen Kelly 97a5faa858 Make it safe to call this method without creating duplicates. 2012-02-22 06:31:49 -05:00
Stephen Kelly edd5303949 Refactor GetIncludeFlags to take includes instead of fetching them 2012-02-22 06:31:49 -05:00
Peter Collingbourne 4468edf12b Add executable with exports flag support to cmLocalGenerator::GetTargetFlags 2012-02-02 23:36:42 +00:00
Brad King 6b104e107e Remove trailing whitespace from cmLocalGenerator 2011-11-29 08:58:45 -05:00
Peter Collingbourne fec4b63714 Fix configuration-dependent flag lookup in cmLocalGenerator::GetTargetFlags
Specifically, perform configuration-dependent lookup of
STATIC_LIBRARY_FLAGS for static libraries, and use the correct prefix
for configuration-dependent lookup of LINK_FLAGS (i.e. "LINK_FLAGS_",
as opposed to the value of the LINK_FLAGS property).
2011-10-02 18:30:43 +01:00
Peter Collingbourne 5b114c9bee Introduce a cmLocalGenerator::ConvertToIncludeReference function
This provides a mechanism for the local generator to override how
header search paths are generated.
2011-10-02 18:30:43 +01:00
Nicolas Despres 3db2973bd2 Refactor TargetTypeNames.
Make it a static method instead of an array. It is safer for the
type checking and if we add a new target type we will be warned to add
a case to the switch.
2011-10-02 18:30:42 +01: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
Brad King 148b528f9d Merge topic 'custom-command-slashes'
1286050 Normalize slashes of add_custom_(command|target) DEPENDS (#11973)
2011-03-31 13:23:32 -04:00
Brad King 128605054a Normalize slashes of add_custom_(command|target) DEPENDS (#11973)
All commands accepting file paths should normalize the slashes so that
the string-represented names can be compared reliably.  The commands
add_library and add_executable have done this for years.  We taught
add_custom_command to normalize its OUTPUT names in commit a75a0a14
(Normalize add_custom_command OUTPUT names, 2010-12-15).  We handled a
special case of the DEPENDS option in commit 7befc007 (Handle trailing
slashes on add_custom_command DEPENDS, 2011-01-26).

Teach both add_custom_command and add_custom_target to normalize slashes
of DEPENDS files up front.  This approach subsumes the above-mentioned
special case so remove the one line added for it but keep its test.
Extend the CustomCommand test to check that slash count mismatches
between custom command OUTPUT and DEPENDS can still be linked correctly.
2011-03-30 09:52:07 -04:00
Brad King 1c3233a850 Merge topic 'include-flags-response-file'
86cb17b Pass include directories with response files to GNU on Windows
9a0b9bc Optionally pass include directories with response files
6e8a67f Generate target-wide flags before individual build rules
d099546 Factor old-style -D flags out from -I flag generation
2011-03-22 14:45:44 -04:00
Brad King 9a0b9bc8b7 Optionally pass include directories with response files
Create platform option CMAKE_<lang>_USE_RESPONSE_FILE_FOR_INCLUDES to
enable use of response files for passing the list of include directories
to compiler command lines.
2011-03-17 17:56:13 -04:00
Brad King d099546450 Factor old-style -D flags out from -I flag generation
Move the GetDefineFlags call from cmLocalGenerator::GetIncludeFlags to
all call sites so that the method exclusively constructs a string of
include search path flags.
2011-03-15 13:09:06 -04:00
Brad King 7befc00783 Handle trailing slashes on add_custom_command DEPENDS 2011-01-26 18:01:33 -05:00