summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/add_test.rst86
-rw-r--r--Help/command/install.rst329
-rw-r--r--Help/release/3.0.0.rst4
-rw-r--r--Modules/CMakeFindDependencyMacro.cmake33
-rw-r--r--Modules/ExternalProject.cmake9
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx57
-rw-r--r--Source/cmGeneratorTarget.cxx482
-rw-r--r--Source/cmGeneratorTarget.h45
-rw-r--r--Source/cmGlobalGenerator.cxx36
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx28
-rw-r--r--Source/cmInstallCommand.cxx21
-rw-r--r--Source/cmInstallFilesCommand.cxx5
-rw-r--r--Source/cmInstallFilesGenerator.cxx55
-rw-r--r--Source/cmInstallFilesGenerator.h12
-rw-r--r--Source/cmInstallProgramsCommand.cxx5
-rw-r--r--Source/cmMakefileTargetGenerator.cxx11
-rw-r--r--Source/cmNinjaTargetGenerator.cxx6
-rw-r--r--Source/cmOSXBundleGenerator.cxx32
-rw-r--r--Source/cmOSXBundleGenerator.h2
-rw-r--r--Source/cmTarget.cxx511
-rw-r--r--Source/cmTarget.h53
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx6
-rw-r--r--Tests/BuildDepends/CMakeLists.txt30
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt12
-rw-r--r--Tests/BuildDepends/Project/External/CMakeLists.txt14
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt16
-rw-r--r--Tests/ExportImport/Export/testLib1file1.txt1
-rw-r--r--Tests/ExportImport/Export/testLib1file2.txt1
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt6
-rw-r--r--Tests/ExportImport/Import/A/check_testLib1_genex.cmake11
-rw-r--r--Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt14
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariable-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariable.cmake9
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake9
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableFile.cmake8
-rw-r--r--Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/EscapeQuotes.cmake9
-rw-r--r--Tests/RunCMake/Syntax/EscapedAt-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/EscapedAt.cmake5
-rw-r--r--Tests/RunCMake/Syntax/ExpandInAt-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/ExpandInAt.cmake6
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV-stderr.txt20
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV.cmake2
-rw-r--r--Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/ParenInQuotedENV.cmake2
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/Syntax/atfile.txt.in4
58 files changed, 1323 insertions, 743 deletions
diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst
index 5714559..7e7e6bd 100644
--- a/Help/command/add_test.rst
+++ b/Help/command/add_test.rst
@@ -1,69 +1,59 @@
add_test
--------
-Add a test to the project with the specified arguments.
+Add a test to the project to be run by :manual:`ctest(1)`.
::
- add_test(testname Exename arg1 arg2 ... )
+ add_test(NAME <name> COMMAND <command> [<arg>...]
+ [CONFIGURATIONS <config>...]
+ [WORKING_DIRECTORY <dir>])
-If the ENABLE_TESTING command has been run, this command adds a test
-target to the current directory. If ENABLE_TESTING has not been run,
-this command does nothing. The tests are run by the testing subsystem
-by executing Exename with the specified arguments. Exename can be
-either an executable built by this project or an arbitrary executable
-on the system (like tclsh). The test will be run with the current
-working directory set to the CMakeList.txt files corresponding
-directory in the binary tree. Tests added using this signature do not
-support generator expressions.
+Add a test called ``<name>``. The test name may not contain spaces,
+quotes, or other characters special in CMake syntax. The options are:
+``COMMAND``
+ Specify the test command-line. If ``<command>`` specifies an
+ executable target (created by :command:`add_executable`) it will
+ automatically be replaced by the location of the executable created
+ at build time.
+``CONFIGURATIONS``
+ Restrict execution of the test only to the named configurations.
-::
-
- add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]
- [WORKING_DIRECTORY dir]
- COMMAND <command> [arg1 [arg2 ...]])
-
-Add a test called <name>. The test name may not contain spaces,
-quotes, or other characters special in CMake syntax. If COMMAND
-specifies an executable target (created by add_executable) it will
-automatically be replaced by the location of the executable created at
-build time. If a CONFIGURATIONS option is given then the test will be
-executed only when testing under one of the named configurations. If
-a WORKING_DIRECTORY option is given then the test will be executed in
-the given directory.
-
-Arguments after COMMAND may use "generator expressions" with the syntax
-``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for
-available expressions.
+``WORKING_DIRECTORY``
+ Set the :prop_test:`WORKING_DIRECTORY` test property to
+ specify the working directory in which to execute the test.
+ If not specified the test will be run with the current working
+ directory set to the build directory corresponding to the
+ current source directory.
-Note that tgt is not added as a dependency of the target this
-expression is evaluated on.
+The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator
+expressions" with the syntax ``$<...>``. See the
+:manual:`cmake-generator-expressions(7)` manual for available expressions.
-::
-
- $<TARGET_POLICY:pol> = '1' if the policy was NEW when the 'head' target was created, else '0'. If the policy was not set, the warning message for the policy will be emitted. This generator expression only works for a subset of policies.
- $<INSTALL_PREFIX> = Content of the install prefix when the target is exported via INSTALL(EXPORT) and empty otherwise.
+Example usage::
-Boolean expressions:
+ add_test(NAME mytest
+ COMMAND testDriver --config $<CONFIGURATION>
+ --exe $<TARGET_FILE:myexe>)
-::
+This creates a test ``mytest`` whose command runs a ``testDriver`` tool
+passing the configuration name and the full path to the executable
+file produced by target ``myexe``.
- $<AND:?[,?]...> = '1' if all '?' are '1', else '0'
- $<OR:?[,?]...> = '0' if all '?' are '0', else '1'
- $<NOT:?> = '0' if '?' is '1', else '1'
+.. note::
-where '?' is always either '0' or '1'.
+ CMake will generate tests only if the :command:`enable_testing`
+ command has been invoked. The :module:`CTest` module invokes the
+ command automatically when the ``BUILD_TESTING`` option is ``ON``.
-Example usage:
+---------------------------------------------------------------------
::
- add_test(NAME mytest
- COMMAND testDriver --config $<CONFIGURATION>
- --exe $<TARGET_FILE:myexe>)
+ add_test(<name> <command> [<arg>...])
-This creates a test "mytest" whose command runs a testDriver tool
-passing the configuration name and the full path to the executable
-file produced by target "myexe".
+Add a test called ``<name>`` with the given command-line. Unlike
+the above ``NAME`` signature no transformation is performed on the
+command-line to support target names or generator expressions.
diff --git a/Help/command/install.rst b/Help/command/install.rst
index a463a60..47108f0 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -9,43 +9,50 @@ executed in order during installation. The order across directories
is not defined.
There are multiple signatures for this command. Some of them define
-installation properties for files and targets. Properties common to
+installation options for files and targets. Options common to
multiple signatures are covered here but they are valid only for
-signatures that specify them.
-
-DESTINATION arguments specify the directory on disk to which a file
-will be installed. If a full path (with a leading slash or drive
-letter) is given it is used directly. If a relative path is given it
-is interpreted relative to the value of CMAKE_INSTALL_PREFIX. The
-prefix can be relocated at install time using DESTDIR mechanism
-explained in the CMAKE_INSTALL_PREFIX variable documentation.
-
-PERMISSIONS arguments specify permissions for installed files. Valid
-permissions are OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ,
-GROUP_WRITE, GROUP_EXECUTE, WORLD_READ, WORLD_WRITE, WORLD_EXECUTE,
-SETUID, and SETGID. Permissions that do not make sense on certain
-platforms are ignored on those platforms.
-
-The CONFIGURATIONS argument specifies a list of build configurations
-for which the install rule applies (Debug, Release, etc.).
-
-The COMPONENT argument specifies an installation component name with
-which the install rule is associated, such as "runtime" or
-"development". During component-specific installation only install
-rules associated with the given component name will be executed.
-During a full installation all components are installed. If COMPONENT
-is not provided a default component "Unspecified" is created. The
-default component name may be controlled with the
-CMAKE_INSTALL_DEFAULT_COMPONENT_NAME variable.
-
-The RENAME argument specifies a name for an installed file that may be
-different from the original file. Renaming is allowed only when a
-single file is installed by the command.
-
-The OPTIONAL argument specifies that it is not an error if the file to
-be installed does not exist.
-
-The TARGETS signature:
+signatures that specify them. The common options are:
+
+``DESTINATION``
+ Specify the directory on disk to which a file will be installed.
+ If a full path (with a leading slash or drive letter) is given
+ it is used directly. If a relative path is given it is interpreted
+ relative to the value of the :variable:`CMAKE_INSTALL_PREFIX` variable.
+ The prefix can be relocated at install time using the ``DESTDIR``
+ mechanism explained in the :variable:`CMAKE_INSTALL_PREFIX` variable
+ documentation.
+
+``PERMISSIONS``
+ Specify permissions for installed files. Valid permissions are
+ ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, ``GROUP_READ``,
+ ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``WORLD_WRITE``,
+ ``WORLD_EXECUTE``, ``SETUID``, and ``SETGID``. Permissions that do
+ not make sense on certain platforms are ignored on those platforms.
+
+``CONFIGURATIONS``
+ Specify a list of build configurations for which the install rule
+ applies (Debug, Release, etc.).
+
+``COMPONENT``
+ Specify an installation component name with which the install rule
+ is associated, such as "runtime" or "development". During
+ component-specific installation only install rules associated with
+ the given component name will be executed. During a full installation
+ all components are installed. If ``COMPONENT`` is not provided a
+ default component "Unspecified" is created. The default component
+ name may be controlled with the
+ :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable.
+
+``RENAME``
+ Specify a name for an installed file that may be different from the
+ original file. Renaming is allowed only when a single file is
+ installed by the command.
+
+``OPTIONAL``
+ Specify that it is not an error if the file to be installed does
+ not exist.
+
+------------------------------------------------------------------------------
::
@@ -60,118 +67,115 @@ The TARGETS signature:
[OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
] [...])
-The TARGETS form specifies rules for installing targets from a
+The ``TARGETS`` form specifies rules for installing targets from a
project. There are five kinds of target files that may be installed:
-ARCHIVE, LIBRARY, RUNTIME, FRAMEWORK, and BUNDLE. Executables are
-treated as RUNTIME targets, except that those marked with the
-MACOSX_BUNDLE property are treated as BUNDLE targets on OS X. Static
-libraries are always treated as ARCHIVE targets. Module libraries are
-always treated as LIBRARY targets. For non-DLL platforms shared
-libraries are treated as LIBRARY targets, except that those marked
-with the FRAMEWORK property are treated as FRAMEWORK targets on OS X.
-For DLL platforms the DLL part of a shared library is treated as a
-RUNTIME target and the corresponding import library is treated as an
-ARCHIVE target. All Windows-based systems including Cygwin are DLL
-platforms. The ARCHIVE, LIBRARY, RUNTIME, and FRAMEWORK arguments
+``ARCHIVE``, ``LIBRARY``, ``RUNTIME``, ``FRAMEWORK``, and ``BUNDLE``.
+Executables are treated as ``RUNTIME`` targets, except that those
+marked with the ``MACOSX_BUNDLE`` property are treated as ``BUNDLE``
+targets on OS X. Static libraries are always treated as ``ARCHIVE``
+targets. Module libraries are always treated as ``LIBRARY`` targets.
+For non-DLL platforms shared libraries are treated as ``LIBRARY``
+targets, except that those marked with the ``FRAMEWORK`` property are
+treated as ``FRAMEWORK`` targets on OS X. For DLL platforms the DLL
+part of a shared library is treated as a ``RUNTIME`` target and the
+corresponding import library is treated as an ``ARCHIVE`` target.
+All Windows-based systems including Cygwin are DLL platforms.
+The ``ARCHIVE``, ``LIBRARY``, ``RUNTIME``, and ``FRAMEWORK`` arguments
change the type of target to which the subsequent properties apply.
If none is given the installation properties apply to all target
types. If only one is given then only targets of that type will be
installed (which can be used to install just a DLL or just an import
-library).The INCLUDES DESTINATION specifies a list of directories
-which will be added to the INTERFACE_INCLUDE_DIRECTORIES of the
-<targets> when exported by install(EXPORT). If a relative path is
-specified, it is treated as relative to the $<INSTALL_PREFIX>.
-
-The PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE arguments cause
-subsequent properties to be applied to installing a FRAMEWORK shared
-library target's associated files on non-Apple platforms. Rules
+library). The ``INCLUDES DESTINATION`` specifies a list of directories
+which will be added to the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
+target property of the ``<targets>`` when exported by the
+:command:`install(EXPORT)` command. If a relative path is
+specified, it is treated as relative to the ``$<INSTALL_PREFIX>``.
+
+The ``PRIVATE_HEADER``, ``PUBLIC_HEADER``, and ``RESOURCE`` arguments
+cause subsequent properties to be applied to installing a ``FRAMEWORK``
+shared library target's associated files on non-Apple platforms. Rules
defined by these arguments are ignored on Apple platforms because the
associated files are installed into the appropriate locations inside
-the framework folder. See documentation of the PRIVATE_HEADER,
-PUBLIC_HEADER, and RESOURCE target properties for details.
+the framework folder. See documentation of the
+:prop_tgt:`PRIVATE_HEADER`, :prop_tgt:`PUBLIC_HEADER`, and
+:prop_tgt:`RESOURCE` target properties for details.
-Either NAMELINK_ONLY or NAMELINK_SKIP may be specified as a LIBRARY
-option. On some platforms a versioned shared library has a symbolic
-link such as
-
-::
+Either ``NAMELINK_ONLY`` or ``NAMELINK_SKIP`` may be specified as a
+``LIBRARY`` option. On some platforms a versioned shared library
+has a symbolic link such as::
lib<name>.so -> lib<name>.so.1
-where "lib<name>.so.1" is the soname of the library and "lib<name>.so"
+where ``lib<name>.so.1`` is the soname of the library and ``lib<name>.so``
is a "namelink" allowing linkers to find the library when given
-"-l<name>". The NAMELINK_ONLY option causes installation of only the
-namelink when a library target is installed. The NAMELINK_SKIP option
+``-l<name>``. The ``NAMELINK_ONLY`` option causes installation of only the
+namelink when a library target is installed. The ``NAMELINK_SKIP`` option
causes installation of library files other than the namelink when a
library target is installed. When neither option is given both
portions are installed. On platforms where versioned shared libraries
do not have namelinks or when a library is not versioned the
-NAMELINK_SKIP option installs the library and the NAMELINK_ONLY option
-installs nothing. See the VERSION and SOVERSION target properties for
-details on creating versioned shared libraries.
+``NAMELINK_SKIP`` option installs the library and the ``NAMELINK_ONLY``
+option installs nothing. See the :prop_tgt:`VERSION` and
+:prop_tgt:`SOVERSION` target properties for details on creating versioned
+shared libraries.
One or more groups of properties may be specified in a single call to
-the TARGETS form of this command. A target may be installed more than
-once to different locations. Consider hypothetical targets "myExe",
-"mySharedLib", and "myStaticLib". The code
+the ``TARGETS`` form of this command. A target may be installed more than
+once to different locations. Consider hypothetical targets ``myExe``,
+``mySharedLib``, and ``myStaticLib``. The code:
-::
+.. code-block:: cmake
- install(TARGETS myExe mySharedLib myStaticLib
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib/static)
- install(TARGETS mySharedLib DESTINATION /some/full/path)
+ install(TARGETS myExe mySharedLib myStaticLib
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib/static)
+ install(TARGETS mySharedLib DESTINATION /some/full/path)
-will install myExe to <prefix>/bin and myStaticLib to
-<prefix>/lib/static. On non-DLL platforms mySharedLib will be
-installed to <prefix>/lib and /some/full/path. On DLL platforms the
-mySharedLib DLL will be installed to <prefix>/bin and /some/full/path
-and its import library will be installed to <prefix>/lib/static and
-/some/full/path.
+will install ``myExe`` to ``<prefix>/bin`` and ``myStaticLib`` to
+``<prefix>/lib/static``. On non-DLL platforms ``mySharedLib`` will be
+installed to ``<prefix>/lib`` and ``/some/full/path``. On DLL platforms
+the ``mySharedLib`` DLL will be installed to ``<prefix>/bin`` and
+``/some/full/path`` and its import library will be installed to
+``<prefix>/lib/static`` and ``/some/full/path``.
-The EXPORT option associates the installed target files with an export
-called <export-name>. It must appear before any RUNTIME, LIBRARY, or
-ARCHIVE options. To actually install the export file itself, call
-install(EXPORT). See documentation of the install(EXPORT ...)
-signature below for details.
+The ``EXPORT`` option associates the installed target files with an
+export called ``<export-name>``. It must appear before any ``RUNTIME``,
+``LIBRARY``, or ``ARCHIVE`` options. To actually install the export
+file itself, call ``install(EXPORT)``, documented below.
-Installing a target with EXCLUDE_FROM_ALL set to true has undefined
-behavior.
+Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property
+set to ``TRUE`` has undefined behavior.
-The FILES signature:
+------------------------------------------------------------------------------
::
- install(FILES files... DESTINATION <dir>
+ install(<FILES|PROGRAMS> files... DESTINATION <dir>
[PERMISSIONS permissions...]
[CONFIGURATIONS [Debug|Release|...]]
[COMPONENT <component>]
[RENAME <name>] [OPTIONAL])
-The FILES form specifies rules for installing files for a project.
+The ``FILES`` form specifies rules for installing files for a project.
File names given as relative paths are interpreted with respect to the
current source directory. Files installed by this form are by default
-given permissions OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ
-if no PERMISSIONS argument is given.
-
-The PROGRAMS signature:
-
-::
-
- install(PROGRAMS files... DESTINATION <dir>
- [PERMISSIONS permissions...]
- [CONFIGURATIONS [Debug|Release|...]]
- [COMPONENT <component>]
- [RENAME <name>] [OPTIONAL])
+given permissions ``OWNER_WRITE``, ``OWNER_READ``, ``GROUP_READ``, and
+``WORLD_READ`` if no ``PERMISSIONS`` argument is given.
-The PROGRAMS form is identical to the FILES form except that the
-default permissions for the installed file also include OWNER_EXECUTE,
-GROUP_EXECUTE, and WORLD_EXECUTE. This form is intended to install
-programs that are not targets, such as shell scripts. Use the TARGETS
+The ``PROGRAMS`` form is identical to the ``FILES`` form except that the
+default permissions for the installed file also include ``OWNER_EXECUTE``,
+``GROUP_EXECUTE``, and ``WORLD_EXECUTE``. This form is intended to install
+programs that are not targets, such as shell scripts. Use the ``TARGETS``
form to install targets built within the project.
-The DIRECTORY signature:
+The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
+"generator expressions" with the syntax ``$<...>``. See the
+:manual:`cmake-generator-expressions(7)` manual for available expressions.
+However, if any item begins in a generator expression it must evaluate
+to a full path.
+
+------------------------------------------------------------------------------
::
@@ -184,7 +188,7 @@ The DIRECTORY signature:
[[PATTERN <pattern> | REGEX <regex>]
[EXCLUDE] [PERMISSIONS permissions...]] [...])
-The DIRECTORY form installs contents of one or more directories to a
+The ``DIRECTORY`` form installs contents of one or more directories to a
given destination. The directory structure is copied verbatim to the
destination. The last component of each directory name is appended to
the destination directory but a trailing slash may be used to avoid
@@ -192,45 +196,45 @@ this because it leaves the last component empty. Directory names
given as relative paths are interpreted with respect to the current
source directory. If no input directory names are given the
destination directory will be created but nothing will be installed
-into it. The FILE_PERMISSIONS and DIRECTORY_PERMISSIONS options
+into it. The ``FILE_PERMISSIONS`` and ``DIRECTORY_PERMISSIONS`` options
specify permissions given to files and directories in the destination.
-If USE_SOURCE_PERMISSIONS is specified and FILE_PERMISSIONS is not,
+If ``USE_SOURCE_PERMISSIONS`` is specified and ``FILE_PERMISSIONS`` is not,
file permissions will be copied from the source directory structure.
If no permissions are specified files will be given the default
-permissions specified in the FILES form of the command, and the
+permissions specified in the ``FILES`` form of the command, and the
directories will be given the default permissions specified in the
-PROGRAMS form of the command.
+``PROGRAMS`` form of the command.
Installation of directories may be controlled with fine granularity
-using the PATTERN or REGEX options. These "match" options specify a
+using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
globbing pattern or regular expression to match directories or files
encountered within input directories. They may be used to apply
certain options (see below) to a subset of the files and directories
encountered. The full path to each input file or directory (with
-forward slashes) is matched against the expression. A PATTERN will
+forward slashes) is matched against the expression. A ``PATTERN`` will
match only complete file names: the portion of the full path matching
the pattern must occur at the end of the file name and be preceded by
-a slash. A REGEX will match any portion of the full path but it may
-use '/' and '$' to simulate the PATTERN behavior. By default all
+a slash. A ``REGEX`` will match any portion of the full path but it may
+use ``/`` and ``$`` to simulate the ``PATTERN`` behavior. By default all
files and directories are installed whether or not they are matched.
-The FILES_MATCHING option may be given before the first match option
+The ``FILES_MATCHING`` option may be given before the first match option
to disable installation of files (but not directories) not matched by
any expression. For example, the code
-::
+.. code-block:: cmake
install(DIRECTORY src/ DESTINATION include/myproj
FILES_MATCHING PATTERN "*.h")
will extract and install header files from a source tree.
-Some options may follow a PATTERN or REGEX expression and are applied
-only to files or directories matching them. The EXCLUDE option will
-skip the matched file or directory. The PERMISSIONS option overrides
+Some options may follow a ``PATTERN`` or ``REGEX`` expression and are applied
+only to files or directories matching them. The ``EXCLUDE`` option will
+skip the matched file or directory. The ``PERMISSIONS`` option overrides
the permissions setting for the matched file or directory. For
example the code
-::
+.. code-block:: cmake
install(DIRECTORY icons scripts/ DESTINATION share/myproj
PATTERN "CVS" EXCLUDE
@@ -238,31 +242,31 @@ example the code
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ)
-will install the icons directory to share/myproj/icons and the scripts
-directory to share/myproj. The icons will get default file
-permissions, the scripts will be given specific permissions, and any
-CVS directories will be excluded.
+will install the ``icons`` directory to ``share/myproj/icons`` and the
+``scripts`` directory to ``share/myproj``. The icons will get default
+file permissions, the scripts will be given specific permissions, and any
+``CVS`` directories will be excluded.
-The SCRIPT and CODE signature:
+------------------------------------------------------------------------------
::
install([[SCRIPT <file>] [CODE <code>]] [...])
-The SCRIPT form will invoke the given CMake script files during
+The ``SCRIPT`` form will invoke the given CMake script files during
installation. If the script file name is a relative path it will be
-interpreted with respect to the current source directory. The CODE
+interpreted with respect to the current source directory. The ``CODE``
form will invoke the given CMake code during installation. Code is
specified as a single argument inside a double-quoted string. For
example, the code
-::
+.. code-block:: cmake
install(CODE "MESSAGE(\"Sample install message.\")")
will print a message during installation.
-The EXPORT signature:
+------------------------------------------------------------------------------
::
@@ -273,44 +277,47 @@ The EXPORT signature:
[EXPORT_LINK_INTERFACE_LIBRARIES]
[COMPONENT <component>])
-The EXPORT form generates and installs a CMake file containing code to
+The ``EXPORT`` form generates and installs a CMake file containing code to
import targets from the installation tree into another project.
-Target installations are associated with the export <export-name>
-using the EXPORT option of the install(TARGETS ...) signature
-documented above. The NAMESPACE option will prepend <namespace> to
+Target installations are associated with the export ``<export-name>``
+using the ``EXPORT`` option of the ``install(TARGETS)`` signature
+documented above. The ``NAMESPACE`` option will prepend ``<namespace>`` to
the target names as they are written to the import file. By default
-the generated file will be called <export-name>.cmake but the FILE
+the generated file will be called ``<export-name>.cmake`` but the ``FILE``
option may be used to specify a different name. The value given to
-the FILE option must be a file name with the ".cmake" extension. If a
-CONFIGURATIONS option is given then the file will only be installed
+the ``FILE`` option must be a file name with the ``.cmake`` extension.
+If a ``CONFIGURATIONS`` option is given then the file will only be installed
when one of the named configurations is installed. Additionally, the
generated import file will reference only the matching target
-configurations. The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if
+configurations. The ``EXPORT_LINK_INTERFACE_LIBRARIES`` keyword, if
present, causes the contents of the properties matching
``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
-policy CMP0022 is NEW. If a COMPONENT option is specified that does
-not match that given to the targets associated with <export-name> the
-behavior is undefined. If a library target is included in the export
-but a target to which it links is not included the behavior is
-unspecified.
+policy :policy:`CMP0022` is ``NEW``. If a ``COMPONENT`` option is
+specified that does not match that given to the targets associated with
+``<export-name>`` the behavior is undefined. If a library target is
+included in the export but a target to which it links is not included
+the behavior is unspecified.
-The EXPORT form is useful to help outside projects use targets built
+The ``EXPORT`` form is useful to help outside projects use targets built
and installed by the current project. For example, the code
-::
+.. code-block:: cmake
install(TARGETS myexe EXPORT myproj DESTINATION bin)
install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)
-will install the executable myexe to <prefix>/bin and code to import
-it in the file "<prefix>/lib/myproj/myproj.cmake". An outside project
-may load this file with the include command and reference the myexe
+will install the executable myexe to ``<prefix>/bin`` and code to import
+it in the file ``<prefix>/lib/myproj/myproj.cmake``. An outside project
+may load this file with the include command and reference the ``myexe``
executable from the installation tree using the imported target name
-mp_myexe as if the target were built in its own tree.
-
-NOTE: This command supercedes the INSTALL_TARGETS command and the
-target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. It also
-replaces the FILES forms of the INSTALL_FILES and INSTALL_PROGRAMS
-commands. The processing order of these install rules relative to
-those generated by INSTALL_TARGETS, INSTALL_FILES, and
-INSTALL_PROGRAMS commands is not defined.
+``mp_myexe`` as if the target were built in its own tree.
+
+.. note::
+ This command supercedes the :command:`install_targets` command and
+ the :prop_tgt:`PRE_INSTALL_SCRIPT` and :prop_tgt:`POST_INSTALL_SCRIPT`
+ target properties. It also replaces the ``FILES`` forms of the
+ :command:`install_files` and :command:`install_programs` commands.
+ The processing order of these install rules relative to
+ those generated by :command:`install_targets`,
+ :command:`install_files`, and :command:`install_programs` commands
+ is not defined.
diff --git a/Help/release/3.0.0.rst b/Help/release/3.0.0.rst
index 208e92a..ee8417c 100644
--- a/Help/release/3.0.0.rst
+++ b/Help/release/3.0.0.rst
@@ -102,6 +102,10 @@ Commands
configuration because it will not be available.
Use :ref:`Alias Targets` instead. See policy :policy:`CMP0024`.
+* The :command:`install(FILES)` command learned to support
+ :manual:`generator expressions <cmake-generator-expressions(7)>`
+ in the list of files.
+
* The :command:`project` command learned to set some version variables
to values specified by the new ``VERSION`` option or to empty strings.
See policy :policy:`CMP0048`.
diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake
index 0f1f56d..08c4990 100644
--- a/Modules/CMakeFindDependencyMacro.cmake
+++ b/Modules/CMakeFindDependencyMacro.cmake
@@ -29,29 +29,34 @@
macro(find_dependency dep)
if (NOT ${dep}_FOUND)
- if (${ARGV1})
- set(version ${ARGV1})
+ set(cmake_fd_version)
+ if (${ARGC} GREATER 1)
+ set(cmake_fd_version ${ARGV1})
endif()
- set(exact_arg)
+ set(cmake_fd_exact_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
- set(exact_arg EXACT)
+ set(cmake_fd_exact_arg EXACT)
endif()
- set(quiet_arg)
+ set(cmake_fd_quiet_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
- set(quiet_arg QUIET)
+ set(cmake_fd_quiet_arg QUIET)
endif()
- set(required_arg)
+ set(cmake_fd_required_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
- set(required_arg REQUIRED)
+ set(cmake_fd_required_arg REQUIRED)
endif()
- get_property(alreadyTransitive GLOBAL PROPERTY
+ get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY
)
- find_package(${dep} ${version} ${exact_arg} ${quiet_arg} ${required_arg})
+ find_package(${dep} ${version}
+ ${cmake_fd_exact_arg}
+ ${cmake_fd_quiet_arg}
+ ${cmake_fd_required_arg}
+ )
- if(NOT DEFINED alreadyTransitive OR alreadyTransitive)
+ if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
endif()
@@ -60,8 +65,8 @@ macro(find_dependency dep)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
return()
endif()
- set(required_arg)
- set(quiet_arg)
- set(exact_arg)
+ set(cmake_fd_required_arg)
+ set(cmake_fd_quiet_arg)
+ set(cmake_fd_exact_arg)
endif()
endmacro()
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 0df51a8..1e83163 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -54,6 +54,7 @@
# [BINARY_DIR dir] # Specify build dir location
# [BUILD_COMMAND cmd...] # Command to drive the native build
# [BUILD_IN_SOURCE 1] # Use source dir for build dir
+# [BUILD_ALWAYS 1] # No stamp file, build step always runs
# #--Install step---------------
# [INSTALL_DIR dir] # Installation prefix
# [INSTALL_COMMAND cmd...] # Command to drive install after build
@@ -1716,10 +1717,18 @@ function(_ep_add_build_command name)
set(log "")
endif()
+ get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS)
+ if(build_always)
+ set(always 1)
+ else()
+ set(always 0)
+ endif()
+
ExternalProject_Add_Step(${name} build
COMMAND ${cmd}
WORKING_DIRECTORY ${binary_dir}
DEPENDEES configure
+ ALWAYS ${always}
${log}
)
endfunction()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 0c481ad..56e5b81 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 0)
-set(CMake_VERSION_PATCH 20140221)
+set(CMake_VERSION_PATCH 20140225)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 7036992..bdefcfb 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -800,7 +800,7 @@ static const char* targetPropertyTransitiveWhitelist[] = {
#undef TRANSITIVE_PROPERTY_NAME
-std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
cmTarget const* target,
cmTarget const* headTarget,
cmGeneratorExpressionContext *context,
@@ -811,23 +811,21 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
std::string sep;
std::string depString;
- for (std::vector<std::string>::const_iterator
- it = libraries.begin();
- it != libraries.end(); ++it)
+ for (std::vector<cmTarget*>::const_iterator
+ it = targets.begin();
+ it != targets.end(); ++it)
{
- if (*it == target->GetName())
+ if (*it == target)
{
// Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a
// self-referencing loop.
continue;
}
- if (context->Makefile->FindTargetToUse(*it))
- {
- depString +=
- sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">";
- sep = ";";
- }
+ depString +=
+ sep + "$<TARGET_PROPERTY:" +
+ (*it)->GetName() + "," + interfacePropertyName + ">";
+ sep = ";";
}
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
@@ -843,6 +841,27 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
return linkedTargetsContent;
}
+std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+ cmTarget const* target,
+ cmTarget const* headTarget,
+ cmGeneratorExpressionContext *context,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string &interfacePropertyName)
+{
+ std::vector<cmTarget*> tgts;
+ for (std::vector<std::string>::const_iterator
+ it = libraries.begin();
+ it != libraries.end(); ++it)
+ {
+ if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it))
+ {
+ tgts.push_back(tgt);
+ }
+ }
+ return getLinkedTargetsContent(tgts, target, headTarget, context,
+ dagChecker, interfacePropertyName);
+}
+
//----------------------------------------------------------------------------
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
@@ -1065,13 +1084,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmStrCmp(propertyName)) != transEnd)
{
- std::vector<std::string> libs;
- target->GetTransitivePropertyLinkLibraries(context->Config,
- headTarget, libs);
- if (!libs.empty())
+ std::vector<cmTarget*> tgts;
+ target->GetTransitivePropertyTargets(context->Config,
+ headTarget, tgts);
+ if (!tgts.empty())
{
linkedTargetsContent =
- getLinkedTargetsContent(libs, target,
+ getLinkedTargetsContent(tgts, target,
headTarget,
context, &dagChecker,
interfacePropertyName);
@@ -1080,9 +1099,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
else if (std::find_if(transBegin, transEnd,
cmStrCmp(interfacePropertyName)) != transEnd)
{
- const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
- context->Config,
- headTarget);
+ const cmTarget::LinkImplementation *impl
+ = target->GetLinkImplementationLibraries(context->Config,
+ headTarget);
if(impl)
{
linkedTargetsContent =
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 175bb0e..a7b2fb6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -25,7 +25,196 @@
#include "assert.h"
//----------------------------------------------------------------------------
-cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
+void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
+ cmTarget *target, cmake *cm)
+{
+ if(!badObjLib.empty())
+ {
+ cmOStringStream e;
+ e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
+ for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
+ i != badObjLib.end(); ++i)
+ {
+ e << " " << (*i)->GetLocation().GetName() << "\n";
+ }
+ e << "but may contain only headers and sources that compile.";
+ cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ target->GetBacktrace());
+ }
+}
+
+struct ObjectSourcesTag {};
+struct CustomCommandsTag {};
+struct ExtraSourcesTag {};
+struct HeaderSourcesTag {};
+struct ExternalObjectsTag {};
+struct IDLSourcesTag {};
+struct ResxTag {};
+struct ModuleDefinitionFileTag {};
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1310
+template<typename Tag, typename OtherTag>
+struct IsSameTag
+{
+ enum {
+ Result = false
+ };
+};
+
+template<typename Tag>
+struct IsSameTag<Tag, Tag>
+{
+ enum {
+ Result = true
+ };
+};
+#else
+struct IsSameTagBase
+{
+ typedef char (&no_type)[1];
+ typedef char (&yes_type)[2];
+ template<typename T> struct Check;
+ template<typename T> static yes_type check(Check<T>*, Check<T>*);
+ static no_type check(...);
+};
+template<typename Tag1, typename Tag2>
+struct IsSameTag: public IsSameTagBase
+{
+ enum {
+ Result = (sizeof(check(static_cast< Check<Tag1>* >(0),
+ static_cast< Check<Tag2>* >(0))) ==
+ sizeof(yes_type))
+ };
+};
+#endif
+
+template<bool>
+struct DoAccept
+{
+ template <typename T> static void Do(T&, cmSourceFile*) {}
+};
+
+template<>
+struct DoAccept<true>
+{
+ static void Do(std::vector<cmSourceFile*>& files, cmSourceFile* f)
+ {
+ files.push_back(f);
+ }
+ static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f)
+ {
+ // Build and save the name of the corresponding .h file
+ // This relationship will be used later when building the project files.
+ // Both names would have been auto generated from Visual Studio
+ // where the user supplied the file name and Visual Studio
+ // appended the suffix.
+ std::string resx = f->GetFullPath();
+ std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
+ data.ExpectedResxHeaders.insert(hFileName);
+ data.ResxSources.push_back(f);
+ }
+ static void Do(std::string& data, cmSourceFile* f)
+ {
+ data = f->GetFullPath();
+ }
+};
+
+//----------------------------------------------------------------------------
+template<typename Tag, typename DataType = std::vector<cmSourceFile*> >
+struct TagVisitor
+{
+ DataType& Data;
+ std::vector<cmSourceFile*> BadObjLibFiles;
+ cmTarget *Target;
+ cmGlobalGenerator *GlobalGenerator;
+ cmsys::RegularExpression Header;
+ bool IsObjLib;
+
+ TagVisitor(cmTarget *target, DataType& data)
+ : Data(data), Target(target),
+ GlobalGenerator(target->GetMakefile()
+ ->GetLocalGenerator()->GetGlobalGenerator()),
+ Header(CM_HEADER_REGEX),
+ IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY)
+ {
+ }
+
+ ~TagVisitor()
+ {
+ reportBadObjLib(this->BadObjLibFiles, this->Target,
+ this->GlobalGenerator->GetCMakeInstance());
+ }
+
+ void Accept(cmSourceFile *sf)
+ {
+ std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
+ if(sf->GetCustomCommand())
+ {
+ DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->Target->GetType() == cmTarget::UTILITY)
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
+ {
+ DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
+ {
+ DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(sf->GetLanguage())
+ {
+ DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(ext == "def")
+ {
+ DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data,
+ sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(ext == "idl")
+ {
+ DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(ext == "resx")
+ {
+ DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->Header.find(sf->GetFullPath().c_str()))
+ {
+ DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib && ext != "txt")
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t),
+ SourceFileFlagsConstructed(false)
{
this->Makefile = this->Target->GetMakefile();
this->LocalGenerator = this->Makefile->GetLocalGenerator();
@@ -62,19 +251,12 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const
return 0;
}
-static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
+static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
const char *config, cmTarget *headTarget,
cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::string>& result,
bool excludeImported)
{
- cmTarget* depTgt = mf->FindTargetToUse(name);
-
- if (!depTgt)
- {
- return;
- }
-
cmListFileBacktrace lfbt;
if (const char* dirs =
@@ -102,11 +284,34 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
}
}
+#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
+ { \
+ std::vector<cmSourceFile*> sourceFiles; \
+ this->Target->GetSourceFiles(sourceFiles); \
+ TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \
+ for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
+ si != sourceFiles.end(); ++si) \
+ { \
+ visitor.Accept(*si); \
+ } \
+ } \
+
+
+#define IMPLEMENT_VISIT(DATA) \
+ IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \
+
+#define EMPTY
+#define COMMA ,
+
//----------------------------------------------------------------------------
void
-cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const
+cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &data) const
{
- objs = this->ObjectSources;
+ IMPLEMENT_VISIT(ObjectSources);
+ if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY)
+ {
+ this->ObjectSources = data;
+ }
}
//----------------------------------------------------------------------------
@@ -135,49 +340,53 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& data) const
{
- srcs = this->ResxSources;
+ IMPLEMENT_VISIT(IDLSources);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const
+void
+cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& data) const
{
- srcs = this->IDLSources;
+ IMPLEMENT_VISIT(HeaderSources);
}
//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& data) const
{
- srcs = this->HeaderSources;
+ IMPLEMENT_VISIT(ExtraSources);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const
+void
+cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& data) const
{
- srcs = this->ExtraSources;
+ IMPLEMENT_VISIT(CustomCommands);
}
//----------------------------------------------------------------------------
void
-cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const
+cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& data) const
{
- srcs = this->CustomCommands;
+ IMPLEMENT_VISIT(ExternalObjects);
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const
{
- srcs = this->ExpectedResxHeaders;
+ ResxData data;
+ IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+ srcs = data.ExpectedResxHeaders;
}
//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const
{
- srcs = this->ExternalObjects;
+ ResxData data;
+ IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+ srcs = data.ResxSources;
}
//----------------------------------------------------------------------------
@@ -224,26 +433,25 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
&dagChecker), result);
}
- std::set<cmStdString> uniqueDeps;
+ std::set<cmTarget*> uniqueDeps;
for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
li != impl->Libraries.end(); ++li)
{
- if (uniqueDeps.insert(*li).second)
+ cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
+ if (!tgt)
{
- cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
-
- if (!tgt)
- {
- continue;
- }
+ continue;
+ }
- handleSystemIncludesDep(this->Makefile, *li, config, this->Target,
+ if (uniqueDeps.insert(tgt).second)
+ {
+ handleSystemIncludesDep(this->Makefile, tgt, config, this->Target,
&dagChecker, result, excludeImported);
- std::vector<std::string> deps;
- tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps);
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitivePropertyTargets(config, this->Target, deps);
- for(std::vector<std::string>::const_iterator di = deps.begin();
+ for(std::vector<cmTarget*>::const_iterator di = deps.begin();
di != deps.end(); ++di)
{
if (uniqueDeps.insert(*di).second)
@@ -290,102 +498,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::ClassifySources()
-{
- cmsys::RegularExpression header(CM_HEADER_REGEX);
-
- cmTarget::TargetType targetType = this->Target->GetType();
- bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY;
-
- std::vector<cmSourceFile*> badObjLib;
- std::vector<cmSourceFile*> sources;
- this->Target->GetSourceFiles(sources);
- for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
- if(sf->GetCustomCommand())
- {
- this->CustomCommands.push_back(sf);
- }
- else if(targetType == cmTarget::UTILITY)
- {
- this->ExtraSources.push_back(sf);
- }
- else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
- {
- this->HeaderSources.push_back(sf);
- }
- else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
- {
- this->ExternalObjects.push_back(sf);
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(sf->GetLanguage())
- {
- this->ObjectSources.push_back(sf);
- }
- else if(ext == "def")
- {
- this->ModuleDefinitionFile = sf->GetFullPath();
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(ext == "idl")
- {
- this->IDLSources.push_back(sf);
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(ext == "resx")
- {
- // Build and save the name of the corresponding .h file
- // This relationship will be used later when building the project files.
- // Both names would have been auto generated from Visual Studio
- // where the user supplied the file name and Visual Studio
- // appended the suffix.
- std::string resx = sf->GetFullPath();
- std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
- this->ExpectedResxHeaders.insert(hFileName);
- this->ResxSources.push_back(sf);
- }
- else if(header.find(sf->GetFullPath().c_str()))
- {
- this->HeaderSources.push_back(sf);
- }
- else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
- {
- // We only get here if a source file is not an external object
- // and has an extension that is listed as an ignored file type.
- // No message or diagnosis should be given.
- this->ExtraSources.push_back(sf);
- }
- else
- {
- this->ExtraSources.push_back(sf);
- if(isObjLib && ext != "txt")
- {
- badObjLib.push_back(sf);
- }
- }
- }
-
- if(!badObjLib.empty())
- {
- cmOStringStream e;
- e << "OBJECT library \"" << this->Target->GetName() << "\" contains:\n";
- for(std::vector<cmSourceFile*>::iterator i = badObjLib.begin();
- i != badObjLib.end(); ++i)
- {
- e << " " << (*i)->GetLocation().GetName() << "\n";
- }
- e << "but may contain only headers and sources that compile.";
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->Target->GetBacktrace());
- }
-}
-
-//----------------------------------------------------------------------------
void cmGeneratorTarget::LookupObjectLibraries()
{
std::vector<std::string> const& objLibs =
@@ -438,6 +550,14 @@ void cmGeneratorTarget::LookupObjectLibraries()
}
//----------------------------------------------------------------------------
+std::string cmGeneratorTarget::GetModuleDefinitionFile() const
+{
+ std::string data;
+ IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string)
+ return data;
+}
+
+//----------------------------------------------------------------------------
void
cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
{
@@ -876,3 +996,97 @@ bool cmStrictTargetComparison::operator()(cmTarget const* t1,
}
return nameResult < 0;
}
+
+//----------------------------------------------------------------------------
+struct cmGeneratorTarget::SourceFileFlags
+cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
+{
+ struct SourceFileFlags flags;
+ this->ConstructSourceFileFlags();
+ std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
+ this->SourceFlagsMap.find(sf);
+ if(si != this->SourceFlagsMap.end())
+ {
+ flags = si->second;
+ }
+ else
+ {
+ // Handle the MACOSX_PACKAGE_LOCATION property on source files that
+ // were not listed in one of the other lists.
+ if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
+ {
+ flags.MacFolder = location;
+ if(strcmp(location, "Resources") == 0)
+ {
+ flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+ }
+ else
+ {
+ flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
+ }
+ }
+ }
+ return flags;
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ConstructSourceFileFlags() const
+{
+ if(this->SourceFileFlagsConstructed)
+ {
+ return;
+ }
+ this->SourceFileFlagsConstructed = true;
+
+ // Process public headers to mark the source files.
+ if(const char* files = this->Target->GetProperty("PUBLIC_HEADER"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "Headers";
+ flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
+ }
+ }
+ }
+
+ // Process private headers after public headers so that they take
+ // precedence if a file is listed in both.
+ if(const char* files = this->Target->GetProperty("PRIVATE_HEADER"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "PrivateHeaders";
+ flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
+ }
+ }
+ }
+
+ // Mark sources listed as resources.
+ if(const char* files = this->Target->GetProperty("RESOURCE"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "Resources";
+ flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+ }
+ }
+ }
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index a4caba1..1e6ce64 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -52,7 +52,7 @@ public:
cmLocalGenerator* LocalGenerator;
cmGlobalGenerator const* GlobalGenerator;
- std::string ModuleDefinitionFile;
+ std::string GetModuleDefinitionFile() const;
/** Full path with trailing slash to the top-level directory
holding object files for this target. Includes the build
@@ -82,31 +82,56 @@ public:
*/
void TraceDependencies();
- void ClassifySources();
void LookupObjectLibraries();
/** Get sources that must be built before the given source. */
std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const;
+ /**
+ * Flags for a given source file as used in this target. Typically assigned
+ * via SET_TARGET_PROPERTIES when the property is a list of source files.
+ */
+ enum SourceFileType
+ {
+ SourceFileTypeNormal,
+ SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
+ SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
+ SourceFileTypeResource, // is in "RESOURCE" target property *or*
+ // has MACOSX_PACKAGE_LOCATION=="Resources"
+ SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
+ };
+ struct SourceFileFlags
+ {
+ SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
+ SourceFileFlags(SourceFileFlags const& r):
+ Type(r.Type), MacFolder(r.MacFolder) {}
+ SourceFileType Type;
+ const char* MacFolder; // location inside Mac content folders
+ };
+
+ struct SourceFileFlags
+ GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+
+ struct ResxData {
+ mutable std::set<std::string> ExpectedResxHeaders;
+ mutable std::vector<cmSourceFile*> ResxSources;
+ };
private:
friend class cmTargetTraceDependencies;
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
SourceEntriesType SourceEntries;
- std::vector<cmSourceFile*> CustomCommands;
- std::vector<cmSourceFile*> ExtraSources;
- std::vector<cmSourceFile*> HeaderSources;
- std::vector<cmSourceFile*> ExternalObjects;
- std::vector<cmSourceFile*> IDLSources;
- std::vector<cmSourceFile*> ResxSources;
std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
- std::set<std::string> ExpectedResxHeaders;
- std::vector<cmSourceFile*> ObjectSources;
+ mutable std::vector<cmSourceFile*> ObjectSources;
std::vector<cmTarget*> ObjectLibraries;
mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
+ void ConstructSourceFileFlags() const;
+ mutable bool SourceFileFlagsConstructed;
+ mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
+
cmGeneratorTarget(cmGeneratorTarget const&);
void operator=(cmGeneratorTarget const&);
};
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 4f3328d..f76c6d1 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1148,12 +1148,6 @@ void cmGlobalGenerator::Generate()
return;
}
- // Check that all targets are valid.
- if(!this->CheckTargets())
- {
- return;
- }
-
this->FinalizeTargetCompileInfo();
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1306,35 +1300,6 @@ bool cmGlobalGenerator::ComputeTargetDepends()
}
//----------------------------------------------------------------------------
-bool cmGlobalGenerator::CheckTargets()
-{
- // Make sure all targets can find their source files.
- for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
- {
- cmTargets& targets =
- this->LocalGenerators[i]->GetMakefile()->GetTargets();
- for(cmTargets::iterator ti = targets.begin();
- ti != targets.end(); ++ti)
- {
- cmTarget& target = ti->second;
- if(target.GetType() == cmTarget::EXECUTABLE ||
- target.GetType() == cmTarget::STATIC_LIBRARY ||
- target.GetType() == cmTarget::SHARED_LIBRARY ||
- target.GetType() == cmTarget::MODULE_LIBRARY ||
- target.GetType() == cmTarget::OBJECT_LIBRARY ||
- target.GetType() == cmTarget::UTILITY)
- {
- if(!target.FindSourceFiles())
- {
- return false;
- }
- }
- }
- }
- return true;
-}
-
-//----------------------------------------------------------------------------
void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1474,7 +1439,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
continue;
}
cmGeneratorTarget* gt = ti->second;
- gt->ClassifySources();
gt->LookupObjectLibraries();
this->ComputeTargetObjects(gt);
}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 753eebf..b66f01e 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -340,7 +340,6 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
- bool CheckTargets();
typedef std::vector<std::pair<cmQtAutoGenerators,
cmTarget const*> > AutogensType;
void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 484b28f..004f7ac 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -713,22 +713,23 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
// Is this a resource file in this target? Add it to the resources group...
//
- cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf);
- bool isResource = (tsFlags.Type == cmTarget::SourceFileTypeResource);
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf);
+ bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource;
// Is this a "private" or "public" framework header file?
// Set the ATTRIBUTES attribute appropriately...
//
if(cmtarget.IsFrameworkOnApple())
{
- if(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader)
+ if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader)
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Private"));
settings->AddAttribute("ATTRIBUTES", attrs);
isResource = true;
}
- else if(tsFlags.Type == cmTarget::SourceFileTypePublicHeader)
+ else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader)
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Public"));
@@ -973,6 +974,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{
cmTarget& cmtarget = l->second;
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
// make sure ALL_BUILD, INSTALL, etc are only done once
if(this->SpecialTargetEmitted(l->first.c_str()))
@@ -1011,8 +1013,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
cmXCodeObject* filetype =
fr->GetObject()->GetObject("explicitFileType");
- cmTarget::SourceFileFlags tsFlags =
- cmtarget.GetTargetSourceFileFlags(*i);
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(*i);
if(filetype &&
strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
@@ -1020,12 +1022,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
externalObjFiles.push_back(xsf);
}
else if(this->IsHeaderFile(*i) ||
- (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) ||
- (tsFlags.Type == cmTarget::SourceFileTypePublicHeader))
+ (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
+ (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader))
{
headerFiles.push_back(xsf);
}
- else if(tsFlags.Type == cmTarget::SourceFileTypeResource)
+ else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource)
{
resourceFiles.push_back(xsf);
}
@@ -1048,7 +1050,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// the externalObjFiles above, except each one is not a cmSourceFile
// within the target.)
std::vector<std::string> objs;
- this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+ gtgt->UseObjectLibraries(objs);
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
@@ -1138,9 +1140,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
{
- cmTarget::SourceFileFlags tsFlags =
- cmtarget.GetTargetSourceFileFlags(*i);
- if(tsFlags.Type == cmTarget::SourceFileTypeMacContent)
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(*i);
+ if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent)
{
bundleFiles[tsFlags.MacFolder].push_back(*i);
}
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 6f2dd65..0878aae 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -32,10 +32,12 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
}
static cmInstallFilesGenerator* CreateInstallFilesGenerator(
+ cmMakefile* mf,
const std::vector<std::string>& absFiles,
const cmInstallCommandArguments& args, bool programs)
{
- return new cmInstallFilesGenerator(absFiles, args.GetDestination().c_str(),
+ return new cmInstallFilesGenerator(mf,
+ absFiles, args.GetDestination().c_str(),
programs, args.GetPermissions().c_str(),
args.GetConfigurations(), args.GetComponent().c_str(),
args.GetRename().c_str(), args.GetOptional());
@@ -668,7 +670,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!privateHeaderArgs.GetDestination().empty())
{
privateHeaderGenerator =
- CreateInstallFilesGenerator(absFiles, privateHeaderArgs, false);
+ CreateInstallFilesGenerator(this->Makefile, absFiles,
+ privateHeaderArgs, false);
}
else
{
@@ -694,7 +697,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!publicHeaderArgs.GetDestination().empty())
{
publicHeaderGenerator =
- CreateInstallFilesGenerator(absFiles, publicHeaderArgs, false);
+ CreateInstallFilesGenerator(this->Makefile, absFiles,
+ publicHeaderArgs, false);
}
else
{
@@ -719,8 +723,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Create the files install generator.
if (!resourceArgs.GetDestination().empty())
{
- resourceGenerator = CreateInstallFilesGenerator(absFiles,
- resourceArgs, false);
+ resourceGenerator = CreateInstallFilesGenerator(
+ this->Makefile, absFiles, resourceArgs, false);
}
else
{
@@ -888,7 +892,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// Create the files install generator.
this->Makefile->AddInstallGenerator(
- CreateInstallFilesGenerator(absFiles, ica, programs));
+ CreateInstallFilesGenerator(this->Makefile, absFiles, ica, programs));
//Tell the global generator about any installation component names specified.
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
@@ -1351,7 +1355,8 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
++fileIt)
{
std::string file = (*fileIt);
- if(!cmSystemTools::FileIsFullPath(file.c_str()))
+ std::string::size_type gpos = cmGeneratorExpression::Find(file);
+ if(gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str()))
{
file = this->Makefile->GetCurrentDirectory();
file += "/";
@@ -1359,7 +1364,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
}
// Make sure the file is not a directory.
- if(cmSystemTools::FileIsDirectory(file.c_str()))
+ if(gpos == file.npos && cmSystemTools::FileIsDirectory(file.c_str()))
{
cmOStringStream e;
e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index cc62c4b..488d486 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -133,7 +133,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
- new cmInstallFilesGenerator(this->Files,
+ new cmInstallFilesGenerator(this->Makefile, this->Files,
destination.c_str(), false,
no_permissions, no_configurations,
no_component.c_str(), no_rename));
@@ -148,7 +148,8 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
*/
std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
{
- if(cmSystemTools::FileIsFullPath(name))
+ if(cmSystemTools::FileIsFullPath(name) ||
+ cmGeneratorExpression::Find(name) == 0)
{
// This is a full path.
return name;
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index ec02bc7..ec15044 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -11,9 +11,13 @@
============================================================================*/
#include "cmInstallFilesGenerator.h"
+#include "cmGeneratorExpression.h"
+#include "cmSystemTools.h"
+
//----------------------------------------------------------------------------
cmInstallFilesGenerator
-::cmInstallFilesGenerator(std::vector<std::string> const& files,
+::cmInstallFilesGenerator(cmMakefile* mf,
+ std::vector<std::string> const& files,
const char* dest, bool programs,
const char* file_permissions,
std::vector<std::string> const& configurations,
@@ -21,10 +25,20 @@ cmInstallFilesGenerator
const char* rename,
bool optional):
cmInstallGenerator(dest, configurations, component),
+ Makefile(mf),
Files(files), Programs(programs),
FilePermissions(file_permissions),
Rename(rename), Optional(optional)
{
+ // We need per-config actions if any files have generator expressions.
+ for(std::vector<std::string>::const_iterator i = files.begin();
+ !this->ActionsPerConfig && i != files.end(); ++i)
+ {
+ if(cmGeneratorExpression::Find(*i) != std::string::npos)
+ {
+ this->ActionsPerConfig = true;
+ }
+ }
}
//----------------------------------------------------------------------------
@@ -34,8 +48,9 @@ cmInstallFilesGenerator
}
//----------------------------------------------------------------------------
-void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
- Indent const& indent)
+void cmInstallFilesGenerator::AddFilesInstallRule(
+ std::ostream& os, Indent const& indent,
+ std::vector<std::string> const& files)
{
// Write code to install the files.
const char* no_dir_permissions = 0;
@@ -43,8 +58,40 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
(this->Programs
? cmInstallType_PROGRAMS
: cmInstallType_FILES),
- this->Files,
+ files,
this->Optional,
this->FilePermissions.c_str(), no_dir_permissions,
this->Rename.c_str(), 0, indent);
}
+
+//----------------------------------------------------------------------------
+void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
+ Indent const& indent)
+{
+ if(this->ActionsPerConfig)
+ {
+ this->cmInstallGenerator::GenerateScriptActions(os, indent);
+ }
+ else
+ {
+ this->AddFilesInstallRule(os, indent, this->Files);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
+ const char* config,
+ Indent const& indent)
+{
+ std::vector<std::string> files;
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
+ for(std::vector<std::string>::const_iterator i = this->Files.begin();
+ i != this->Files.end(); ++i)
+ {
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
+ cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config),
+ files);
+ }
+ this->AddFilesInstallRule(os, indent, files);
+}
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 871335c..9dea296 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -14,13 +14,16 @@
#include "cmInstallGenerator.h"
+class cmMakefile;
+
/** \class cmInstallFilesGenerator
* \brief Generate file installation rules.
*/
class cmInstallFilesGenerator: public cmInstallGenerator
{
public:
- cmInstallFilesGenerator(std::vector<std::string> const& files,
+ cmInstallFilesGenerator(cmMakefile* mf,
+ std::vector<std::string> const& files,
const char* dest, bool programs,
const char* file_permissions,
std::vector<std::string> const& configurations,
@@ -31,6 +34,13 @@ public:
protected:
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
+ virtual void GenerateScriptForConfig(std::ostream& os,
+ const char* config,
+ Indent const& indent);
+ void AddFilesInstallRule(std::ostream& os, Indent const& indent,
+ std::vector<std::string> const& files);
+
+ cmMakefile* Makefile;
std::vector<std::string> Files;
bool Programs;
std::string FilePermissions;
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 3a0a322..54d903a 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -94,7 +94,7 @@ void cmInstallProgramsCommand::FinalPass()
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
- new cmInstallFilesGenerator(this->Files,
+ new cmInstallFilesGenerator(this->Makefile, this->Files,
destination.c_str(), true,
no_permissions, no_configurations,
no_component.c_str(), no_rename));
@@ -109,7 +109,8 @@ void cmInstallProgramsCommand::FinalPass()
std::string cmInstallProgramsCommand
::FindInstallSource(const char* name) const
{
- if(cmSystemTools::FileIsFullPath(name))
+ if(cmSystemTools::FileIsFullPath(name) ||
+ cmGeneratorExpression::Find(name) == 0)
{
// This is a full path.
return name;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c3ca85d..5a841ed 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1650,9 +1650,10 @@ void cmMakefileTargetGenerator
this->AppendTargetDepends(depends);
// Add a dependency on the link definitions file, if any.
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
+ if(!def.empty())
{
- depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
+ depends.push_back(def);
}
// Add user-specified dependencies.
@@ -2019,7 +2020,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
- if(this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
+ if(def.empty())
{
return;
}
@@ -2035,8 +2037,7 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
- flag += (this->LocalGenerator->ConvertToLinkReference(
- this->GeneratorTarget->ModuleDefinitionFile.c_str()));
+ flag += (this->LocalGenerator->ConvertToLinkReference(def.c_str()));
this->LocalGenerator->AppendFlags(flags, flag.c_str());
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 900af8d..5f6fc2d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -498,10 +498,10 @@ cmNinjaTargetGenerator
{
this->WriteObjectBuildStatement(*si);
}
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
+ if(!def.empty())
{
- this->ModuleDefinitionFile = this->ConvertToNinjaPath(
- this->GeneratorTarget->ModuleDefinitionFile.c_str());
+ this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
}
{
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 9a340dc..78b59b3 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -20,7 +20,7 @@
cmOSXBundleGenerator::
cmOSXBundleGenerator(cmGeneratorTarget* target,
const char* configName)
- : Target(target->Target)
+ : GT(target)
, Makefile(target->Target->GetMakefile())
, LocalGenerator(Makefile->GetLocalGenerator())
, ConfigName(configName)
@@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target,
//----------------------------------------------------------------------------
bool cmOSXBundleGenerator::MustSkip()
{
- return !this->Target->HaveWellDefinedOutputFiles();
+ return !this->GT->Target->HaveWellDefinedOutputFiles();
}
//----------------------------------------------------------------------------
@@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
// Compute bundle directory names.
std::string out = outpath;
out += "/";
- out += this->Target->GetAppBundleDirectory(this->ConfigName, false);
+ out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false);
cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out);
@@ -57,9 +57,9 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
// to be set.
std::string plist = outpath;
plist += "/";
- plist += this->Target->GetAppBundleDirectory(this->ConfigName, true);
+ plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true);
plist += "/Info.plist";
- this->LocalGenerator->GenerateAppleInfoPList(this->Target,
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
targetName.c_str(),
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist);
@@ -77,20 +77,20 @@ void cmOSXBundleGenerator::CreateFramework(
// Compute the location of the top-level foo.framework directory.
std::string contentdir = outpath + "/" +
- this->Target->GetFrameworkDirectory(this->ConfigName, true);
+ this->GT->Target->GetFrameworkDirectory(this->ConfigName, true);
contentdir += "/";
std::string newoutpath = outpath + "/" +
- this->Target->GetFrameworkDirectory(this->ConfigName, false);
+ this->GT->Target->GetFrameworkDirectory(this->ConfigName, false);
- std::string frameworkVersion = this->Target->GetFrameworkVersion();
+ std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
// Configure the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");
std::string plist = newoutpath;
plist += "/Resources/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName);
- this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
+ this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target,
name.c_str(),
plist.c_str());
@@ -172,16 +172,16 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
// Compute bundle directory names.
std::string out = root;
out += "/";
- out += this->Target->GetCFBundleDirectory(this->ConfigName, false);
+ out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false);
cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out);
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
std::string plist =
- this->Target->GetCFBundleDirectory(this->ConfigName, true);
+ this->GT->Target->GetCFBundleDirectory(this->ConfigName, true);
plist += "/Info.plist";
- this->LocalGenerator->GenerateAppleInfoPList(this->Target,
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
targetName.c_str(),
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist);
@@ -199,9 +199,9 @@ GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
for(std::vector<cmSourceFile*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
- cmTarget::SourceFileFlags tsFlags =
- this->Target->GetTargetSourceFileFlags(*si);
- if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ this->GT->GetTargetSourceFileFlags(*si);
+ if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal)
{
(*generator)(**si, tsFlags.MacFolder);
}
@@ -215,7 +215,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
// Construct the full path to the content subdirectory.
std::string macdir =
- this->Target->GetMacContentDirectory(this->ConfigName,
+ this->GT->Target->GetMacContentDirectory(this->ConfigName,
/*implib*/ false);
macdir += "/";
macdir += pkgloc;
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 29b7611..2f36394 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -59,7 +59,7 @@ private:
bool MustSkip();
private:
- cmTarget* Target;
+ cmGeneratorTarget* GT;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
const char* ConfigName;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index db34bd8..7df2928 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -83,17 +83,12 @@ public:
cmTargetInternals()
{
this->PolicyWarnedCMP0022 = false;
- this->SourceFileFlagsConstructed = false;
}
cmTargetInternals(cmTargetInternals const&)
{
this->PolicyWarnedCMP0022 = false;
- this->SourceFileFlagsConstructed = false;
}
~cmTargetInternals();
- typedef cmTarget::SourceFileFlags SourceFileFlags;
- mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
- mutable bool SourceFileFlagsConstructed;
// The backtrace when the target was created.
cmListFileBacktrace Backtrace;
@@ -101,9 +96,17 @@ public:
// Cache link interface computation from each configuration.
struct OptionalLinkInterface: public cmTarget::LinkInterface
{
- OptionalLinkInterface(): Exists(false) {}
+ OptionalLinkInterface():
+ Exists(false), Complete(false), ExplicitLibraries(0) {}
bool Exists;
+ bool Complete;
+ const char* ExplicitLibraries;
};
+ void ComputeLinkInterface(cmTarget const* thisTarget,
+ const char* config, OptionalLinkInterface& iface,
+ cmTarget const* head,
+ const char *explicitLibraries) const;
+
typedef std::map<TargetConfigPair, OptionalLinkInterface>
LinkInterfaceMapType;
LinkInterfaceMapType LinkInterfaceMap;
@@ -527,10 +530,11 @@ bool cmTarget::IsBundleOnApple() const
}
//----------------------------------------------------------------------------
-bool cmTarget::FindSourceFiles()
+void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
{
+ assert(this->GetType() != INTERFACE_LIBRARY);
for(std::vector<cmSourceFile*>::const_iterator
- si = this->SourceFiles.begin();
+ si = this->SourceFiles.begin();
si != this->SourceFiles.end(); ++si)
{
std::string e;
@@ -542,16 +546,9 @@ bool cmTarget::FindSourceFiles()
cm->IssueMessage(cmake::FATAL_ERROR, e,
this->GetBacktrace());
}
- return false;
+ return;
}
}
- return true;
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
-{
- assert(this->GetType() != INTERFACE_LIBRARY);
files = this->SourceFiles;
}
@@ -648,109 +645,6 @@ void cmTarget::ProcessSourceExpression(std::string const& expr)
}
//----------------------------------------------------------------------------
-struct cmTarget::SourceFileFlags
-cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
-{
- struct SourceFileFlags flags;
- this->ConstructSourceFileFlags();
- std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
- this->Internal->SourceFlagsMap.find(sf);
- if(si != this->Internal->SourceFlagsMap.end())
- {
- flags = si->second;
- }
- return flags;
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::ConstructSourceFileFlags() const
-{
- if(this->Internal->SourceFileFlagsConstructed)
- {
- return;
- }
- this->Internal->SourceFileFlagsConstructed = true;
-
- // Process public headers to mark the source files.
- if(const char* files = this->GetProperty("PUBLIC_HEADER"))
- {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "Headers";
- flags.Type = cmTarget::SourceFileTypePublicHeader;
- }
- }
- }
-
- // Process private headers after public headers so that they take
- // precedence if a file is listed in both.
- if(const char* files = this->GetProperty("PRIVATE_HEADER"))
- {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "PrivateHeaders";
- flags.Type = cmTarget::SourceFileTypePrivateHeader;
- }
- }
- }
-
- // Mark sources listed as resources.
- if(const char* files = this->GetProperty("RESOURCE"))
- {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "Resources";
- flags.Type = cmTarget::SourceFileTypeResource;
- }
- }
- }
-
- // Handle the MACOSX_PACKAGE_LOCATION property on source files that
- // were not listed in one of the other lists.
- std::vector<cmSourceFile*> sources;
- this->GetSourceFiles(sources);
- for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- if(flags.Type == cmTarget::SourceFileTypeNormal)
- {
- flags.MacFolder = location;
- if(strcmp(location, "Resources") == 0)
- {
- flags.Type = cmTarget::SourceFileTypeResource;
- }
- else
- {
- flags.Type = cmTarget::SourceFileTypeMacContent;
- }
- }
- }
- }
-}
-
-//----------------------------------------------------------------------------
void cmTarget::MergeLinkLibraries( cmMakefile& mf,
const char *selfname,
const LinkLibraryVectorType& libs )
@@ -4530,12 +4424,13 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
assert((impliedByUse ^ explicitlySet)
|| (!impliedByUse && !explicitlySet));
- cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
- if(!info)
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+ if(deps.empty())
{
return propContent;
}
- const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
bool propInitialized = explicitlySet;
std::string report = " * Target \"";
@@ -4555,7 +4450,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
report += "\" property not set.\n";
}
- for(cmComputeLinkInformation::ItemVector::const_iterator li =
+ for(std::vector<cmTarget*>::const_iterator li =
deps.begin();
li != deps.end(); ++li)
{
@@ -4565,23 +4460,20 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
// target itself has a POSITION_INDEPENDENT_CODE which disagrees
// with a dependency.
- if (!li->Target)
- {
- continue;
- }
+ cmTarget const* theTarget = *li;
- const bool ifaceIsSet = li->Target->GetProperties()
+ const bool ifaceIsSet = theTarget->GetProperties()
.find("INTERFACE_" + p)
- != li->Target->GetProperties().end();
+ != theTarget->GetProperties().end();
PropertyType ifacePropContent =
- getTypedProperty<PropertyType>(li->Target,
+ getTypedProperty<PropertyType>(theTarget,
("INTERFACE_" + p).c_str(), 0);
std::string reportEntry;
if (ifaceIsSet)
{
reportEntry += " * Target \"";
- reportEntry += li->Target->GetName();
+ reportEntry += theTarget->GetName();
reportEntry += "\" property value \"";
reportEntry += valueAsString<PropertyType>(ifacePropContent);
reportEntry += "\" ";
@@ -4602,7 +4494,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
e << "Property " << p << " on target \""
<< tgt->GetName() << "\" does\nnot match the "
"INTERFACE_" << p << " property requirement\nof "
- "dependency \"" << li->Target->GetName() << "\".\n";
+ "dependency \"" << theTarget->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
break;
}
@@ -4636,7 +4528,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
<< tgt->GetName() << "\" is\nimplied to be " << defaultValue
<< " because it was used to determine the link libraries\n"
"already. The INTERFACE_" << p << " property on\ndependency \""
- << li->Target->GetName() << "\" is in conflict.\n";
+ << theTarget->GetName() << "\" is in conflict.\n";
cmSystemTools::Error(e.str().c_str());
break;
}
@@ -4667,7 +4559,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
cmOStringStream e;
e << "The INTERFACE_" << p << " property of \""
- << li->Target->GetName() << "\" does\nnot agree with the value "
+ << theTarget->GetName() << "\" does\nnot agree with the value "
"of " << p << " already determined\nfor \""
<< tgt->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
@@ -4748,23 +4640,19 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p,
const char *interfaceProperty,
const char *config)
{
- cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
- if(!info)
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+ if(deps.empty())
{
return false;
}
- const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
-
- for(cmComputeLinkInformation::ItemVector::const_iterator li =
+ for(std::vector<cmTarget*>::const_iterator li =
deps.begin();
li != deps.end(); ++li)
{
- if (!li->Target)
- {
- continue;
- }
- const char *prop = li->Target->GetProperty(interfaceProperty);
+ const char *prop = (*li)->GetProperty(interfaceProperty);
if (!prop)
{
continue;
@@ -5316,24 +5204,124 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
{
// Compute the link interface for this configuration.
cmTargetInternals::OptionalLinkInterface iface;
- iface.Exists = this->ComputeLinkInterface(config, iface, head);
+ iface.ExplicitLibraries =
+ this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists);
+ if (iface.Exists)
+ {
+ this->Internal->ComputeLinkInterface(this, config, iface,
+ head, iface.ExplicitLibraries);
+ }
+
+ // Store the information for this configuration.
+ cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
+ i = this->Internal->LinkInterfaceMap.insert(entry).first;
+ }
+ else if(!i->second.Complete && i->second.Exists)
+ {
+ this->Internal->ComputeLinkInterface(this, config, i->second, head,
+ i->second.ExplicitLibraries);
+ }
+
+ return i->second.Exists ? &i->second : 0;
+}
+
+//----------------------------------------------------------------------------
+cmTarget::LinkInterface const*
+cmTarget::GetLinkInterfaceLibraries(const char* config,
+ cmTarget const* head) const
+{
+ // Imported targets have their own link interface.
+ if(this->IsImported())
+ {
+ if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head))
+ {
+ return &info->LinkInterface;
+ }
+ return 0;
+ }
+
+ // Link interfaces are not supported for executables that do not
+ // export symbols.
+ if(this->GetType() == cmTarget::EXECUTABLE &&
+ !this->IsExecutableWithExports())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link interface for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+
+ cmTargetInternals::LinkInterfaceMapType::iterator
+ i = this->Internal->LinkInterfaceMap.find(key);
+ if(i == this->Internal->LinkInterfaceMap.end())
+ {
+ // Compute the link interface for this configuration.
+ cmTargetInternals::OptionalLinkInterface iface;
+ iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config,
+ iface,
+ head,
+ iface.Exists);
// Store the information for this configuration.
cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
i = this->Internal->LinkInterfaceMap.insert(entry).first;
}
- return i->second.Exists? &i->second : 0;
+ return i->second.Exists ? &i->second : 0;
+}
+
+//----------------------------------------------------------------------------
+void processILibs(const char* config,
+ cmTarget const* headTarget,
+ std::string const& name,
+ std::vector<cmTarget*>& tgts, std::set<cmTarget*>& emitted)
+{
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(name.c_str()))
+ {
+ if (emitted.insert(tgt).second)
+ {
+ tgts.push_back(tgt);
+ std::vector<std::string> ilibs;
+ cmTarget::LinkInterface const* iface =
+ tgt->GetLinkInterfaceLibraries(config, headTarget);
+ if (iface)
+ {
+ for(std::vector<std::string>::const_iterator
+ it = iface->Libraries.begin();
+ it != iface->Libraries.end(); ++it)
+ {
+ processILibs(config, headTarget, *it, tgts, emitted);
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetTransitiveTargetClosure(const char* config,
+ cmTarget const* headTarget,
+ std::vector<cmTarget*> &tgts) const
+{
+ std::set<cmTarget*> emitted;
+
+ cmTarget::LinkImplementation const* impl
+ = this->GetLinkImplementationLibraries(config, headTarget);
+
+ for(std::vector<std::string>::const_iterator it = impl->Libraries.begin();
+ it != impl->Libraries.end(); ++it)
+ {
+ processILibs(config, headTarget, *it, tgts, emitted);
+ }
}
//----------------------------------------------------------------------------
-void cmTarget::GetTransitivePropertyLinkLibraries(
- const char* config,
+void cmTarget::GetTransitivePropertyTargets(const char* config,
cmTarget const* headTarget,
- std::vector<std::string> &libs) const
+ std::vector<cmTarget*> &tgts) const
{
- cmTarget::LinkInterface const* iface = this->GetLinkInterface(config,
- headTarget);
+ cmTarget::LinkInterface const* iface
+ = this->GetLinkInterfaceLibraries(config, headTarget);
if (!iface)
{
return;
@@ -5342,7 +5330,15 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
|| this->GetPolicyStatusCMP0022() == cmPolicies::WARN
|| this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
{
- libs = iface->Libraries;
+ for(std::vector<std::string>::const_iterator it = iface->Libraries.begin();
+ it != iface->Libraries.end(); ++it)
+ {
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(it->c_str()))
+ {
+ tgts.push_back(tgt);
+ }
+ }
return;
}
@@ -5360,17 +5356,30 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
linkIfaceProp, 0, 0);
dagChecker.SetTransitivePropertiesOnly();
+ std::vector<std::string> libs;
cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate(
this->Makefile,
config,
false,
headTarget,
this, &dagChecker), libs);
+
+ for(std::vector<std::string>::const_iterator it = libs.begin();
+ it != libs.end(); ++it)
+ {
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(it->c_str()))
+ {
+ tgts.push_back(tgt);
+ }
+ }
}
//----------------------------------------------------------------------------
-bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
- cmTarget const* headTarget) const
+const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config,
+ LinkInterface& iface,
+ cmTarget const* headTarget,
+ bool &exists) const
{
// Construct the property name suffix for this configuration.
std::string suffix = "_";
@@ -5446,8 +5455,10 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
(this->GetType() == cmTarget::EXECUTABLE ||
(this->GetType() == cmTarget::MODULE_LIBRARY)))
{
- return false;
+ exists = false;
+ return 0;
}
+ exists = true;
if(explicitLibraries)
{
@@ -5462,52 +5473,6 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
false,
headTarget,
this, &dagChecker), iface.Libraries);
-
- if(this->GetType() == cmTarget::SHARED_LIBRARY
- || this->GetType() == cmTarget::STATIC_LIBRARY
- || this->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- // Shared libraries may have runtime implementation dependencies
- // on other shared libraries that are not in the interface.
- std::set<cmStdString> emitted;
- for(std::vector<std::string>::const_iterator
- li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
- {
- emitted.insert(*li);
- }
- if (this->GetType() != cmTarget::INTERFACE_LIBRARY)
- {
- LinkImplementation const* impl = this->GetLinkImplementation(config,
- headTarget);
- for(std::vector<std::string>::const_iterator
- li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
- {
- if(emitted.insert(*li).second)
- {
- if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li))
- {
- // This is a runtime dependency on another shared library.
- if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
- {
- iface.SharedDeps.push_back(*li);
- }
- }
- else
- {
- // TODO: Recognize shared library file names. Perhaps this
- // should be moved to cmComputeLinkInformation, but that creates
- // a chicken-and-egg problem since this list is needed for its
- // construction.
- }
- }
- }
- if(this->LinkLanguagePropagatesToDependents())
- {
- // Targets using this archive need its language runtime libraries.
- iface.Languages = impl->Languages;
- }
- }
- }
}
else if (this->PolicyStatusCMP0022 == cmPolicies::WARN
|| this->PolicyStatusCMP0022 == cmPolicies::OLD)
@@ -5517,17 +5482,9 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
// to the link implementation.
{
// The link implementation is the default link interface.
- LinkImplementation const* impl = this->GetLinkImplementation(config,
- headTarget);
- iface.ImplementationIsInterface = true;
+ LinkImplementation const* impl =
+ this->GetLinkImplementationLibraries(config, headTarget);
iface.Libraries = impl->Libraries;
- iface.WrongConfigLibraries = impl->WrongConfigLibraries;
- if(this->LinkLanguagePropagatesToDependents())
- {
- // Targets using this archive need its language runtime libraries.
- iface.Languages = impl->Languages;
- }
-
if(this->PolicyStatusCMP0022 == cmPolicies::WARN &&
!this->Internal->PolicyWarnedCMP0022)
{
@@ -5592,25 +5549,107 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
}
}
}
+ return explicitLibraries;
+}
- if(this->GetType() == cmTarget::STATIC_LIBRARY)
+//----------------------------------------------------------------------------
+void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
+ const char* config,
+ OptionalLinkInterface& iface,
+ cmTarget const* headTarget,
+ const char* explicitLibraries) const
+{
+ if(explicitLibraries)
+ {
+ if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY
+ || thisTarget->GetType() == cmTarget::STATIC_LIBRARY
+ || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ // Shared libraries may have runtime implementation dependencies
+ // on other shared libraries that are not in the interface.
+ std::set<cmStdString> emitted;
+ for(std::vector<std::string>::const_iterator
+ li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
+ {
+ emitted.insert(*li);
+ }
+ if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY)
+ {
+ cmTarget::LinkImplementation const* impl =
+ thisTarget->GetLinkImplementation(config, headTarget);
+ for(std::vector<std::string>::const_iterator
+ li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
+ {
+ if(emitted.insert(*li).second)
+ {
+ if(cmTarget* tgt = thisTarget->Makefile->FindTargetToUse(*li))
+ {
+ // This is a runtime dependency on another shared library.
+ if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
+ {
+ iface.SharedDeps.push_back(*li);
+ }
+ }
+ else
+ {
+ // TODO: Recognize shared library file names. Perhaps this
+ // should be moved to cmComputeLinkInformation, but that creates
+ // a chicken-and-egg problem since this list is needed for its
+ // construction.
+ }
+ }
+ }
+ if(thisTarget->LinkLanguagePropagatesToDependents())
+ {
+ // Targets using this archive need its language runtime libraries.
+ iface.Languages = impl->Languages;
+ }
+ }
+ }
+ }
+ else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN
+ || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD)
+ {
+ // The link implementation is the default link interface.
+ cmTarget::LinkImplementation const*
+ impl = thisTarget->GetLinkImplementation(config, headTarget);
+ iface.ImplementationIsInterface = true;
+ iface.WrongConfigLibraries = impl->WrongConfigLibraries;
+ if(thisTarget->LinkLanguagePropagatesToDependents())
+ {
+ // Targets using this archive need its language runtime libraries.
+ iface.Languages = impl->Languages;
+ }
+ }
+
+ if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY)
{
+ // Construct the property name suffix for this configuration.
+ std::string suffix = "_";
+ if(config && *config)
+ {
+ suffix += cmSystemTools::UpperCase(config);
+ }
+ else
+ {
+ suffix += "NOCONFIG";
+ }
+
// How many repetitions are needed if this library has cyclic
// dependencies?
std::string propName = "LINK_INTERFACE_MULTIPLICITY";
propName += suffix;
- if(const char* config_reps = this->GetProperty(propName.c_str()))
+ if(const char* config_reps = thisTarget->GetProperty(propName.c_str()))
{
sscanf(config_reps, "%u", &iface.Multiplicity);
}
else if(const char* reps =
- this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
+ thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
{
sscanf(reps, "%u", &iface.Multiplicity);
}
}
-
- return true;
+ iface.Complete = true;
}
//----------------------------------------------------------------------------
@@ -5633,6 +5672,41 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const
// Compute the link implementation for this configuration.
LinkImplementation impl;
this->ComputeLinkImplementation(config, impl, head);
+ this->ComputeLinkImplementationLanguages(impl);
+
+ // Store the information for this configuration.
+ cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
+ i = this->Internal->LinkImplMap.insert(entry).first;
+ }
+ else if (i->second.Languages.empty())
+ {
+ this->ComputeLinkImplementationLanguages(i->second);
+ }
+
+ return &i->second;
+}
+
+//----------------------------------------------------------------------------
+cmTarget::LinkImplementation const*
+cmTarget::GetLinkImplementationLibraries(const char* config,
+ cmTarget const* head) const
+{
+ // There is no link implementation for imported targets.
+ if(this->IsImported())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link implementation for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+
+ cmTargetInternals::LinkImplMapType::iterator
+ i = this->Internal->LinkImplMap.find(key);
+ if(i == this->Internal->LinkImplMap.end())
+ {
+ // Compute the link implementation for this configuration.
+ LinkImplementation impl;
+ this->ComputeLinkImplementation(config, impl, head);
// Store the information for this configuration.
cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
@@ -5715,7 +5789,12 @@ void cmTarget::ComputeLinkImplementation(const char* config,
impl.WrongConfigLibraries.push_back(item);
}
}
+}
+//----------------------------------------------------------------------------
+void
+cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const
+{
// This target needs runtime libraries for its source languages.
std::set<cmStdString> languages;
// Get languages used in our source files.
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 271824b..5dec9e2 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -140,34 +140,6 @@ public:
}
/**
- * Flags for a given source file as used in this target. Typically assigned
- * via SET_TARGET_PROPERTIES when the property is a list of source files.
- */
- enum SourceFileType
- {
- SourceFileTypeNormal,
- SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
- SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
- SourceFileTypeResource, // is in "RESOURCE" target property *or*
- // has MACOSX_PACKAGE_LOCATION=="Resources"
- SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
- };
- struct SourceFileFlags
- {
- SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
- SourceFileFlags(SourceFileFlags const& r):
- Type(r.Type), MacFolder(r.MacFolder) {}
- SourceFileType Type;
- const char* MacFolder; // location inside Mac content folders
- };
-
- /**
- * Get the flags for a given source file as used in this target
- */
- struct SourceFileFlags
- GetTargetSourceFileFlags(const cmSourceFile* sf) const;
-
- /**
* Add sources to the target.
*/
void AddSources(std::vector<std::string> const& srcs);
@@ -292,9 +264,14 @@ public:
if the target cannot be linked. */
LinkInterface const* GetLinkInterface(const char* config,
cmTarget const* headTarget) const;
- void GetTransitivePropertyLinkLibraries(const char* config,
+ LinkInterface const* GetLinkInterfaceLibraries(const char* config,
+ cmTarget const* headTarget) const;
+ void GetTransitivePropertyTargets(const char* config,
+ cmTarget const* headTarget,
+ std::vector<cmTarget*> &libs) const;
+ void GetTransitiveTargetClosure(const char* config,
cmTarget const* headTarget,
- std::vector<std::string> &libs) const;
+ std::vector<cmTarget*> &libs) const;
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
@@ -313,6 +290,9 @@ public:
LinkImplementation const* GetLinkImplementation(const char* config,
cmTarget const* head) const;
+ LinkImplementation const* GetLinkImplementationLibraries(const char* config,
+ cmTarget const* head) const;
+
/** Link information from the transitive closure of the link
implementation and the interfaces of its dependencies. */
struct LinkClosure
@@ -358,11 +338,6 @@ public:
void
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
- /**
- * Make sure the full path to all source files is known.
- */
- bool FindSourceFiles();
-
///! Return the preferred linker language for this target
const char* GetLinkerLanguage(const char* config = 0,
cmTarget const* head = 0) const;
@@ -723,12 +698,15 @@ private:
void CheckPropertyCompatibility(cmComputeLinkInformation *info,
const char* config) const;
- bool ComputeLinkInterface(const char* config, LinkInterface& iface,
- cmTarget const* head) const;
+ const char* ComputeLinkInterfaceLibraries(const char* config,
+ LinkInterface& iface,
+ cmTarget const* head,
+ bool &exists) const;
void ComputeLinkImplementation(const char* config,
LinkImplementation& impl,
cmTarget const* head) const;
+ void ComputeLinkImplementationLanguages(LinkImplementation& impl) const;
void ComputeLinkClosure(const char* config, LinkClosure& lc,
cmTarget const* head) const;
@@ -756,7 +734,6 @@ private:
friend class cmTargetTraceDependencies;
cmTargetInternalPointer Internal;
- void ConstructSourceFileFlags() const;
void ComputeVersionedName(std::string& vName,
std::string const& prefix,
std::string const& base,
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ed7e243..d760b3f 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1666,10 +1666,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
linkOptions.Parse(flags.c_str());
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile();
+ if(!def.empty())
{
- linkOptions.AddFlag("ModuleDefinitionFile",
- this->GeneratorTarget->ModuleDefinitionFile.c_str());
+ linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
}
this->LinkOptions[config] = pOptions.release();
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 9727930..a875f07 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -68,6 +68,8 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h
"#define link_depends_no_shared_exe_value 0\n")
set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n")
+
help_xcode_depends()
message("Building project first time")
@@ -166,6 +168,19 @@ else()
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
endif()
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+ file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+ if("${external_out}" STREQUAL "external original")
+ message(STATUS "external.out contains '${external_out}'")
+ else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "external.out contains '${external_out}'")
+ endif()
+else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "external.out is missing")
+endif()
+
message("Waiting 3 seconds...")
# any additional argument will cause ${bar} to wait forever
execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
@@ -191,6 +206,8 @@ if(TEST_LINK_DEPENDS)
file(WRITE ${TEST_LINK_DEPENDS} "2")
endif()
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external changed\n")
+
help_xcode_depends()
message("Building project second time")
@@ -294,3 +311,16 @@ else()
message(SEND_ERROR "Project did not rebuild properly. "
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
endif()
+
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+ file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+ if("${external_out}" STREQUAL "external changed")
+ message(STATUS "external.out contains '${external_out}'")
+ else()
+ message(SEND_ERROR "Project did not rebuild properly: "
+ "external.out contains '${external_out}'")
+ endif()
+else()
+ message(SEND_ERROR "Project did not rebuild properly: "
+ "external.out is missing")
+endif()
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 8806ecd..9ee4a43 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -139,3 +139,15 @@ add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(ninjadep ninjadep.cpp)
add_dependencies(ninjadep header_tgt)
+
+include(ExternalProject)
+ExternalProject_Add(ExternalBuild
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/External
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/External
+ STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/Stamp
+ BUILD_ALWAYS 1
+ CMAKE_ARGS
+ -Dexternal_in=${CMAKE_CURRENT_BINARY_DIR}/external.in
+ -Dexternal_out=${CMAKE_CURRENT_BINARY_DIR}/external.out
+ INSTALL_COMMAND ""
+ )
diff --git a/Tests/BuildDepends/Project/External/CMakeLists.txt b/Tests/BuildDepends/Project/External/CMakeLists.txt
new file mode 100644
index 0000000..c6015b6
--- /dev/null
+++ b/Tests/BuildDepends/Project/External/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.0)
+project(BuildDependsExternal NONE)
+if(NOT DEFINED external_in)
+ message(FATAL_ERROR "Define external_in")
+endif()
+if(NOT DEFINED external_out)
+ message(FATAL_ERROR "Define external_out")
+endif()
+add_custom_command(
+ OUTPUT ${external_out}
+ COMMAND ${CMAKE_COMMAND} -E copy ${external_in} ${external_out}
+ DEPENDS ${external_in}
+ )
+add_custom_target(drive ALL DEPENDS ${external_out})
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 0e2828e..febdfe6 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -23,6 +23,22 @@ add_library(testLib1 STATIC testLib1.c)
add_library(testLib2 STATIC testLib2.c)
target_link_libraries(testLib2 testLib1)
+# Test install(FILES) with generator expressions referencing testLib1.
+add_custom_command(TARGET testLib1 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:testLib1>
+ $<TARGET_FILE:testLib1>.genex
+ )
+install(FILES $<TARGET_FILE:testLib1>.genex
+ DESTINATION lib
+ )
+set_property(TARGET testLib1 PROPERTY MY_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/testLib1file1.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/testLib1file2.txt
+ )
+install(FILES $<TARGET_PROPERTY:testLib1,MY_FILES>
+ DESTINATION doc
+ )
+
# Test library with empty link interface. Link it to an implementation
# dependency that itself links to dependencies publicly.
add_library(testLib3ImpDep SHARED testLib3ImpDep.c)
diff --git a/Tests/ExportImport/Export/testLib1file1.txt b/Tests/ExportImport/Export/testLib1file1.txt
new file mode 100644
index 0000000..73601df
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib1file1.txt
@@ -0,0 +1 @@
+testLib1file1
diff --git a/Tests/ExportImport/Export/testLib1file2.txt b/Tests/ExportImport/Export/testLib1file2.txt
new file mode 100644
index 0000000..4874ed1
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib1file2.txt
@@ -0,0 +1 @@
+testLib1file2
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index ebe4af2..eb0bbf8 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -68,6 +68,12 @@ target_link_libraries(imp_testExe1b
bld_testLibCycleA
)
+add_custom_target(check_testLib1_genex ALL
+ COMMAND ${CMAKE_COMMAND} -DtestLib1=$<TARGET_FILE:exp_testLib1>
+ -Dprefix=${CMAKE_INSTALL_PREFIX}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check_testLib1_genex.cmake
+ )
+
add_executable(cmp0022OLD_test cmp0022OLD_test_vs6_1.cpp)
target_link_libraries(cmp0022OLD_test bld_cmp0022OLD)
add_executable(cmp0022NEW_test cmp0022NEW_test_vs6_1.cpp)
diff --git a/Tests/ExportImport/Import/A/check_testLib1_genex.cmake b/Tests/ExportImport/Import/A/check_testLib1_genex.cmake
new file mode 100644
index 0000000..7c02652
--- /dev/null
+++ b/Tests/ExportImport/Import/A/check_testLib1_genex.cmake
@@ -0,0 +1,11 @@
+foreach(f
+ "${testLib1}.genex"
+ "${prefix}/doc/testLib1file1.txt"
+ "${prefix}/doc/testLib1file2.txt"
+ )
+ if(EXISTS "${f}")
+ message(STATUS "'${f}' exists!")
+ else()
+ message(FATAL_ERROR "Missing file:\n ${f}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
index 17b8a5c..82a34d5 100644
--- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
+++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
@@ -1,4 +1,11 @@
CMake Debug Log:
+ Boolean compatibility of property "BOOL_PROP7" for target
+ "CompatibleInterface" \(result: "FALSE"\):
+
+ \* Target "CompatibleInterface" property is implied by use.
+ \* Target "iface1" property value "FALSE" \(Agree\)
++
+CMake Debug Log:
Boolean compatibility of property "BOOL_PROP1" for target
"CompatibleInterface" \(result: "TRUE"\):
@@ -40,13 +47,6 @@ CMake Debug Log:
\* Target "iface2" property value "FALSE" \(Agree\)
+
CMake Debug Log:
- Boolean compatibility of property "BOOL_PROP7" for target
- "CompatibleInterface" \(result: "FALSE"\):
-
- \* Target "CompatibleInterface" property is implied by use.
- \* Target "iface1" property value "FALSE" \(Agree\)
-+
-CMake Debug Log:
String compatibility of property "STRING_PROP1" for target
"CompatibleInterface" \(result: "prop1"\):
diff --git a/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
new file mode 100644
index 0000000..5dcd4d7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
@@ -0,0 +1 @@
+-->wrong<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariable.cmake b/Tests/RunCMake/Syntax/AtWithVariable.cmake
new file mode 100644
index 0000000..2bbf61d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# 'right' is dereferenced because 'var' was dereferenced when
+# assigning to 'ref' above.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
new file mode 100644
index 0000000..e06484c
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# No dereference done at all.
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
new file mode 100644
index 0000000..90bffb6
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${var}<==
+==>\${empty}<==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
new file mode 100644
index 0000000..bdd7bcd
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt"
+ @ONLY)
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
new file mode 100644
index 0000000..840c7f0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced here.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
new file mode 100644
index 0000000..b657506
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced, but now 'right'
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
new file mode 100644
index 0000000..43f029f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${right}<==
+==><==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
new file mode 100644
index 0000000..c709099
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt")
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
new file mode 100644
index 0000000..077272d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
@@ -0,0 +1 @@
+-->"<--
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes.cmake b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
new file mode 100644
index 0000000..46d2b6f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
@@ -0,0 +1,9 @@
+set(var "\"")
+set(ref "@var@")
+set(rref "\${var}")
+
+string(CONFIGURE "${ref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
+
+string(CONFIGURE "${rref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/EscapedAt-stderr.txt b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
new file mode 100644
index 0000000..a51c0d3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
@@ -0,0 +1 @@
+-->\\n<--
diff --git a/Tests/RunCMake/Syntax/EscapedAt.cmake b/Tests/RunCMake/Syntax/EscapedAt.cmake
new file mode 100644
index 0000000..1ced620
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt.cmake
@@ -0,0 +1,5 @@
+set(var "n")
+set(ref "\\@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
new file mode 100644
index 0000000..5da8b60
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
@@ -0,0 +1 @@
+-->@foo@<--
diff --git a/Tests/RunCMake/Syntax/ExpandInAt.cmake b/Tests/RunCMake/Syntax/ExpandInAt.cmake
new file mode 100644
index 0000000..98f0277
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt.cmake
@@ -0,0 +1,6 @@
+set("\${varname}" bar)
+set(var foo)
+set(ref "@\${var}@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/ParenInENV-result.txt b/Tests/RunCMake/Syntax/ParenInENV-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
new file mode 100644
index 0000000..7ecfe11
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
+ Syntax Warning in cmake code at
+
+ .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21
+
+ Argument not separated from preceding token by whitespace.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at ParenInENV.cmake:2 \(message\):
+ Syntax error in cmake code at
+
+ .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2
+
+ when parsing string
+
+ -->\$ENV{e
+
+ syntax error, unexpected \$end, expecting } \(9\)
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/ParenInENV.cmake b/Tests/RunCMake/Syntax/ParenInENV.cmake
new file mode 100644
index 0000000..148f726
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message(-->$ENV{e(x)}<--)
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
new file mode 100644
index 0000000..6333717
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index 5f05cfc..dcabd8a 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -52,3 +52,16 @@ run_cmake(UnterminatedString)
run_cmake(UnterminatedBracket0)
run_cmake(UnterminatedBracket1)
run_cmake(UnterminatedBracketComment)
+
+# Variable expansion tests
+run_cmake(ExpandInAt)
+run_cmake(EscapedAt)
+run_cmake(EscapeQuotes)
+run_cmake(AtWithVariable)
+run_cmake(AtWithVariableEmptyExpansion)
+run_cmake(AtWithVariableAtOnly)
+run_cmake(AtWithVariableEmptyExpansionAtOnly)
+run_cmake(AtWithVariableFile)
+run_cmake(AtWithVariableAtOnlyFile)
+run_cmake(ParenInENV)
+run_cmake(ParenInQuotedENV)
diff --git a/Tests/RunCMake/Syntax/atfile.txt.in b/Tests/RunCMake/Syntax/atfile.txt.in
new file mode 100644
index 0000000..3775919
--- /dev/null
+++ b/Tests/RunCMake/Syntax/atfile.txt.in
@@ -0,0 +1,4 @@
+==>@var@<==
+==>@empty@<==
+==>${var}<==
+==>${empty}<==