summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Copyright.txt2
-rw-r--r--Help/command/if.rst378
-rw-r--r--Help/index.rst16
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/manual/cmake-packages.7.rst414
-rw-r--r--Help/manual/cmake-policies.7.rst16
-rw-r--r--Help/module/CMakeFindDependencyMacro.rst1
-rw-r--r--Help/policy/CMP0024.rst2
-rw-r--r--Help/policy/CMP0037.rst2
-rw-r--r--Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst8
-rw-r--r--Help/variable/CMAKE_VERBOSE_MAKEFILE.rst9
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake2
-rw-r--r--Modules/CMakeFindDependencyMacro.cmake58
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake35
-rw-r--r--Modules/CPackWIX.cmake51
-rw-r--r--Modules/FindBacktrace.cmake17
-rw-r--r--Modules/FindFreetype.cmake16
-rw-r--r--Modules/FindQt4.cmake4
-rw-r--r--Modules/FindSubversion.cmake2
-rw-r--r--Modules/Platform/MirBSD.cmake1
-rw-r--r--Modules/Qt4Macros.cmake1
-rw-r--r--Modules/TestCXXAcceptsFlag.cmake16
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx116
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h21
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx145
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.h75
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx28
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.h2
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx70
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h8
-rw-r--r--Source/cmComputeLinkDepends.cxx11
-rw-r--r--Source/cmComputeLinkDepends.h8
-rw-r--r--Source/cmComputeLinkInformation.cxx17
-rw-r--r--Source/cmComputeLinkInformation.h17
-rw-r--r--Source/cmComputeTargetDepends.cxx67
-rw-r--r--Source/cmComputeTargetDepends.h14
-rw-r--r--Source/cmExportBuildFileGenerator.cxx2
-rw-r--r--Source/cmExportFileGenerator.cxx2
-rw-r--r--Source/cmExportInstallFileGenerator.cxx12
-rw-r--r--Source/cmExtraKateGenerator.cxx75
-rw-r--r--Source/cmExtraKateGenerator.h6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx66
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h2
-rw-r--r--Source/cmGlobalGenerator.cxx26
-rw-r--r--Source/cmGlobalGenerator.h17
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx4
-rw-r--r--Source/cmGlobalNinjaGenerator.h4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx107
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h12
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx6
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h4
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx6
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h6
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx51
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h12
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx24
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h17
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmInstallTargetGenerator.cxx14
-rw-r--r--Source/cmInstallTargetGenerator.h3
-rw-r--r--Source/cmLocalGenerator.cxx31
-rw-r--r--Source/cmLocalGenerator.h5
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx12
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx1
-rw-r--r--Source/cmQtAutoGenerators.cxx93
-rw-r--r--Source/cmQtAutoGenerators.h9
-rw-r--r--Source/cmStandardIncludes.h6
-rw-r--r--Source/cmTarget.cxx20
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Source/cmTargetDepend.h10
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2
-rw-r--r--Source/kwsys/Encoding.hxx.in31
-rw-r--r--Source/kwsys/EncodingC.c2
-rw-r--r--Source/kwsys/EncodingCXX.cxx93
-rw-r--r--Source/kwsys/FStream.hxx.in2
-rw-r--r--Source/kwsys/ProcessUNIX.c2
-rw-r--r--Source/kwsys/SystemInformation.cxx32
-rw-r--r--Source/kwsys/SystemTools.cxx4
-rw-r--r--Source/kwsys/testEncoding.cxx42
-rw-r--r--Tests/CMakeLists.txt18
-rw-r--r--Tests/CPackWiXGenerator/CMakeLists.txt2
-rw-r--r--Tests/CPackWiXGenerator/patch.xml7
-rw-r--r--Tests/CTestTestMemcheck/CMakeLists.txt10
-rw-r--r--Tests/Contracts/VTK/Dashboard.cmake.in9
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt6
-rw-r--r--Tests/GeneratorExpression/check-part3.cmake6
-rw-r--r--Tests/InterfaceBuildTargets/CMakeLists.txt13
-rw-r--r--Tests/InterfaceBuildTargets/main.cxx5
-rw-r--r--Tests/InterfaceBuildTargets/testlib.cxx5
-rw-r--r--Tests/InterfaceLibrary/CMakeLists.txt14
-rw-r--r--Tests/InterfaceLibrary/broken.cpp2
-rw-r--r--Tests/InterfaceLibrary/dummy.cpp5
-rw-r--r--Tests/Module/GenerateExportHeader/CMakeLists.txt113
-rw-r--r--Tests/Module/GenerateExportHeader/exportheader_test.cpp54
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt16
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h26
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt33
-rw-r--r--Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt45
-rw-r--r--Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt18
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt11
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/main.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/someclass.h8
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt15
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/main.cpp8
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/useprefixclass.h13
-rw-r--r--Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h41
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt17
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/main.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h13
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt2
-rw-r--r--Tests/RunCMake/interface_library/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/interface_library/genex_link-result.txt1
-rw-r--r--Tests/RunCMake/interface_library/genex_link-stderr.txt1
-rw-r--r--Tests/RunCMake/interface_library/genex_link.cmake22
-rw-r--r--Utilities/Sphinx/cmake.py7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c68
139 files changed, 2518 insertions, 1155 deletions
diff --git a/Copyright.txt b/Copyright.txt
index 9342249..214d7de 100644
--- a/Copyright.txt
+++ b/Copyright.txt
@@ -1,5 +1,5 @@
CMake - Cross Platform Makefile Generator
-Copyright 2000-2013 Kitware, Inc.
+Copyright 2000-2014 Kitware, Inc.
Copyright 2000-2011 Insight Software Consortium
All rights reserved.
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 0279be7..49c356e 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -3,24 +3,24 @@ if
Conditionally execute a group of commands.
-::
-
- if(expression)
- # then section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- elseif(expression2)
- # elseif section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- else(expression)
- # else section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- endif(expression)
+.. code-block:: cmake
+
+ if(expression)
+ # then section.
+ COMMAND1(ARGS ...)
+ COMMAND2(ARGS ...)
+ ...
+ elseif(expression2)
+ # elseif section.
+ COMMAND1(ARGS ...)
+ COMMAND2(ARGS ...)
+ ...
+ else(expression)
+ # else section.
+ COMMAND1(ARGS ...)
+ COMMAND2(ARGS ...)
+ ...
+ endif(expression)
Evaluates the given expression. If the result is true, the commands
in the THEN section are invoked. Otherwise, the commands in the else
@@ -28,212 +28,174 @@ section are invoked. The elseif and else sections are optional. You
may have multiple elseif clauses. Note that the expression in the
else and endif clause is optional. Long expressions can be used and
there is a traditional order of precedence. Parenthetical expressions
-are evaluated first followed by unary operators such as EXISTS,
-COMMAND, and DEFINED. Then any EQUAL, LESS, GREATER, STRLESS,
-STRGREATER, STREQUAL, MATCHES will be evaluated. Then NOT operators
-and finally AND, OR operators will be evaluated. Possible expressions
-are:
-
-::
-
- if(<constant>)
-
-True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number.
-False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, '',
-or ends in the suffix '-NOTFOUND'. Named boolean constants are
-case-insensitive. If the argument is not one of these constants, it
-is treated as a variable:
-
-::
-
- if(<variable>)
-
-True if the variable is defined to a value that is not a false
-constant. False otherwise. (Note macro arguments are not variables.)
-
-::
-
- if(NOT <expression>)
-
-True if the expression is not true.
-
-::
-
- if(<expr1> AND <expr2>)
-
-True if both expressions would be considered true individually.
-
-::
-
- if(<expr1> OR <expr2>)
-
-True if either expression would be considered true individually.
-
-::
-
- if(COMMAND command-name)
-
-True if the given name is a command, macro or function that can be
-invoked.
-
-::
-
- if(POLICY policy-id)
-
-True if the given name is an existing policy (of the form CMP<NNNN>).
-
-::
-
- if(TARGET target-name)
-
-True if the given name is an existing target, built or imported.
-
-::
-
- if(EXISTS file-name)
- if(EXISTS directory-name)
-
-True if the named file or directory exists. Behavior is well-defined
-only for full paths.
-
-::
-
- if(file1 IS_NEWER_THAN file2)
-
-True if file1 is newer than file2 or if one of the two files doesn't
-exist. Behavior is well-defined only for full paths. If the file
-time stamps are exactly the same, an IS_NEWER_THAN comparison returns
-true, so that any dependent build operations will occur in the event
-of a tie. This includes the case of passing the same file name for
-both file1 and file2.
-
-::
-
- if(IS_DIRECTORY directory-name)
-
-True if the given name is a directory. Behavior is well-defined only
-for full paths.
-
-::
-
- if(IS_SYMLINK file-name)
-
-True if the given name is a symbolic link. Behavior is well-defined
-only for full paths.
-
-::
-
- if(IS_ABSOLUTE path)
-
-True if the given path is an absolute path.
-
-::
-
- if(<variable|string> MATCHES regex)
-
-True if the given string or variable's value matches the given regular
-expression.
-
-::
-
- if(<variable|string> LESS <variable|string>)
- if(<variable|string> GREATER <variable|string>)
- if(<variable|string> EQUAL <variable|string>)
-
-True if the given string or variable's value is a valid number and the
-inequality or equality is true.
-
-::
-
- if(<variable|string> STRLESS <variable|string>)
- if(<variable|string> STRGREATER <variable|string>)
- if(<variable|string> STREQUAL <variable|string>)
-
-True if the given string or variable's value is lexicographically less
-(or greater, or equal) than the string or variable on the right.
-
-::
-
- if(<variable|string> VERSION_LESS <variable|string>)
- if(<variable|string> VERSION_EQUAL <variable|string>)
- if(<variable|string> VERSION_GREATER <variable|string>)
-
-Component-wise integer version number comparison (version format is
-major[.minor[.patch[.tweak]]]).
-
-::
-
- if(DEFINED <variable>)
-
-True if the given variable is defined. It does not matter if the
-variable is true or false just if it has been set. (Note macro
-arguments are not variables.)
-
-::
-
- if((expression) AND (expression OR (expression)))
-
-The expressions inside the parenthesis are evaluated first and then
-the remaining expression is evaluated as in the previous examples.
-Where there are nested parenthesis the innermost are evaluated as part
-of evaluating the expression that contains them.
+are evaluated first followed by unary tests such as ``EXISTS``,
+``COMMAND``, and ``DEFINED``. Then any binary tests such as
+``EQUAL``, ``LESS``, ``GREATER``, ``STRLESS``, ``STRGREATER``,
+``STREQUAL``, and ``MATCHES`` will be evaluated. Then boolean ``NOT``
+operators and finally boolean ``AND`` and then ``OR`` operators will
+be evaluated.
+
+Possible expressions are:
+
+``if(<constant>)``
+ True if the constant is ``1``, ``ON``, ``YES``, ``TRUE``, ``Y``,
+ or a non-zero number. False if the constant is ``0``, ``OFF``,
+ ``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string,
+ or ends in the suffix ``-NOTFOUND``. Named boolean constants are
+ case-insensitive. If the argument is not one of these constants, it
+ is treated as a variable.
+
+``if(<variable>)``
+ True if the variable is defined to a value that is not a false
+ constant. False otherwise. (Note macro arguments are not variables.)
+
+``if(NOT <expression>)``
+ True if the expression is not true.
+
+``if(<expr1> AND <expr2>)``
+ True if both expressions would be considered true individually.
+
+``if(<expr1> OR <expr2>)``
+ True if either expression would be considered true individually.
+
+``if(COMMAND command-name)``
+ True if the given name is a command, macro or function that can be
+ invoked.
+
+``if(POLICY policy-id)``
+ True if the given name is an existing policy (of the form ``CMP<NNNN>``).
+
+``if(TARGET target-name)``
+ True if the given name is an existing logical target name such as those
+ created by the :command:`add_executable`, :command:`add_library`, or
+ :command:`add_custom_target` commands.
+
+``if(EXISTS path-to-file-or-directory)``
+ True if the named file or directory exists. Behavior is well-defined
+ only for full paths.
+
+``if(file1 IS_NEWER_THAN file2)``
+ True if file1 is newer than file2 or if one of the two files doesn't
+ exist. Behavior is well-defined only for full paths. If the file
+ time stamps are exactly the same, an ``IS_NEWER_THAN`` comparison returns
+ true, so that any dependent build operations will occur in the event
+ of a tie. This includes the case of passing the same file name for
+ both file1 and file2.
+
+``if(IS_DIRECTORY path-to-directory)``
+ True if the given name is a directory. Behavior is well-defined only
+ for full paths.
+
+``if(IS_SYMLINK file-name)``
+ True if the given name is a symbolic link. Behavior is well-defined
+ only for full paths.
+
+``if(IS_ABSOLUTE path)``
+ True if the given path is an absolute path.
+
+``if(<variable|string> MATCHES regex)``
+ True if the given string or variable's value matches the given regular
+ expression.
+
+``if(<variable|string> LESS <variable|string>)``
+ True if the given string or variable's value is a valid number and less
+ than that on the right.
+
+``if(<variable|string> GREATER <variable|string>)``
+ True if the given string or variable's value is a valid number and greater
+ than that on the right.
+
+``if(<variable|string> EQUAL <variable|string>)``
+ True if the given string or variable's value is a valid number and equal
+ to that on the right.
+
+``if(<variable|string> STRLESS <variable|string>)``
+ True if the given string or variable's value is lexicographically less
+ than the string or variable on the right.
+
+``if(<variable|string> STRGREATER <variable|string>)``
+ True if the given string or variable's value is lexicographically greater
+ than the string or variable on the right.
+
+``if(<variable|string> STREQUAL <variable|string>)``
+ True if the given string or variable's value is lexicographically equal
+ to the string or variable on the right.
+
+``if(<variable|string> VERSION_LESS <variable|string>)``
+ Component-wise integer version number comparison (version format is
+ ``major[.minor[.patch[.tweak]]]``).
+
+``if(<variable|string> VERSION_EQUAL <variable|string>)``
+ Component-wise integer version number comparison (version format is
+ ``major[.minor[.patch[.tweak]]]``).
+
+``if(<variable|string> VERSION_GREATER <variable|string>)``
+ Component-wise integer version number comparison (version format is
+ ``major[.minor[.patch[.tweak]]]``).
+
+``if(DEFINED <variable>)``
+ True if the given variable is defined. It does not matter if the
+ variable is true or false just if it has been set. (Note macro
+ arguments are not variables.)
+
+``if((expression) AND (expression OR (expression)))``
+ The expressions inside the parenthesis are evaluated first and then
+ the remaining expression is evaluated as in the previous examples.
+ Where there are nested parenthesis the innermost are evaluated as part
+ of evaluating the expression that contains them.
The if command was written very early in CMake's history, predating
-the ${} variable evaluation syntax, and for convenience evaluates
+the ``${}`` variable evaluation syntax, and for convenience evaluates
variables named by its arguments as shown in the above signatures.
-Note that normal variable evaluation with ${} applies before the if
-command even receives the arguments. Therefore code like
-
-::
-
- set(var1 OFF)
- set(var2 "var1")
- if(${var2})
-
-appears to the if command as
+Note that normal variable evaluation with ``${}`` applies before the if
+command even receives the arguments. Therefore code like::
-::
+ set(var1 OFF)
+ set(var2 "var1")
+ if(${var2})
- if(var1)
+appears to the if command as::
-and is evaluated according to the if(<variable>) case documented
-above. The result is OFF which is false. However, if we remove the
-${} from the example then the command sees
+ if(var1)
-::
+and is evaluated according to the ``if(<variable>)`` case documented
+above. The result is ``OFF`` which is false. However, if we remove the
+``${}`` from the example then the command sees::
- if(var2)
+ if(var2)
-which is true because var2 is defined to "var1" which is not a false
+which is true because ``var2`` is defined to "var1" which is not a false
constant.
Automatic evaluation applies in the other cases whenever the
-above-documented signature accepts <variable|string>:
+above-documented signature accepts ``<variable|string>``:
-1) The left hand argument to MATCHES is first checked to see if it is
-a defined variable, if so the variable's value is used, otherwise the
-original value is used.
+* The left hand argument to ``MATCHES`` is first checked to see if it is
+ a defined variable, if so the variable's value is used, otherwise the
+ original value is used.
-2) If the left hand argument to MATCHES is missing it returns false
-without error
+* If the left hand argument to ``MATCHES`` is missing it returns false
+ without error
-3) Both left and right hand arguments to LESS GREATER EQUAL are
-independently tested to see if they are defined variables, if so their
-defined values are used otherwise the original value is used.
+* Both left and right hand arguments to ``LESS``, ``GREATER``, and
+ ``EQUAL`` are independently tested to see if they are defined
+ variables, if so their defined values are used otherwise the original
+ value is used.
-4) Both left and right hand arguments to STRLESS STREQUAL STRGREATER
-are independently tested to see if they are defined variables, if so
-their defined values are used otherwise the original value is used.
+* Both left and right hand arguments to ``STRLESS``, ``STREQUAL``, and
+ ``STRGREATER`` are independently tested to see if they are defined
+ variables, if so their defined values are used otherwise the original
+ value is used.
-5) Both left and right hand argumemnts to VERSION_LESS VERSION_EQUAL
-VERSION_GREATER are independently tested to see if they are defined
-variables, if so their defined values are used otherwise the original
-value is used.
+* Both left and right hand argumemnts to ``VERSION_LESS``,
+ ``VERSION_EQUAL``, and ``VERSION_GREATER`` are independently tested
+ to see if they are defined variables, if so their defined values are
+ used otherwise the original value is used.
-6) The right hand argument to NOT is tested to see if it is a boolean
-constant, if so the value is used, otherwise it is assumed to be a
-variable and it is dereferenced.
+* The right hand argument to ``NOT`` is tested to see if it is a boolean
+ constant, if so the value is used, otherwise it is assumed to be a
+ variable and it is dereferenced.
-7) The left and right hand arguments to AND OR are independently
-tested to see if they are boolean constants, if so they are used as
-such, otherwise they are assumed to be variables and are dereferenced.
+* The left and right hand arguments to ``AND`` and ``OR`` are independently
+ tested to see if they are boolean constants, if so they are used as
+ such, otherwise they are assumed to be variables and are dereferenced.
diff --git a/Help/index.rst b/Help/index.rst
index 4ef5c3f..a7a1bd9 100644
--- a/Help/index.rst
+++ b/Help/index.rst
@@ -26,23 +26,17 @@ Reference Manuals
:maxdepth: 1
/manual/cmake-commands.7
+ /manual/cmake-developer.7
+ /manual/cmake-generator-expressions.7
/manual/cmake-generators.7
- /manual/cmake-toolchains.7
+ /manual/cmake-language.7
/manual/cmake-modules.7
+ /manual/cmake-packages.7
/manual/cmake-policies.7
/manual/cmake-properties.7
+ /manual/cmake-toolchains.7
/manual/cmake-variables.7
-Other Manuals
-#############
-
-.. toctree::
- :maxdepth: 1
-
- /manual/cmake-developer.7
- /manual/cmake-generator-expressions.7
- /manual/cmake-language.7
-
.. only:: html
Index and Search
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index f148a51..3f819d6 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -39,6 +39,7 @@ All Modules
/module/CMakeDependentOption
/module/CMakeDetermineVSServicePack
/module/CMakeExpandImportedTargets
+ /module/CMakeFindDependencyMacro
/module/CMakeFindFrameworks
/module/CMakeFindPackageMode
/module/CMakeForceCompiler
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
new file mode 100644
index 0000000..952da3c
--- /dev/null
+++ b/Help/manual/cmake-packages.7.rst
@@ -0,0 +1,414 @@
+.. cmake-manual-description: CMake Packages Reference
+
+cmake-packages(7)
+*****************
+
+.. only:: html or latex
+
+ .. contents::
+
+Introduction
+============
+
+Packages provide dependency information to CMake based buildsystems. Packages
+are found with the :command:`find_package` command. The result of
+using ``find_package`` is either a set of :prop_tgt:`IMPORTED` targets, or
+a set of variables corresponding to build-relevant information.
+
+Using Packages
+==============
+
+CMake provides direct support for two forms of packages,
+`Config-file Packages`_ and `Find-module Packages`_.
+Indirect support for ``pkg-config`` packages is also provided via
+the :module:`FindPkgConfig` module. In all cases, the basic form
+of :command:`find_package` calls is the same:
+
+.. code-block:: cmake
+
+ find_package(Qt4 4.7.0 REQUIRED) # CMake provides a Qt4 find-module
+ find_package(Qt5Core 5.1.0 REQUIRED) # Qt provides a Qt5 package config file.
+ find_package(LibXml2 REQUIRED) # Use pkg-config via the LibXml2 find-module
+
+In cases where it is known that a package configuration file is provided by
+upstream, and only that should be used, the ``CONFIG`` keyword may be passed
+to :command:`find_package`:
+
+.. code-block:: cmake
+
+ find_package(Qt5Core 5.1.0 CONFIG REQUIRED)
+ find_package(Qt5Gui 5.1.0 CONFIG)
+
+Similarly, the ``MODULE`` keyword says to use only a find-module:
+
+.. code-block:: cmake
+
+ find_package(Qt4 4.7.0 MODULE REQUIRED)
+
+Specifying the type of package explicitly improves the error message shown to
+the user if it is not found.
+
+Both types of packages also support specifying components of a package,
+either after the ``REQUIRED`` keyword:
+
+.. code-block:: cmake
+
+ find_package(Qt5 5.1.0 CONFIG REQUIRED Widgets Xml Sql)
+
+or as a separate ``COMPONENTS`` list:
+
+.. code-block:: cmake
+
+ find_package(Qt5 5.1.0 COMPONENTS Widgets Xml Sql)
+
+or as a separate ``OPTIONAL_COMPONENTS`` list:
+
+.. code-block:: cmake
+
+ find_package(Qt5 5.1.0 COMPONENTS Widgets
+ OPTIONAL_COMPONENTS Xml Sql
+ )
+
+Handling of ``COMPONENTS`` and ``OPTIONAL_COMPONENTS`` is defined by the
+package.
+
+Config-file Packages
+--------------------
+
+A config-file package is a set of files provided by upstreams for downstreams
+to use. CMake searches in a number of locations for package configuration files, as
+described in the :command:`find_package` documentation. The most simple way for
+a CMake user to tell :manual:`cmake(1)` to search in a non-standard prefix for
+a package is to set the ``CMAKE_PREFIX_PATH`` cache variable.
+
+Config-file packages are provided by upstream vendors as part of development
+packages, that is, they belong with the header files and any other files
+provided to assist downsteams in using the package.
+
+A set of variables which provide package status information are also set
+automatically when using a config-file package. The ``<Package>_FOUND``
+variable is set to true or false, depending on whether the package was
+found. The ``<Package>_DIR`` cache variable is set to the location of the
+package configuration file.
+
+Find-module Packages
+--------------------
+
+A find module is a file with a set of rules for finding the required pieces of
+a dependency, primarily header files and libraries. Typically, a find module
+is needed when the upstream is not built with CMake, or is not CMake-aware
+enough to otherwise provide a package configuration file. Unlike a package configuration
+file, it is not shipped with upstream, but is used by downstream to find the
+files by guessing locations of files with platform-specific hints.
+
+Unlike the case of an upstream-provided package configuration file, no single point
+of reference identifies the package as being found, so the ``<Package>_FOUND``
+variable is not automatically set by the :command:`find_package` command. It
+can still be expected to be set by convention however and should be set by
+the author of the Find-module. Similarly there is no ``<Package>_DIR`` variable,
+but each of the artifacts such as library locations and header file locations
+provide a separate cache variable.
+
+See the :manual:`cmake-developer(7)` manual for more information about creating
+Find-module files.
+
+Package Layout
+==============
+
+A config-file package consists of a `Package Configuration File`_ and
+optionally a `Package Version File`_ provided with the project distribution.
+
+Package Configuration File
+--------------------------
+
+Consider a project ``Foo`` that installs the following files::
+
+ <prefix>/include/foo-1.2/foo.h
+ <prefix>/lib/foo-1.2/libfoo.a
+
+It may also provide a CMake package configuration file::
+
+ <prefix>/lib/cmake/foo-1.2/FooConfig.cmake
+
+with content defining :prop_tgt:`IMPORTED` targets, or defining variables, such
+as::
+
+ # ...
+ # (compute PREFIX relative to file location)
+ # ...
+ set(Foo_INCLUDE_DIRS ${PREFIX}/include/foo-1.2)
+ set(Foo_LIBRARIES ${PREFIX}/lib/foo-1.2/libfoo.a)
+
+If another project wishes to use ``Foo`` it need only to locate the ``FooConfig.cmake``
+file and load it to get all the information it needs about package content
+locations. Since the package configuration file is provided by the package
+installation it already knows all the file locations.
+
+The :command:`find_package` command may be used to search for the package
+configuration file. This command constructs a set of installation prefixes
+and searches under each prefix in several locations. Given the name ``Foo``,
+it looks for a file called ``FooConfig.cmake`` or ``foo-config.cmake``.
+The full set of locations is specified in the :command:`find_package` command
+documentation. One place it looks is::
+
+ <prefix>/lib/cmake/Foo*/
+
+where ``Foo*`` is a case-insensitive globbing expression. In our example the
+globbing expression will match ``<prefix>/lib/cmake/foo-1.2`` and the package
+configuration file will be found.
+
+Once found, a package configuration file is immediately loaded. It, together
+with a package version file, contains all the information the project needs to
+use the package.
+
+Package Version File
+--------------------
+
+When the :command:`find_package` command finds a candidate package configuration
+file it looks next to it for a version file. The version file is loaded to test
+whether the package version is an acceptable match for the version requested.
+If the version file claims compatibility the configuration file is accepted.
+Otherwise it is ignored.
+
+The name of the package version file must match that of the package configuration
+file but has either ``-version`` or ``Version`` appended to the name before
+the ``.cmake`` extension. For example, the files::
+
+ <prefix>/lib/cmake/foo-1.3/foo-config.cmake
+ <prefix>/lib/cmake/foo-1.3/foo-config-version.cmake
+
+and::
+
+ <prefix>/lib/cmake/bar-4.2/BarConfig.cmake
+ <prefix>/lib/cmake/bar-4.2/BarConfigVersion.cmake
+
+are each pairs of package configuration files and corresponding package version
+files.
+
+When the :command:`find_package` command loads a version file it first sets the
+following variables:
+
+``PACKAGE_FIND_NAME``
+ The <package> name
+
+``PACKAGE_FIND_VERSION``
+ Full requested version string
+
+``PACKAGE_FIND_VERSION_MAJOR``
+ Major version if requested, else 0
+
+``PACKAGE_FIND_VERSION_MINOR``
+ Minor version if requested, else 0
+
+``PACKAGE_FIND_VERSION_PATCH``
+ Patch version if requested, else 0
+
+``PACKAGE_FIND_VERSION_TWEAK``
+ Tweak version if requested, else 0
+
+``PACKAGE_FIND_VERSION_COUNT``
+ Number of version components, 0 to 4
+
+The version file must use these variables to check whether it is compatible or
+an exact match for the requested version and set the following variables with
+results:
+
+``PACKAGE_VERSION``
+ Full provided version string
+
+``PACKAGE_VERSION_EXACT``
+ True if version is exact match
+
+``PACKAGE_VERSION_COMPATIBLE``
+ True if version is compatible
+
+``PACKAGE_VERSION_UNSUITABLE``
+ True if unsuitable as any version
+
+Version files are loaded in a nested scope so they are free to set any variables
+they wish as part of their computation. The find_package command wipes out the
+scope when the version file has completed and it has checked the output
+variables. When the version file claims to be an acceptable match for the
+requested version the find_package command sets the following variables for
+use by the project:
+
+``<package>_VERSION``
+ Full provided version string
+
+``<package>_VERSION_MAJOR``
+ Major version if provided, else 0
+
+``<package>_VERSION_MINOR``
+ Minor version if provided, else 0
+
+``<package>_VERSION_PATCH``
+ Patch version if provided, else 0
+
+``<package>_VERSION_TWEAK``
+ Tweak version if provided, else 0
+
+``<package>_VERSION_COUNT``
+ Number of version components, 0 to 4
+
+The variables report the version of the package that was actually found.
+The ``<package>`` part of their name matches the argument given to the
+:command:`find_package` command.
+
+Creating Packages
+=================
+
+Usually, the upstream depends on CMake itself and can use some CMake facilities
+for creating the package files. Consider an upstream which provides a single
+shared library:
+
+.. code-block:: cmake
+
+ project(UpstreamLib)
+
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+ set(Upstream_VERSION 3.4.1)
+
+ include(GenerateExportHeader)
+
+ add_library(ClimbingStats SHARED climbingstats.cpp)
+ generate_export_header(ClimbingStats)
+
+ install(TARGETS ClimbingStats EXPORT ClimbingStatsTargets
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ INCLUDES DESTINATION include
+ )
+ install(
+ FILES
+ climbingstats.h
+ "${CMAKE_CURRENT_BINARY_DIR}/climbingstats_export.h"
+ DESTINATION
+ include
+ COMPONENT
+ Devel
+ )
+
+ include(CMakePackageConfigHelpers)
+ write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/ClimbingStatsConfigVersion.cmake"
+ VERSION ${Upstream_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+ set(ConfigPackageLocation lib/cmake/ClimbingStats)
+ install(EXPORT ClimbingStatsTargets
+ FILE
+ ClimbingStatsTargets.cmake
+ NAMESPACE
+ Upstream::
+ DESTINATION
+ ${ConfigPackageLocation}
+ )
+ install(
+ FILES
+ cmake/ClimbingStatsConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/ClimbingStatsConfigVersion.cmake"
+ DESTINATION
+ ${ConfigPackageLocation}
+ COMPONENT
+ Devel
+ )
+
+The :module:`CMakePackageConfigHelpers` module provides a macro for creating
+a simple ``ConfigVersion.cmake`` file. This file sets the version of the
+package. It is read by CMake when :command:`find_package` is called to
+determine the compatibility with the requested version, and to set some
+version-specific variables ``<Package>_VERSION``, ``<Package>_VERSION_MAJOR``,
+``<Package>_VERSION_MINOR`` etc. The :command:`install(EXPORT)` command is
+used to export the targets in the ``ClimbingStatsTargets`` export-set, defined
+previously by the :command:`install(TARGETS)` command. This command generates
+the ``ClimbingStatsTargets.cmake`` file to contain :prop_tgt:`IMPORTED`
+targets, suitable for use by downsteams and arranges to install it to
+``lib/cmake/ClimbingStats``. The generated ``ClimbingStatsConfigVersion.cmake``
+and a ``cmake/ClimbingStatsConfig.cmake`` are installed to the same location,
+completing the package.
+
+A ``NAMESPACE`` with double-colons is specified when exporting the targets
+for installation. This convention of double-colons gives CMake a hint that
+the name is an :prop_tgt:`IMPORTED` target when it is used by downstreams
+with the :command:`target_link_libraries` command. This way, CMake can
+issue a diagnostic if the package providing it has not yet been found.
+
+In this case, when using :command:`install(TARGETS)` the ``INCLUDES DESTINATION``
+was specified. This causes the ``IMPORTED`` targets to have their
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` populated with the ``include``
+directory in the :variable:`CMAKE_INSTALL_PREFIX`. When the ``IMPORTED``
+target is used by downsteam, it automatically consumes the entries from
+that property.
+
+In this case, the ``ClimbingStatsConfig.cmake`` file could be as simple as:
+
+.. code-block:: cmake
+
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+
+As this allows downstreams to use the ``IMPORTED`` targets. If any macros
+should be provided by the ``ClimbingStats`` package, they should
+be in a separate file which is installed to the same location as the
+``ClimbingStatsConfig.cmake`` file, and included from there.
+
+This can also be extended to cover dependencies:
+
+.. code-block:: cmake
+
+ # ...
+ add_library(ClimbingStats SHARED climbingstats.cpp)
+ generate_export_header(ClimbingStats)
+
+ find_package(Stats 2.6.4 REQUIRED)
+ target_link_libraries(ClimbingStats PUBLIC Stats::Types)
+
+As the ``Stats::Types`` target is a ``PUBLIC`` dependency of ``ClimbingStats``,
+downsteams must also find the ``Stats`` package and link to the ``Stats::Types``
+library. The ``Stats`` package should be found in the ``ClimbingStatsConfig.cmake``
+file to ensure this. The ``find_dependency`` macro from the
+:module:`CMakeFindDependencyMacro` helps with this by propagating
+whether the package is ``REQUIRED``, or ``QUIET`` etc. All ``REQUIRED``
+dependencies of a package should be found in the ``Config.cmake`` file:
+
+.. code-block:: cmake
+
+ include(CMakePackageConfigHelpers)
+ find_dependency(Stats 2.6.4)
+
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
+
+The ``find_dependency`` macro also sets ``ClimbingStats_FOUND`` to ``False`` if
+the dependency is not found, along with a diagnostic that the ``ClimbingStats``
+package can not be used without the ``Stats`` package.
+
+If ``COMPONENTS`` are specified when the downstream uses :command:`find_package`,
+they are listed in the ``<Package>_FIND_COMPONENTS`` variable. If a particular
+component is non-optional, then the ``<Package>_FIND_REQUIRED_<comp>`` will
+be true. This can be tested with logic in the package configuration file:
+
+.. code-block:: cmake
+
+ include(CMakePackageConfigHelpers)
+ find_dependency(Stats 2.6.4)
+
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
+
+ set(_supported_components Plot Table)
+
+ foreach(_comp ${ClimbingStats_FIND_COMPONENTS})
+ if (NOT ";${_supported_components};" MATCHES _comp)
+ set(ClimbingStats_FOUND False)
+ set(ClimbingStats_NOTFOUND_MESSAGE "Specified unsupported component: ${_comp}")
+ endif()
+ include("${CMAKE_CURRENT_LIST_DIR}ClimbingStats${_comp}Targets.cmake")
+ endforeach()
+
+Here, the ``ClimbingStats_NOTFOUND_MESSAGE`` is set to a diagnosis that the package
+could not be found because an invalid component was specified. This message
+variable can be set for any case where the ``_FOUND`` variable is set to ``False``,
+and will be displayed to the user.
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 1e57495..d467c36 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -21,7 +21,21 @@ for a policy, also avoiding the warning.
The :command:`cmake_minimum_required` command does more than report an
error if a too-old version of CMake is used to build a project. It
also sets all policies introduced in that CMake version or earlier to
-NEW behavior.
+NEW behavior. To manage policies without increasing the minimum required
+CMake version, the :command:`if(POLICY)` command may be used::
+
+ if(POLICY CMP0990)
+ cmake_policy(SET CMP0990 NEW)
+ endif()
+
+This has the effect of using the NEW behavior with newer CMake releases which
+users may be using and not issuing a compatibility warning.
+
+The setting of a policy is confined in some cases to not propagate to the
+parent scope. For example, if the files read by the :command:`include` command
+or the :command:`find_package` command contain a use of :command:`cmake_policy`,
+that policy setting will not affect the caller by default. Both commands accept
+an optional ``NO_POLICY_SCOPE`` keyword to control this behavior.
The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
to determine whether to report an error on use of deprecated macros or
diff --git a/Help/module/CMakeFindDependencyMacro.rst b/Help/module/CMakeFindDependencyMacro.rst
new file mode 100644
index 0000000..5b5b550
--- /dev/null
+++ b/Help/module/CMakeFindDependencyMacro.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CMakeFindDependencyMacro.cmake
diff --git a/Help/policy/CMP0024.rst b/Help/policy/CMP0024.rst
index 4c8c714..abfcc75 100644
--- a/Help/policy/CMP0024.rst
+++ b/Help/policy/CMP0024.rst
@@ -11,7 +11,7 @@ until later at generate-time, such as the link language and complete
list of link libraries. Future refactoring will change the effect of
the export() command to be executed at generate-time. Use ALIAS
targets instead in cases where the goal is to refer to targets by
-another name
+another name.
The OLD behavior for this policy is to allow including the result of
an export() command. The NEW behavior for this policy is to not to
diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst
index 059b2e6..f4d2f4e 100644
--- a/Help/policy/CMP0037.rst
+++ b/Help/policy/CMP0037.rst
@@ -11,7 +11,7 @@ diagnostics expect target names to match a restricted pattern.
Target names may contain upper and lower case letters, numbers, the underscore
character (_), dot(.), plus(+) and minus(-). As a special case, ALIAS
-targets and INTERFACE library targets may contain two consequtive colons.
+targets and IMPORTED targets may contain two consequtive colons.
Target names reserved by one or more CMake generators are not allowed.
Among others these include "all", "help" and "test".
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
index 6b17f6e..11aed0c 100644
--- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
+++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
@@ -5,7 +5,9 @@ Enables tracing output for target properties.
This variable can be populated with a list of properties to generate
debug output for when evaluating target properties. Currently it can
-only be used when evaluating the INCLUDE_DIRECTORIES,
-COMPILE_DEFINITIONS, COMPILE_OPTIONS and AUTOUIC_OPTIONS target properties.
-In that case, it outputs a backtrace for each entry in the target property.
+only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
+:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`,
+:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
+listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_``
+properties. It outputs an origin for each entry in the target property.
Default is unset.
diff --git a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst
index 451ce8c..2420a25 100644
--- a/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst
+++ b/Help/variable/CMAKE_VERBOSE_MAKEFILE.rst
@@ -1,8 +1,9 @@
CMAKE_VERBOSE_MAKEFILE
----------------------
-Create verbose makefiles if on.
+Enable verbose output from Makefile builds.
-This variable defaults to false. You can set this variable to true to
-make CMake produce verbose makefiles that show each command line as it
-is used.
+This variable is a cache entry initialized (to FALSE) by
+the :command:`project` command. Users may enable the option
+in their local build tree to get more verbose output from
+Makefile builds and show each command line as it is launched.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 518b8c6..2bcf3d1 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -232,7 +232,7 @@ Id flags: ${testflags}
# ...
# /path/to/cc ...CompilerId${lang}/...
# to extract the compiler front-end for the language.
- if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/\\./CompilerId${lang}[ \t\n\\\"]")
+ if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/(\\./)?CompilerId${lang}[ \t\n\\\"]")
set(_comp "${CMAKE_MATCH_2}")
if(EXISTS "${_comp}")
set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE)
diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake
new file mode 100644
index 0000000..596c6fc
--- /dev/null
+++ b/Modules/CMakeFindDependencyMacro.cmake
@@ -0,0 +1,58 @@
+#.rst:
+# CMakeFindDependencyMacro
+# -------------------------
+#
+# ::
+#
+# find_dependency(<dep> [<version>])
+#
+#
+# ``find_dependency()`` wraps a :command:`find_package` call for a package
+# dependency. It is designed to be used in a <package>Config.cmake file, and it
+# forwards the correct parameters for EXACT, QUIET and REQUIRED which were
+# passed to the original :command:`find_package` call. It also sets an
+# informative diagnostic message if the dependency could not be found.
+#
+
+#=============================================================================
+# Copyright 2013 Stephen Kelly <steveire@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+macro(find_dependency dep)
+ if (NOT ${dep}_FOUND)
+ if (${ARGV1})
+ set(version ${ARGV1})
+ endif()
+ set(exact_arg)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
+ set(exact_arg EXACT)
+ endif()
+ set(quiet_arg)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ set(quiet_arg QUIET)
+ endif()
+ set(required_arg)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ set(required_arg REQUIRED)
+ endif()
+
+ find_package(${dep} ${version} ${exact_arg} ${quiet_arg} ${required_arg})
+ if (NOT ${dep}_FOUND)
+ set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
+ endif()
+ set(required_arg)
+ set(quiet_arg)
+ set(exact_arg)
+ endif()
+endmacro()
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index 855af9c..2c1c613 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -196,11 +196,13 @@
include(CMakeParseArguments)
include(WriteBasicConfigVersionFile)
+include(CMakeFindDependencyMacro)
macro(WRITE_BASIC_PACKAGE_VERSION_FILE)
write_basic_config_version_file(${ARGN})
endmacro()
+set(cfpch_dir ${CMAKE_CURRENT_LIST_DIR})
function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_FIND_DEPENDENCY_MACRO)
@@ -290,37 +292,8 @@ endmacro()
endif()
if(NOT CCF_NO_FIND_DEPENDENCY_MACRO)
- set(PACKAGE_INIT "${PACKAGE_INIT}
-macro(find_dependency dep)
- if (NOT \${dep}_FOUND)
- if (\${ARGV1})
- set(version \${ARGV1})
- endif()
- set(exact_arg)
- if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
- set(exact_arg EXACT)
- endif()
- set(quiet_arg)
- if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
- set(quiet_arg QUIET)
- endif()
- set(required_arg)
- if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
- set(required_arg REQUIRED)
- endif()
-
- find_package(\${dep} \${version} \${exact_arg} \${quiet_arg} \${required_arg})
- if (NOT \${dep}_FOUND)
- set(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE \"\${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency \${dep} could not be found.\")
- set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
- return()
- endif()
- set(required_arg)
- set(quiet_arg)
- set(exact_arg)
- endif()
-endmacro()
-")
+ file(READ "${cfpch_dir}/CMakeFindDependencyMacro.cmake" find_dependency_macro)
+ set(PACKAGE_INIT "${PACKAGE_INIT} ${find_dependency_macro}")
endif()
set(PACKAGE_INIT "${PACKAGE_INIT}
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
index 237c5bc..d9e0ba7 100644
--- a/Modules/CPackWIX.cmake
+++ b/Modules/CPackWIX.cmake
@@ -116,6 +116,57 @@
# If this variable is not set, the default MSI template included with CMake
# will be used.
#
+# .. variable:: CPACK_WIX_PATCH_FILE
+#
+# Optional XML file with fragments to be inserted into generated WiX sources
+#
+# This optional variable can be used to specify an XML file that the
+# WiX generator will use to inject fragments into its generated
+# source files.
+#
+# Patch files understood by the CPack WiX generator
+# roughly follow this RELAX NG compact schema:
+#
+# .. code-block:: none
+#
+# start = CPackWiXPatch
+#
+# CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* }
+#
+# CPackWiXFragment = element CPackWiXFragment
+# {
+# attribute Id { string },
+# fragmentContent*
+# }
+#
+# fragmentContent = element * - CPackWiXFragment
+# {
+# (attribute * { text } | text | fragmentContent)*
+# }
+#
+# Currently fragments can be injected into most
+# Component, File and Directory elements.
+#
+# The following example illustrates how this works.
+#
+# Given that the WiX generator creates the following XML element:
+#
+# .. code-block:: xml
+#
+# <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/>
+#
+# The following XML patch file may be used to inject an Environment element
+# into it:
+#
+# .. code-block:: xml
+#
+# <CPackWiXPatch>
+# <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe">
+# <Environment Id="MyEnvironment" Action="set"
+# Name="MyVariableName" Value="MyVariableValue"/>
+# </CPackWiXFragment>
+# </CPackWiXPatch>
+#
# .. variable:: CPACK_WIX_EXTRA_SOURCES
#
# Extra WiX source files
diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake
index 56e739e..83789cc 100644
--- a/Modules/FindBacktrace.cmake
+++ b/Modules/FindBacktrace.cmake
@@ -58,17 +58,20 @@ endif(Backtrace_HEADER)
find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}")
set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
-# First, check if we already have backtrace(), e.g., in libc
-cmake_push_check_state(RESET)
-set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
-check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
-cmake_pop_check_state()
+if (NOT DEFINED Backtrace_LIBRARY)
+ # First, check if we already have backtrace(), e.g., in libc
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
+ check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
+ cmake_pop_check_state()
+endif()
if(_Backtrace_SYM_FOUND)
- set(Backtrace_LIBRARY)
- if(NOT Backtrace_FIND_QUIETLY)
+ # Avoid repeating the message() call below each time CMake is run.
+ if(NOT Backtrace_FIND_QUIETLY AND NOT DEFINED Backtrace_LIBRARY)
message(STATUS "backtrace facility detected in default set of libraries")
endif()
+ set(Backtrace_LIBRARY "" CACHE FILEPATH "Library providing backtrace(3), empty for default set of libraries")
else()
# Check for external library, for non-glibc systems
if(Backtrace_INCLUDE_DIR)
diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake
index 179dc00..6f03c86 100644
--- a/Modules/FindFreetype.cmake
+++ b/Modules/FindFreetype.cmake
@@ -65,7 +65,10 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
PATH_SUFFIXES include/freetype2 include
)
-find_path(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
+find_path(FREETYPE_INCLUDE_DIR_freetype2
+ NAMES
+ freetype/config/ftheader.h
+ config/ftheader.h
HINTS
ENV FREETYPE_DIR
PATHS
@@ -97,11 +100,18 @@ find_library(FREETYPE_LIBRARY
# set the user variables
if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
+ list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS)
endif()
set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
-if(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
- file(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str
+if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+ set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h")
+ set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h")
+endif()
+
+if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
+ file(STRINGS "${FREETYPE_H}" freetype_version_str
REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
unset(FREETYPE_VERSION_STRING)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 24747f7..28b8454 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -1203,6 +1203,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
"${QT_MKSPECS_DIR}/default"
${QT_INCLUDE_DIR}
)
+ set_property(TARGET Qt4::QtCore APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS
+ $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>
+ )
set_property(TARGET Qt4::QtCore PROPERTY
INTERFACE_QT_MAJOR_VERSION 4
)
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake
index 2338721..0d13318 100644
--- a/Modules/FindSubversion.cmake
+++ b/Modules/FindSubversion.cmake
@@ -73,6 +73,8 @@
# License text for the above reference.)
find_program(Subversion_SVN_EXECUTABLE svn
+ PATHS
+ [HKEY_LOCAL_MACHINE\\Software\\TortoiseSVN;Directory]/bin
DOC "subversion command line client")
mark_as_advanced(Subversion_SVN_EXECUTABLE)
diff --git a/Modules/Platform/MirBSD.cmake b/Modules/Platform/MirBSD.cmake
new file mode 100644
index 0000000..7637f9b
--- /dev/null
+++ b/Modules/Platform/MirBSD.cmake
@@ -0,0 +1 @@
+include(Platform/OpenBSD)
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index b5f005f..fd9819f 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -120,6 +120,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
if(moc_target)
+ set (_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>)
set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake
index 2bcbea6..c814187 100644
--- a/Modules/TestCXXAcceptsFlag.cmake
+++ b/Modules/TestCXXAcceptsFlag.cmake
@@ -2,16 +2,18 @@
# TestCXXAcceptsFlag
# ------------------
#
-# Test CXX compiler for a flag
+# Deprecated. See :module:`CheckCXXCompilerFlag`.
#
-# Check if the CXX compiler accepts a flag
+# Check if the CXX compiler accepts a flag.
#
-# ::
+# .. code-block:: cmake
#
-# Macro CHECK_CXX_ACCEPTS_FLAG(FLAGS VARIABLE) -
-# checks if the function exists
-# FLAGS - the flags to try
-# VARIABLE - variable to store the result
+# CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
+#
+# ``<flags>``
+# the flags to try
+# ``<variable>``
+# variable to store the result
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 17fb52d..3c944fb 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -517,6 +517,7 @@ if(WIN32)
CPack/WiX/cmCPackWIXGenerator.cxx
CPack/WiX/cmWIXSourceWriter.cxx
CPack/WiX/cmWIXRichTextFormatWriter.cxx
+ CPack/WiX/cmWIXPatchParser.cxx
)
endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index a2c6fcc..5cb27c8 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -2,5 +2,5 @@
set(CMake_VERSION_MAJOR 2)
set(CMake_VERSION_MINOR 8)
set(CMake_VERSION_PATCH 12)
-set(CMake_VERSION_TWEAK 20131218)
+set(CMake_VERSION_TWEAK 20140102)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 1b9b20a..c1749ac 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -85,8 +85,8 @@ bool cmCPackWIXGenerator::RunCandleCommand(
command << " -arch " << GetArchitecture();
command << " -out " << QuotePath(objectFile);
- for(extension_set_t::const_iterator i = candleExtensions.begin();
- i != candleExtensions.end(); ++i)
+ for(extension_set_t::const_iterator i = CandleExtensions.begin();
+ i != CandleExtensions.end(); ++i)
{
command << " -ext " << QuotePath(*i);
}
@@ -111,8 +111,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
- for(extension_set_t::const_iterator i = lightExtensions.begin();
- i != lightExtensions.end(); ++i)
+ for(extension_set_t::const_iterator i = LightExtensions.begin();
+ i != LightExtensions.end(); ++i)
{
command << " -ext " << QuotePath(*i);
}
@@ -211,12 +211,18 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
}
- CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions);
- CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions);
+ CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
+ CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
- lightExtensions.insert("WixUIExtension");
- CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions);
- CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions);
+ LightExtensions.insert("WixUIExtension");
+ CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
+ CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
+
+ const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
+ if(patchFilePath)
+ {
+ LoadPatchFragments(patchFilePath);
+ }
return true;
}
@@ -241,9 +247,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
AppendUserSuppliedExtraSources();
std::stringstream objectFiles;
- for(size_t i = 0; i < wixSources.size(); ++i)
+ for(size_t i = 0; i < WixSources.size(); ++i)
{
- const std::string& sourceFilename = wixSources[i];
+ const std::string& sourceFilename = WixSources[i];
std::string objectFilename =
cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@@ -266,7 +272,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
if(!cpackWixExtraSources) return;
- cmSystemTools::ExpandListArgument(cpackWixExtraSources, wixSources);
+ cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@@ -345,7 +351,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string directoryDefinitionsFilename =
cpackTopLevel + "/directories.wxs";
- wixSources.push_back(directoryDefinitionsFilename);
+ WixSources.push_back(directoryDefinitionsFilename);
cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment");
@@ -400,7 +406,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string fileDefinitionsFilename =
cpackTopLevel + "/files.wxs";
- wixSources.push_back(fileDefinitionsFilename);
+ WixSources.push_back(fileDefinitionsFilename);
cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment");
@@ -408,7 +414,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string featureDefinitionsFilename =
cpackTopLevel +"/features.wxs";
- wixSources.push_back(featureDefinitionsFilename);
+ WixSources.push_back(featureDefinitionsFilename);
cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment");
@@ -527,7 +533,29 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
- wixSources.push_back(mainSourceFilePath);
+ WixSources.push_back(mainSourceFilePath);
+
+ std::string fragmentList;
+ for(cmWIXPatchParser::fragment_map_t::const_iterator
+ i = Fragments.begin(); i != Fragments.end(); ++i)
+ {
+ if(!fragmentList.empty())
+ {
+ fragmentList += ", ";
+ }
+
+ fragmentList += "'";
+ fragmentList += i->first;
+ fragmentList += "'";
+ }
+
+ if(fragmentList.size())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Some XML patch fragments did not have matching IDs: " <<
+ fragmentList << std::endl);
+ return false;
+ }
return true;
}
@@ -737,7 +765,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.EndElement("RemoveFolder");
std::string registryKey =
- std::string("Software/") + cpackVendor + "/" + cpackPackageName;
+ std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
fileDefinitions.BeginElement("RegistryValue");
fileDefinitions.AddAttribute("Root", "HKCU");
@@ -872,6 +900,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
packageExecutables,
shortcutMap);
+ ApplyPatchFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory");
}
else
@@ -891,7 +920,10 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
fileDefinitions.AddAttribute("Source", fullPath);
fileDefinitions.AddAttribute("KeyPath", "yes");
+ ApplyPatchFragment(fileId, fileDefinitions);
fileDefinitions.EndElement("File");
+
+ ApplyPatchFragment(componentId, fileDefinitions);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
@@ -986,8 +1018,8 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
std::string cmCPackWIXGenerator::PathToId(const std::string& path)
{
- id_map_t::const_iterator i = pathToIdMap.find(path);
- if(i != pathToIdMap.end()) return i->second;
+ id_map_t::const_iterator i = PathToIdMap.find(path);
+ if(i != PathToIdMap.end()) return i->second;
std::string id = CreateNewIdForPath(path);
return id;
@@ -1024,7 +1056,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
std::stringstream result;
result << idPrefix << "_" << identifier;
- size_t ambiguityCount = ++idAmbiguityCounter[identifier];
+ size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
if(ambiguityCount > 999)
{
@@ -1041,7 +1073,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
std::string resultString = result.str();
- pathToIdMap[path] = resultString;
+ PathToIdMap[path] = resultString;
return resultString;
}
@@ -1146,3 +1178,45 @@ void cmCPackWIXGenerator::CreateStartMenuFolder(
directoryDefinitions.EndElement("Directory");
}
+
+void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
+{
+ cmWIXPatchParser parser(Fragments, Logger);
+ parser.ParseFile(patchFilePath.c_str());
+}
+
+void cmCPackWIXGenerator::ApplyPatchFragment(
+ const std::string& id, cmWIXSourceWriter& writer)
+{
+ cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
+ if(i == Fragments.end()) return;
+
+ const cmWIXPatchElement& fragment = i->second;
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ j = fragment.children.begin(); j != fragment.children.end(); ++j)
+ {
+ ApplyPatchElement(**j, writer);
+ }
+
+ Fragments.erase(i);
+}
+
+void cmCPackWIXGenerator::ApplyPatchElement(
+ const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+{
+ writer.BeginElement(element.name);
+
+ for(cmWIXPatchElement::attributes_t::const_iterator
+ i = element.attributes.begin(); i != element.attributes.end(); ++i)
+ {
+ writer.AddAttribute(i->first, i->second);
+ }
+
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ i = element.children.begin(); i != element.children.end(); ++i)
+ {
+ ApplyPatchElement(**i, writer);
+ }
+
+ writer.EndElement(element.name);
+}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 84f68b6..0a85ae2 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -13,6 +13,8 @@
#ifndef cmCPackWIXGenerator_h
#define cmCPackWIXGenerator_h
+#include "cmWIXPatchParser.h"
+
#include <CPack/cmCPackGenerator.h>
#include <string>
@@ -160,12 +162,21 @@ private:
void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
- std::vector<std::string> wixSources;
- id_map_t pathToIdMap;
- ambiguity_map_t idAmbiguityCounter;
+ void LoadPatchFragments(const std::string& patchFilePath);
+
+ void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
+
+ void ApplyPatchElement(const cmWIXPatchElement& element,
+ cmWIXSourceWriter& writer);
+
+ std::vector<std::string> WixSources;
+ id_map_t PathToIdMap;
+ ambiguity_map_t IdAmbiguityCounter;
+
+ extension_set_t CandleExtensions;
+ extension_set_t LightExtensions;
- extension_set_t candleExtensions;
- extension_set_t lightExtensions;
+ cmWIXPatchParser::fragment_map_t Fragments;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
new file mode 100644
index 0000000..7ceaf1f
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -0,0 +1,145 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmWIXPatchParser.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+#include <cm_expat.h>
+
+cmWIXPatchElement::~cmWIXPatchElement()
+{
+ for(child_list_t::iterator i = children.begin(); i != children.end(); ++i)
+ {
+ delete *i;
+ }
+}
+
+cmWIXPatchParser::cmWIXPatchParser(
+ fragment_map_t& fragments, cmCPackLog* logger):
+ Logger(logger),
+ State(BEGIN_DOCUMENT),
+ Valid(true),
+ Fragments(fragments)
+{
+
+}
+
+void cmWIXPatchParser::StartElement(const char *name, const char **atts)
+{
+ std::string name_str = name;
+ if(State == BEGIN_DOCUMENT)
+ {
+ if(name_str == "CPackWiXPatch")
+ {
+ State = BEGIN_FRAGMENTS;
+ }
+ else
+ {
+ ReportValidationError("Expected root element 'CPackWiXPatch'");
+ }
+ }
+ else if(State == BEGIN_FRAGMENTS)
+ {
+ if(name_str == "CPackWiXFragment")
+ {
+ State = INSIDE_FRAGMENT;
+ StartFragment(atts);
+ }
+ else
+ {
+ ReportValidationError("Expected 'CPackWixFragment' element");
+ }
+ }
+ else if(State == INSIDE_FRAGMENT)
+ {
+ cmWIXPatchElement &parent = *ElementStack.back();
+
+ parent.children.resize(parent.children.size() + 1);
+ cmWIXPatchElement*& currentElement = parent.children.back();
+ currentElement = new cmWIXPatchElement;
+ currentElement->name = name;
+
+ for(size_t i = 0; atts[i]; i += 2)
+ {
+ std::string key = atts[i];
+ std::string value = atts[i+1];
+
+ currentElement->attributes[key] = value;
+ }
+
+ ElementStack.push_back(currentElement);
+ }
+}
+
+void cmWIXPatchParser::StartFragment(const char **attributes)
+{
+ for(size_t i = 0; attributes[i]; i += 2)
+ {
+ std::string key = attributes[i];
+ std::string value = attributes[i+1];
+
+ if(key == "Id")
+ {
+ if(Fragments.find(value) != Fragments.end())
+ {
+ std::stringstream tmp;
+ tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
+ ReportValidationError(tmp.str());
+ }
+
+ ElementStack.push_back(&Fragments[value]);
+ }
+ else
+ {
+ ReportValidationError(
+ "The only allowed 'CPackWixFragment' attribute is 'Id'");
+ }
+ }
+}
+
+void cmWIXPatchParser::EndElement(const char *name)
+{
+ std::string name_str = name;
+ if(State == INSIDE_FRAGMENT)
+ {
+ if(name_str == "CPackWiXFragment")
+ {
+ State = BEGIN_FRAGMENTS;
+ ElementStack.clear();
+ }
+ else
+ {
+ ElementStack.pop_back();
+ }
+ }
+}
+
+void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
+{
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while processing XML patch file at " << line << ":" << column <<
+ ": "<< msg << std::endl);
+ Valid = false;
+}
+
+void cmWIXPatchParser::ReportValidationError(const std::string& message)
+{
+ ReportError(XML_GetCurrentLineNumber(Parser),
+ XML_GetCurrentColumnNumber(Parser),
+ message.c_str());
+}
+
+bool cmWIXPatchParser::IsValid() const
+{
+ return Valid;
+}
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
new file mode 100644
index 0000000..91b3b66
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -0,0 +1,75 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmCPackWIXPatchParser_h
+#define cmCPackWIXPatchParser_h
+
+#include <cmXMLParser.h>
+
+#include <CPack/cmCPackLog.h>
+
+#include <map>
+#include <list>
+
+struct cmWIXPatchElement
+{
+ ~cmWIXPatchElement();
+
+ typedef std::list<cmWIXPatchElement*> child_list_t;
+ typedef std::map<std::string, std::string> attributes_t;
+
+ std::string name;
+ child_list_t children;
+ attributes_t attributes;
+};
+
+/** \class cmWIXPatchParser
+ * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE)
+ */
+class cmWIXPatchParser : public cmXMLParser
+{
+public:
+ typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
+
+ cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
+
+private:
+ virtual void StartElement(const char *name, const char **atts);
+
+ void StartFragment(const char **attributes);
+
+ virtual void EndElement(const char *name);
+ virtual void ReportError(int line, int column, const char* msg);
+
+ void ReportValidationError(const std::string& message);
+
+ bool IsValid() const;
+
+ cmCPackLog* Logger;
+
+ enum ParserState
+ {
+ BEGIN_DOCUMENT,
+ BEGIN_FRAGMENTS,
+ INSIDE_FRAGMENT
+ };
+
+ ParserState State;
+
+ bool Valid;
+
+ fragment_map_t& Fragments;
+
+ std::list<cmWIXPatchElement*> ElementStack;
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index 774c22c..886b534 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -16,7 +16,7 @@
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
const std::string& filename):
- file(filename.c_str(), std::ios::binary)
+ File(filename.c_str(), std::ios::binary)
{
StartGroup();
WriteHeader();
@@ -29,8 +29,8 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
/* I haven't seen this in the RTF spec but
* wordpad terminates its RTF like this */
- file << "\r\n";
- file.put(0);
+ File << "\r\n";
+ File.put(0);
}
void cmWIXRichTextFormatWriter::AddText(const std::string& text)
@@ -44,16 +44,16 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text)
switch(c)
{
case '\\':
- file << "\\\\";
+ File << "\\\\";
break;
case '{':
- file << "\\{";
+ File << "\\{";
break;
case '}':
- file << "\\}";
+ File << "\\}";
break;
case '\n':
- file << "\\par\r\n";
+ File << "\\par\r\n";
break;
case '\r':
continue;
@@ -61,11 +61,11 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text)
{
if(c <= 0x7F)
{
- file << c;
+ File << c;
}
else
{
- file << "[NON-ASCII-" << int(c) << "]";
+ File << "[NON-ASCII-" << int(c) << "]";
}
}
break;
@@ -103,7 +103,7 @@ void cmWIXRichTextFormatWriter::WriteGenerator()
{
StartGroup();
NewControlWord("generator");
- file << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");";
+ File << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");";
EndGroup();
}
@@ -118,20 +118,20 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
{
- file << "\\" << keyword;
+ File << "\\" << keyword;
}
void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
{
- file << "\\*\\" << keyword;
+ File << "\\*\\" << keyword;
}
void cmWIXRichTextFormatWriter::StartGroup()
{
- file.put('{');
+ File.put('{');
}
void cmWIXRichTextFormatWriter::EndGroup()
{
- file.put('}');
+ File.put('}');
}
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index 10b67c3..bb8580a 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -40,7 +40,7 @@ private:
void StartGroup();
void EndGroup();
- std::ofstream file;
+ std::ofstream File;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index c8a3922..e83c226 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -20,9 +20,9 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
const std::string& filename,
bool isIncludeFile):
Logger(logger),
- file(filename.c_str()),
- state(DEFAULT),
- sourceFilename(filename)
+ File(filename.c_str()),
+ State(DEFAULT),
+ SourceFilename(filename)
{
WriteXMLDeclaration();
@@ -40,79 +40,79 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
cmWIXSourceWriter::~cmWIXSourceWriter()
{
- if(elements.size() > 1)
+ if(Elements.size() > 1)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
- elements.size() - 1 << " WiX elements were still open when closing '" <<
- sourceFilename << "'" << std::endl);
+ Elements.size() - 1 << " WiX elements were still open when closing '" <<
+ SourceFilename << "'" << std::endl);
return;
}
- EndElement(elements.back());
+ EndElement(Elements.back());
}
void cmWIXSourceWriter::BeginElement(const std::string& name)
{
- if(state == BEGIN)
+ if(State == BEGIN)
{
- file << ">";
+ File << ">";
}
- file << "\n";
- Indent(elements.size());
- file << "<" << name;
+ File << "\n";
+ Indent(Elements.size());
+ File << "<" << name;
- elements.push_back(name);
- state = BEGIN;
+ Elements.push_back(name);
+ State = BEGIN;
}
void cmWIXSourceWriter::EndElement(std::string const& name)
{
- if(elements.empty())
+ if(Elements.empty())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not end WiX element with no open elements in '" <<
- sourceFilename << "'" << std::endl);
+ SourceFilename << "'" << std::endl);
return;
}
- if(elements.back() != name)
+ if(Elements.back() != name)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "WiX element <" << elements.back() <<
+ "WiX element <" << Elements.back() <<
"> can not be closed by </" << name << "> in '" <<
- sourceFilename << "'" << std::endl);
+ SourceFilename << "'" << std::endl);
return;
}
- if(state == DEFAULT)
+ if(State == DEFAULT)
{
- file << "\n";
- Indent(elements.size()-1);
- file << "</" << elements.back() << ">";
+ File << "\n";
+ Indent(Elements.size()-1);
+ File << "</" << Elements.back() << ">";
}
else
{
- file << "/>";
+ File << "/>";
}
- elements.pop_back();
- state = DEFAULT;
+ Elements.pop_back();
+ State = DEFAULT;
}
void cmWIXSourceWriter::AddProcessingInstruction(
const std::string& target, const std::string& content)
{
- if(state == BEGIN)
+ if(State == BEGIN)
{
- file << ">";
+ File << ">";
}
- file << "\n";
- Indent(elements.size());
- file << "<?" << target << " " << content << "?>";
+ File << "\n";
+ Indent(Elements.size());
+ File << "<?" << target << " " << content << "?>";
- state = DEFAULT;
+ State = DEFAULT;
}
void cmWIXSourceWriter::AddAttribute(
@@ -120,7 +120,7 @@ void cmWIXSourceWriter::AddAttribute(
{
std::string utf8 = WindowsCodepageToUtf8(value);
- file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
+ File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
}
void cmWIXSourceWriter::AddAttributeUnlessEmpty(
@@ -172,14 +172,14 @@ std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
void cmWIXSourceWriter::WriteXMLDeclaration()
{
- file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+ File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
}
void cmWIXSourceWriter::Indent(size_t count)
{
for(size_t i = 0; i < count; ++i)
{
- file << " ";
+ File << " ";
}
}
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 670d4c0..f291d25 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -60,13 +60,13 @@ private:
cmCPackLog* Logger;
- std::ofstream file;
+ std::ofstream File;
- State state;
+ State State;
- std::vector<std::string> elements;
+ std::vector<std::string> Elements;
- std::string sourceFilename;
+ std::string SourceFilename;
};
#endif
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 31cc393..1be5980 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
}
//----------------------------------------------------------------------------
-cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index,
+cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
const char* name)
{
// Look for a target in the scope of the depender.
cmMakefile* mf = this->Makefile;
if(depender_index >= 0)
{
- if(cmTarget* depender = this->EntryList[depender_index].Target)
+ if(cmTarget const* depender = this->EntryList[depender_index].Target)
{
mf = depender->GetMakefile();
}
}
- cmTarget* tgt = mf->FindTargetToUse(name);
+ cmTarget const* tgt = mf->FindTargetToUse(name);
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
@@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
int count = 2;
for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
- if(cmTarget* target = this->EntryList[*ni].Target)
+ if(cmTarget const* target = this->EntryList[*ni].Target)
{
if(cmTarget::LinkInterface const* iface =
target->GetLinkInterface(this->Config, this->HeadTarget))
@@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
// For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link
// directories.
- if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str()))
+ if(cmTarget const* tgt
+ = this->FindTargetToLink(depender_index, item.c_str()))
{
if(!tgt->IsImported())
{
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index b86c9b2..cf227fb 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -40,7 +40,7 @@ public:
struct LinkEntry
{
std::string Item;
- cmTarget* Target;
+ cmTarget const* Target;
bool IsSharedDep;
bool IsFlag;
LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
@@ -53,7 +53,7 @@ public:
EntryVector const& Compute();
void SetOldLinkDirMode(bool b);
- std::set<cmTarget*> const& GetOldWrongConfigItems() const
+ std::set<cmTarget const*> const& GetOldWrongConfigItems() const
{ return this->OldWrongConfigItems; }
private:
@@ -83,7 +83,7 @@ private:
void AddDirectLinkEntries();
void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs);
- cmTarget* FindTargetToLink(int depender_index, const char* name);
+ cmTarget const* FindTargetToLink(int depender_index, const char* name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
@@ -164,7 +164,7 @@ private:
// Compatibility help.
bool OldLinkDirMode;
void CheckWrongConfigItem(int depender_index, std::string const& item);
- std::set<cmTarget*> OldWrongConfigItems;
+ std::set<cmTarget const*> OldWrongConfigItems;
};
#endif
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 1e21216..6986965 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
}
//----------------------------------------------------------------------------
-std::set<cmTarget*> const&
+std::set<cmTarget const*> const&
cmComputeLinkInformation::GetSharedLibrariesLinked()
{
return this->SharedLibrariesLinked;
@@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute()
// For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link
// directories.
- std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems();
- for(std::set<cmTarget*>::const_iterator i = wrongItems.begin();
+ std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems();
+ for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin();
i != wrongItems.end(); ++i)
{
- cmTarget* tgt = *i;
+ cmTarget const* tgt = *i;
bool implib =
(this->UseImportLibrary &&
(tgt->GetType() == cmTarget::SHARED_LIBRARY));
@@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
}
//----------------------------------------------------------------------------
-void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
+void cmComputeLinkInformation::AddItem(std::string const& item,
+ cmTarget const* tgt)
{
// Compute the proper name to use to link this library.
const char* config = this->Config;
@@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
//----------------------------------------------------------------------------
void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
- cmTarget* tgt)
+ cmTarget const* tgt)
{
// If dropping shared library dependencies, ignore them.
if(this->SharedDependencyMode == SharedDepModeNone)
@@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
//----------------------------------------------------------------------------
void cmComputeLinkInformation::AddTargetItem(std::string const& item,
- cmTarget* target)
+ cmTarget const* target)
{
// This is called to handle a link item that is a full path to a target.
// If the target is not a static library make sure the link type is
@@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath()
//----------------------------------------------------------------------------
void
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
- cmTarget* target)
+ cmTarget const* target)
{
// Ignore targets on Apple where install_name is not @rpath.
// The dependenty library can be found with other means such as
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 1da5495..356e6ed 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -39,11 +39,11 @@ public:
Item(): Value(), IsPath(true), Target(0) {}
Item(Item const& item):
Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
- Item(std::string const& v, bool p, cmTarget* target = 0):
+ Item(std::string const& v, bool p, cmTarget const* target = 0):
Value(v), IsPath(p), Target(target) {}
std::string Value;
bool IsPath;
- cmTarget* Target;
+ cmTarget const* Target;
};
typedef std::vector<Item> ItemVector;
ItemVector const& GetItems();
@@ -57,13 +57,13 @@ public:
void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
std::string GetRPathString(bool for_install);
std::string GetChrpathString();
- std::set<cmTarget*> const& GetSharedLibrariesLinked();
+ std::set<cmTarget const*> const& GetSharedLibrariesLinked();
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
std::string GetRPathLinkString();
private:
- void AddItem(std::string const& item, cmTarget* tgt);
- void AddSharedDepItem(std::string const& item, cmTarget* tgt);
+ void AddItem(std::string const& item, cmTarget const* tgt);
+ void AddSharedDepItem(std::string const& item, cmTarget const* tgt);
// Output information.
ItemVector Items;
@@ -71,7 +71,7 @@ private:
std::vector<std::string> Depends;
std::vector<std::string> FrameworkPaths;
std::vector<std::string> RuntimeSearchPath;
- std::set<cmTarget*> SharedLibrariesLinked;
+ std::set<cmTarget const*> SharedLibrariesLinked;
// Context information.
cmTarget const* Target;
@@ -139,7 +139,7 @@ private:
std::string NoCaseExpression(const char* str);
// Handling of link items.
- void AddTargetItem(std::string const& item, cmTarget* target);
+ void AddTargetItem(std::string const& item, cmTarget const* target);
void AddFullItem(std::string const& item);
bool CheckImplicitDirItem(std::string const& item);
void AddUserItem(std::string const& item, bool pathNotKnown);
@@ -179,7 +179,8 @@ private:
// Runtime path computation.
cmOrderDirectories* OrderRuntimeSearchPath;
- void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target);
+ void AddLibraryRuntimeInfo(std::string const& fullPath,
+ cmTarget const* target);
void AddLibraryRuntimeInfo(std::string const& fullPath);
// Dependent library path computation.
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index cb9e37e..73a8e27 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute()
//----------------------------------------------------------------------------
void
-cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t,
+cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t,
cmTargetDependSet& deps)
{
// Lookup the index for this target. All targets should be known by
// this point.
- std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t);
+ std::map<cmTarget const*, int>::const_iterator tii
+ = this->TargetIndex.find(t);
assert(tii != this->TargetIndex.end());
int i = tii->second;
@@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t,
EdgeList const& nl = this->FinalGraph[i];
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
- cmTarget* dep = this->Targets[*ni];
+ cmTarget const* dep = this->Targets[*ni];
cmTargetDependSet::iterator di = deps.insert(dep).first;
di->SetType(ni->IsStrong());
}
@@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets()
this->GlobalGenerator->GetLocalGenerators();
for(unsigned int i = 0; i < lgens.size(); ++i)
{
- cmTargets& targets = lgens[i]->GetMakefile()->GetTargets();
- for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti)
+ const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets();
+ for(cmTargets::const_iterator ti = targets.begin();
+ ti != targets.end(); ++ti)
{
- cmTarget* target = &ti->second;
+ cmTarget const* target = &ti->second;
int index = static_cast<int>(this->Targets.size());
this->TargetIndex[target] = index;
this->Targets.push_back(target);
@@ -198,7 +200,11 @@ void cmComputeTargetDepends::CollectDepends()
void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{
// Get the depender.
- cmTarget* depender = this->Targets[depender_index];
+ cmTarget const* depender = this->Targets[depender_index];
+ if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ return;
+ }
// Loop over all targets linked directly in all configs.
// We need to make targets depend on the union of all config-specific
@@ -208,15 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
std::set<cmStdString> emitted;
{
std::vector<std::string> tlibs;
- if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- // For INTERFACE_LIBRARY depend on the interface instead.
- depender->GetInterfaceLinkLibraries(0, tlibs, depender);
- }
- else
- {
- depender->GetDirectLinkLibraries(0, tlibs, depender);
- }
+ depender->GetDirectLinkLibraries(0, tlibs, depender);
// A target should not depend on itself.
emitted.insert(depender->GetName());
for(std::vector<std::string>::const_iterator lib = tlibs.begin();
@@ -237,15 +235,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
it != configs.end(); ++it)
{
std::vector<std::string> tlibs;
- if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- // For INTERFACE_LIBRARY depend on the interface instead.
- depender->GetInterfaceLinkLibraries(it->c_str(), tlibs, depender);
- }
- else
- {
- depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
- }
+ depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
+
// A target should not depend on itself.
emitted.insert(depender->GetName());
for(std::vector<std::string>::const_iterator lib = tlibs.begin();
@@ -282,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
- cmTarget* dependee,
+ cmTarget const* dependee,
const char *config,
std::set<cmStdString> &emitted)
{
- cmTarget* depender = this->Targets[depender_index];
+ cmTarget const* depender = this->Targets[depender_index];
if(cmTarget::LinkInterface const* iface =
dependee->GetLinkInterface(config, depender))
{
@@ -311,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
bool linking,
std::set<cmStdString> &emitted)
{
- cmTarget* depender = this->Targets[depender_index];
- cmTarget* dependee =
+ cmTarget const* depender = this->Targets[depender_index];
+ cmTarget const* dependee =
depender->GetMakefile()->FindTargetToUse(dependee_name);
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
@@ -346,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
bool linking)
{
// Get the depender.
- cmTarget* depender = this->Targets[depender_index];
+ cmTarget const* depender = this->Targets[depender_index];
// Check the target's makefile first.
- cmTarget* dependee =
+ cmTarget const* dependee =
depender->GetMakefile()->FindTargetToUse(dependee_name);
// Skip targets that will not really be linked. This is probably a
@@ -370,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
- cmTarget* dependee,
+ cmTarget const* dependee,
bool linking)
{
if(dependee->IsImported())
@@ -380,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
for(std::set<cmStdString>::const_iterator i = utils.begin();
i != utils.end(); ++i)
{
- if(cmTarget* transitive_dependee =
+ if(cmTarget const* transitive_dependee =
dependee->GetMakefile()->FindTargetToUse(i->c_str()))
{
this->AddTargetDepend(depender_index, transitive_dependee, false);
@@ -391,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
{
// Lookup the index for this target. All targets should be known by
// this point.
- std::map<cmTarget*, int>::const_iterator tii =
+ std::map<cmTarget const*, int>::const_iterator tii =
this->TargetIndex.find(dependee);
assert(tii != this->TargetIndex.end());
int dependee_index = tii->second;
@@ -411,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
for(int depender_index = 0; depender_index < n; ++depender_index)
{
EdgeList const& nl = graph[depender_index];
- cmTarget* depender = this->Targets[depender_index];
+ cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n",
depender_index, depender->GetName());
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
int dependee_index = *ni;
- cmTarget* dependee = this->Targets[dependee_index];
+ cmTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
dependee->GetName(), ni->IsStrong()? "strong" : "weak");
}
@@ -504,7 +495,7 @@ cmComputeTargetDepends
{
// Get the depender.
int i = *ci;
- cmTarget* depender = this->Targets[i];
+ cmTarget const* depender = this->Targets[i];
// Describe the depender.
e << " \"" << depender->GetName() << "\" of type "
@@ -517,7 +508,7 @@ cmComputeTargetDepends
int j = *ni;
if(cmap[j] == c)
{
- cmTarget* dependee = this->Targets[j];
+ cmTarget const* dependee = this->Targets[j];
e << " depends on \"" << dependee->GetName() << "\""
<< " (" << (ni->IsStrong()? "strong" : "weak") << ")\n";
}
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index d6131cf..6cd6da0 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -38,19 +38,21 @@ public:
bool Compute();
- std::vector<cmTarget*> const& GetTargets() const { return this->Targets; }
- void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps);
+ std::vector<cmTarget const*> const&
+ GetTargets() const { return this->Targets; }
+ void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps);
private:
void CollectTargets();
void CollectDepends();
void CollectTargetDepends(int depender_index);
void AddTargetDepend(int depender_index, const char* dependee_name,
bool linking);
- void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking);
+ void AddTargetDepend(int depender_index, cmTarget const* dependee,
+ bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, const char* dependee_name,
bool linking, std::set<cmStdString> &emitted);
- void AddInterfaceDepends(int depender_index, cmTarget* dependee,
+ void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
const char *config,
std::set<cmStdString> &emitted);
cmGlobalGenerator* GlobalGenerator;
@@ -58,8 +60,8 @@ private:
bool NoCycles;
// Collect all targets.
- std::vector<cmTarget*> Targets;
- std::map<cmTarget*, int> TargetIndex;
+ std::vector<cmTarget const*> Targets;
+ std::map<cmTarget const*, int> TargetIndex;
// Represent the target dependency graph. The entry at each
// top-level index corresponds to a depender whose dependencies are
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 0d0d05b..c10f86f 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -229,10 +229,8 @@ cmExportBuildFileGenerator::HandleMissingTarget(
// Append it with the export namespace.
link_libs += this->Namespace;
link_libs += dependee->GetExportName();
-// if generate time {}
}
-
//----------------------------------------------------------------------------
std::vector<std::string>
cmExportBuildFileGenerator
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index f8b4e28..2a87e4f 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -402,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
//----------------------------------------------------------------------------
-void getPropertyContents(cmTarget *tgt, const char *prop,
+void getPropertyContents(cmTarget const* tgt, const char *prop,
std::set<std::string> &ifaceProperties)
{
const char *p = tgt->GetProperty(prop);
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 79e78df..1025dc0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -297,16 +297,14 @@ cmExportInstallFileGenerator
{
// Collect import properties for this target.
cmTargetExport const* te = *tei;
- ImportPropertyMap properties;
- std::set<std::string> importedLocations;
- if (!properties.empty()
- && te->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
+ if (te->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
- this->GenerateImportPropertyCode(os, config, te->Target, properties);
- this->GenerateImportedFileChecksCode(os, te->Target, properties,
- importedLocations);
continue;
}
+
+ ImportPropertyMap properties;
+ std::set<std::string> importedLocations;
+
this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
properties, importedLocations);
this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index f020ddb..177ef8d 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -52,6 +52,8 @@ void cmExtraKateGenerator::Generate()
this->ProjectName = this->GenerateProjectName(mf->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(mf->GetHomeOutputDirectory()));
+ this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0);
+
this->CreateKateProjectFile(mf);
this->CreateDummyKateProjectFile(mf);
}
@@ -95,11 +97,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf,
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_KATE_MAKE_ARGUMENTS");
+ const char* homeOutputDir = mf->GetHomeOutputDirectory();
this->AppendTarget(fout, "all", make, makeArgs,
- mf->GetHomeOutputDirectory());
+ homeOutputDir, homeOutputDir);
this->AppendTarget(fout, "clean", make, makeArgs,
- mf->GetHomeOutputDirectory());
+ homeOutputDir, homeOutputDir);
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
@@ -143,7 +146,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf,
}
if (insertTarget)
{
- this->AppendTarget(fout, ti->first, make, makeArgs, currentDir);
+ this->AppendTarget(fout, ti->first, make, makeArgs,
+ currentDir, homeOutputDir);
}
}
break;
@@ -158,7 +162,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf,
break;
}
- this->AppendTarget(fout, ti->first, make, makeArgs, currentDir);
+ this->AppendTarget(fout, ti->first, make, makeArgs,
+ currentDir, homeOutputDir);
break;
case cmTarget::EXECUTABLE:
case cmTarget::STATIC_LIBRARY:
@@ -166,10 +171,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf,
case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY:
{
- this->AppendTarget(fout, ti->first, make, makeArgs, currentDir);
+ this->AppendTarget(fout, ti->first, make, makeArgs,
+ currentDir, homeOutputDir);
std::string fastTarget = ti->first;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir);
+ this->AppendTarget(fout, fastTarget, make, makeArgs,
+ currentDir, homeOutputDir);
}
break;
@@ -185,7 +192,7 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf,
fit != objectFileTargets.end();
++fit)
{
- this->AppendTarget(fout, *fit, make, makeArgs, currentDir);
+ this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir);
}
}
@@ -199,14 +206,18 @@ cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
const std::string& target,
const std::string& make,
const std::string& makeArgs,
- const std::string& path) const
+ const std::string& path,
+ const char* homeOutputDir
+ ) const
{
static char JsonSep = ' ';
fout <<
"\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", "
- "\"build_cmd\":\"" << make << " -C " << path << " " << makeArgs << " "
- << target << "\"}\n";
+ "\"build_cmd\":\"" << make
+ << " -C " << (this->UseNinja ? homeOutputDir : path.c_str())
+ << " " << makeArgs << " "
+ << target << "\"}\n";
JsonSep = ',';
}
@@ -326,47 +337,3 @@ std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const
return outputBasename;
}
-
-
-// Create the command line for building the given target using the selected
-// make
-std::string cmExtraKateGenerator::BuildMakeCommand(const std::string& make,
- const char* makefile, const char* target) const
-{
- std::string command = make;
- if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
- {
- std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
- command += " /NOLOGO /f &quot;";
- command += makefileName;
- command += "&quot; ";
- command += " VERBOSE=1 ";
- command += target;
- }
- else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
- {
- // no escaping of spaces in this case, see
- // http://public.kitware.com/Bug/view.php?id=10014
- std::string makefileName = makefile;
- command += " -f &quot;";
- command += makefileName;
- command += "&quot; ";
- command += " VERBOSE=1 ";
- command += target;
- }
- else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
- {
- command += " -v ";
- command += target;
- }
- else
- {
- std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
- command += " -f &quot;";
- command += makefileName;
- command += "&quot; ";
- command += " VERBOSE=1 ";
- command += target;
- }
- return command;
-}
diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h
index 4979eff..6ced5fe 100644
--- a/Source/cmExtraKateGenerator.h
+++ b/Source/cmExtraKateGenerator.h
@@ -46,17 +46,17 @@ private:
const std::string& target,
const std::string& make,
const std::string& makeArgs,
- const std::string& path) const;
+ const std::string& path,
+ const char* homeOutputDir) const;
std::string GenerateFilesString(const cmMakefile* mf) const;
std::string GetPathBasename(const std::string& path) const;
std::string GenerateProjectName(const std::string& name,
const std::string& type,
const std::string& path) const;
- std::string BuildMakeCommand(const std::string& make,
- const char* makefile, const char* target) const;
std::string ProjectName;
+ bool UseNinja;
};
#endif
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 0f8c4e3..c8010d0 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -82,7 +82,6 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- // Unreachable
return std::string();
}
} zeroNode;
@@ -94,13 +93,12 @@ static const struct OneNode : public cmGeneratorExpressionNode
virtual bool AcceptsArbitraryContentParameter() const { return true; }
- std::string Evaluate(const std::vector<std::string> &,
+ std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- // Unreachable
- return std::string();
+ return parameters.front();
}
} oneNode;
@@ -203,6 +201,8 @@ static const struct LowerCaseNode : public cmGeneratorExpressionNode
{
LowerCaseNode() {}
+ bool AcceptsArbitraryContentParameter() const { return true; }
+
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
@@ -217,6 +217,8 @@ static const struct UpperCaseNode : public cmGeneratorExpressionNode
{
UpperCaseNode() {}
+ bool AcceptsArbitraryContentParameter() const { return true; }
+
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
@@ -231,6 +233,8 @@ static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
{
MakeCIdentifierNode() {}
+ bool AcceptsArbitraryContentParameter() const { return true; }
+
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
@@ -350,6 +354,7 @@ static const struct CCompilerIdNode : public CompilerIdNode
reportError(context, content->GetOriginalExpression(),
"$<C_COMPILER_ID> may only be used with targets. It may not "
"be used with add_custom_command.");
+ return std::string();
}
return this->EvaluateWithLanguage(parameters, context, content,
dagChecker, "C");
@@ -377,6 +382,7 @@ static const struct CXXCompilerIdNode : public CompilerIdNode
reportError(context, content->GetOriginalExpression(),
"$<CXX_COMPILER_ID> may only be used with targets. It may not "
"be used with add_custom_command.");
+ return std::string();
}
return this->EvaluateWithLanguage(parameters, context, content,
dagChecker, "CXX");
@@ -444,6 +450,7 @@ static const struct CCompilerVersionNode : public CompilerVersionNode
reportError(context, content->GetOriginalExpression(),
"$<C_COMPILER_VERSION> may only be used with targets. It may not "
"be used with add_custom_command.");
+ return std::string();
}
return this->EvaluateWithLanguage(parameters, context, content,
dagChecker, "C");
@@ -472,6 +479,7 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode
reportError(context, content->GetOriginalExpression(),
"$<CXX_COMPILER_VERSION> may only be used with targets. It may "
"not be used with add_custom_command.");
+ return std::string();
}
return this->EvaluateWithLanguage(parameters, context, content,
dagChecker, "CXX");
@@ -504,7 +512,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
return parameters.front().empty() ? "1" : "0";
}
- if (cmsysString_strcasecmp(parameters.begin()->c_str(), platformId) == 0)
+ if (strcmp(parameters.begin()->c_str(), platformId) == 0)
{
return "1";
}
@@ -1634,14 +1642,6 @@ std::string GeneratorExpressionContent::Evaluate(
return std::string();
}
- if (node->NumExpectedParameters() == 1
- && node->AcceptsArbitraryContentParameter())
- {
- return this->ProcessArbitraryContent(node, identifier, context,
- dagChecker,
- this->ParamChildren.begin());
- }
-
std::vector<std::string> parameters;
this->EvaluateParameters(node, identifier, context, dagChecker, parameters);
if (context->HadError)
@@ -1669,33 +1669,35 @@ std::string GeneratorExpressionContent::EvaluateParameters(
pend = this->ParamChildren.end();
const bool acceptsArbitraryContent
= node->AcceptsArbitraryContentParameter();
- for ( ; pit != pend; ++pit)
+ int counter = 1;
+ for ( ; pit != pend; ++pit, ++counter)
{
- std::string parameter;
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for ( ; it != end; ++it)
- {
- parameter += (*it)->Evaluate(context, dagChecker);
- if (context->HadError)
- {
- return std::string();
- }
- }
- parameters.push_back(parameter);
- if (acceptsArbitraryContent
- && parameters.size() == (unsigned int)numExpected - 1)
+ if (acceptsArbitraryContent && counter == numExpected)
{
- assert(pit != pend);
std::string lastParam = this->ProcessArbitraryContent(node, identifier,
context,
dagChecker,
- pit + 1);
+ pit);
parameters.push_back(lastParam);
return std::string();
}
+ else
+ {
+ std::string parameter;
+ std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+ pit->begin();
+ const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+ pit->end();
+ for ( ; it != end; ++it)
+ {
+ parameter += (*it)->Evaluate(context, dagChecker);
+ if (context->HadError)
+ {
+ return std::string();
+ }
+ }
+ parameters.push_back(parameter);
+ }
}
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 6aff5f0..8b760f1 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -104,7 +104,7 @@ struct cmStrictTargetComparison {
bool operator()(cmTarget const* t1, cmTarget const* t2) const;
};
-typedef std::map<cmTarget*,
+typedef std::map<cmTarget const*,
cmGeneratorTarget*,
cmStrictTargetComparison> cmGeneratorTargetsType;
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index bd3db3e..70004ea 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -44,6 +44,8 @@ public:
*/
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional);
+
+ virtual bool AllowNotParallel() const { return false; }
};
#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 3ed612d..3b858af 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages()
}
bool cmGlobalGenerator::IsDependedOn(const char* project,
- cmTarget* targetIn)
+ cmTarget const* targetIn)
{
// Get all local gens for this project
std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
@@ -1242,8 +1242,8 @@ bool cmGlobalGenerator::ComputeTargetDepends()
{
return false;
}
- std::vector<cmTarget*> const& targets = ctd.GetTargets();
- for(std::vector<cmTarget*>::const_iterator ti = targets.begin();
+ std::vector<cmTarget const*> const& targets = ctd.GetTargets();
+ for(std::vector<cmTarget const*>::const_iterator ti = targets.begin();
ti != targets.end(); ++ti)
{
ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
@@ -1306,7 +1306,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
cmQtAutoGenerators autogen;
if(autogen.InitializeAutogenTarget(&target))
{
- autogens.push_back(std::make_pair(autogen, &target));
+ autogens.push_back(AutogensType::value_type(autogen, &target));
}
}
}
@@ -1407,6 +1407,10 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
for(cmGeneratorTargetsType::iterator ti = targets.begin();
ti != targets.end(); ++ti)
{
+ if (ti->second->Target->IsImported())
+ {
+ continue;
+ }
cmGeneratorTarget* gt = ti->second;
gt->ClassifySources();
gt->LookupObjectLibraries();
@@ -1460,7 +1464,8 @@ void cmGlobalGenerator::ClearGeneratorMembers()
}
//----------------------------------------------------------------------------
-cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const
+cmGeneratorTarget*
+cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
{
cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t);
if(ti == this->GeneratorTargets.end())
@@ -1982,7 +1987,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
clg = clg->GetParent())
{
// This local generator includes the target.
- std::set<cmTarget*>& targetSet =
+ std::set<cmTarget const*>& targetSet =
this->LocalGeneratorToTargetMap[clg];
targetSet.insert(&target);
@@ -1993,7 +1998,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
for(TargetDependSet::const_iterator ti = tgtdeps.begin();
ti != tgtdeps.end(); ++ti)
{
- targetSet.insert(*ti);
+ cmTarget const* ttt = *ti;
+ targetSet.insert(ttt);
}
}
}
@@ -2506,7 +2512,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
//----------------------------------------------------------------------------
cmGlobalGenerator::TargetDependSet const&
-cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target)
+cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target)
{
return this->TargetDependencies[&target];
}
@@ -2628,7 +2634,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target)
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
+void cmGlobalGenerator::AddTargetDepends(cmTarget const* target,
TargetDependSet& projectTargets)
{
// add the target itself
@@ -2639,7 +2645,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
TargetDependSet const& ts = this->GetTargetDirectDepends(*target);
for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i)
{
- cmTarget* dtarget = *i;
+ cmTarget const* dtarget = *i;
this->AddTargetDepends(dtarget, projectTargets);
}
}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index b21bc8b..049b0e6 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -218,7 +218,7 @@ public:
/** If check to see if the target is linked to by any other
target in the project */
- bool IsDependedOn(const char* project, cmTarget* target);
+ bool IsDependedOn(const char* project, cmTarget const* target);
///! Find a local generator by its startdirectory
cmLocalGenerator* FindLocalGenerator(const char* start_dir);
@@ -266,10 +266,10 @@ public:
// what targets does the specified target depend on directly
// via a target_link_libraries or add_dependencies
- TargetDependSet const& GetTargetDirectDepends(cmTarget & target);
+ TargetDependSet const& GetTargetDirectDepends(cmTarget const& target);
/** Get per-target generator information. */
- cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const;
+ cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap()
const {return this->ProjectMap;}
@@ -325,7 +325,8 @@ protected:
TargetDependSet& originalTargets,
cmLocalGenerator* root, GeneratorVector const&);
virtual bool IsRootOnlyTarget(cmTarget* target);
- void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets);
+ void AddTargetDepends(cmTarget const* target,
+ TargetDependSet& projectTargets);
void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
@@ -335,7 +336,8 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS();
bool CheckTargets();
- typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > AutogensType;
+ typedef std::vector<std::pair<cmQtAutoGenerators,
+ cmTarget const*> > AutogensType;
void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
std::string SelectMakeProgram(const char* makeProgram,
@@ -364,7 +366,8 @@ protected:
cmLocalGenerator* CurrentLocalGenerator;
// map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
- std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap;
+ std::map<cmLocalGenerator*, std::set<cmTarget const*> >
+ LocalGeneratorToTargetMap;
// Set of named installation components requested by the project.
std::set<cmStdString> InstallComponents;
@@ -422,7 +425,7 @@ private:
std::vector<std::string> FilesReplacedDuringGenerate;
// Store computed inter-target dependencies.
- typedef std::map<cmTarget *, TargetDependSet> TargetDependMap;
+ typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies;
// Per-target generator information.
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 77571b2..4b92058 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
void
cmGlobalNinjaGenerator
-::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs)
+::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs)
{
const char* configName =
target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE");
@@ -879,7 +879,7 @@ cmGlobalNinjaGenerator
void
cmGlobalNinjaGenerator
-::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs)
+::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs)
{
if (target->GetType() == cmTarget::GLOBAL_TARGET) {
// Global targets only depend on other utilities, which may not appear in
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 4fd0d5c..de38923 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -283,8 +283,8 @@ public:
ASD.insert(deps.begin(), deps.end());
}
- void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs);
- void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
+ void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs);
+ void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs);
void AddDependencyToAll(cmTarget* target);
void AddDependencyToAll(const std::string& input);
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 6333873..622a7c5 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -480,7 +480,6 @@ cmGlobalUnixMakefileGenerator3
(l->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(l->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(l->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
- (l->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(l->second->GetType() == cmTarget::UTILITY))
{
if(l->second->Target->IsImported())
@@ -658,7 +657,6 @@ cmGlobalUnixMakefileGenerator3
(t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
- (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second->GetType() == cmTarget::UTILITY)))
{
// Add a rule to build the target by name.
@@ -680,10 +678,6 @@ cmGlobalUnixMakefileGenerator3
t->second->GetName(), depends, commands,
true);
- if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- continue;
- }
// Add a fast rule to build the target
std::string localName =
lg->GetRelativeTargetDirectory(*t->second->Target);
@@ -757,7 +751,6 @@ cmGlobalUnixMakefileGenerator3
|| (t->second->GetType() == cmTarget::SHARED_LIBRARY)
|| (t->second->GetType() == cmTarget::MODULE_LIBRARY)
|| (t->second->GetType() == cmTarget::OBJECT_LIBRARY)
- || (t->second->GetType() == cmTarget::INTERFACE_LIBRARY)
|| (t->second->GetType() == cmTarget::UTILITY)))
{
std::string makefileName;
@@ -774,64 +767,53 @@ cmGlobalUnixMakefileGenerator3
<< localName << "\n\n";
commands.clear();
+ makeTargetName = localName;
+ makeTargetName += "/depend";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
- if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY)
+ // add requires if we need it for this generator
+ if (needRequiresStep)
{
makeTargetName = localName;
- makeTargetName += "/depend";
+ makeTargetName += "/requires";
commands.push_back(lg->GetRecursiveMakeCall
(makefileName.c_str(),makeTargetName.c_str()));
+ }
+ makeTargetName = localName;
+ makeTargetName += "/build";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
- // add requires if we need it for this generator
- if (needRequiresStep)
- {
- makeTargetName = localName;
- makeTargetName += "/requires";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
- }
- makeTargetName = localName;
- makeTargetName += "/build";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
-
- // Write the rule.
- localName += "/all";
- depends.clear();
+ // Write the rule.
+ localName += "/all";
+ depends.clear();
- std::string progressDir =
- lg->GetMakefile()->GetHomeOutputDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
+ std::string progressDir =
+ lg->GetMakefile()->GetHomeOutputDirectory();
+ progressDir += cmake::GetCMakeFilesDirectory();
+ {
+ cmOStringStream progCmd;
+ progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
+ // all target counts
+ progCmd << lg->Convert(progressDir.c_str(),
+ cmLocalGenerator::FULL,
+ cmLocalGenerator::SHELL);
+ progCmd << " ";
+ std::vector<unsigned long>& progFiles =
+ this->ProgressMap[t->second->Target].Marks;
+ for (std::vector<unsigned long>::iterator i = progFiles.begin();
+ i != progFiles.end(); ++i)
{
- cmOStringStream progCmd;
- progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
- // all target counts
- progCmd << lg->Convert(progressDir.c_str(),
- cmLocalGenerator::FULL,
- cmLocalGenerator::SHELL);
- progCmd << " ";
- std::vector<unsigned long>& progFiles =
- this->ProgressMap[t->second->Target].Marks;
- for (std::vector<unsigned long>::iterator i = progFiles.begin();
- i != progFiles.end(); ++i)
- {
- progCmd << " " << *i;
- }
- commands.push_back(progCmd.str());
+ progCmd << " " << *i;
}
- progressDir = "Built target ";
- progressDir += t->second->GetName();
- lg->AppendEcho(commands,progressDir.c_str());
- }
- else
- {
- depends.clear();
+ commands.push_back(progCmd.str());
}
+ progressDir = "Built target ";
+ progressDir += t->second->GetName();
+ lg->AppendEcho(commands,progressDir.c_str());
+
this->AppendGlobalTargetDepends(depends,*t->second->Target);
- if(depends.empty() && this->EmptyRuleHackDepends != "")
- {
- depends.push_back(this->EmptyRuleHackDepends);
- }
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName.c_str(), depends, commands, true);
@@ -847,7 +829,7 @@ cmGlobalUnixMakefileGenerator3
// Write the rule.
commands.clear();
- std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
+ progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory();
{
@@ -859,7 +841,7 @@ cmGlobalUnixMakefileGenerator3
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
//
- std::set<cmTarget *> emitted;
+ std::set<cmTarget const*> emitted;
progCmd << " "
<< this->CountProgressMarksInTarget(t->second->Target, emitted);
commands.push_back(progCmd.str());
@@ -937,8 +919,8 @@ cmGlobalUnixMakefileGenerator3
//----------------------------------------------------------------------------
size_t
cmGlobalUnixMakefileGenerator3
-::CountProgressMarksInTarget(cmTarget* target,
- std::set<cmTarget*>& emitted)
+::CountProgressMarksInTarget(cmTarget const* target,
+ std::set<cmTarget const*>& emitted)
{
size_t count = 0;
if(emitted.insert(target).second)
@@ -964,9 +946,10 @@ cmGlobalUnixMakefileGenerator3
::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg)
{
size_t count = 0;
- std::set<cmTarget*> emitted;
- std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg];
- for(std::set<cmTarget*>::const_iterator t = targets.begin();
+ std::set<cmTarget const*> emitted;
+ std::set<cmTarget const*> const& targets
+ = this->LocalGeneratorToTargetMap[lg];
+ for(std::set<cmTarget const*>::const_iterator t = targets.begin();
t != targets.end(); ++t)
{
count += this->CountProgressMarksInTarget(*t, emitted);
@@ -987,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
//----------------------------------------------------------------------------
bool
cmGlobalUnixMakefileGenerator3::ProgressMapCompare
-::operator()(cmTarget* l, cmTarget* r) const
+::operator()(cmTarget const* l, cmTarget const* r) const
{
// Order by target name.
if(int c = strcmp(l->GetName(), r->GetName()))
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 284f5d1..00a86eb 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -125,6 +125,9 @@ public:
const std::string &workingDirectory,
const std::string &compileCommand);
+ /** Does the make tool tolerate .NOTPARALLEL? */
+ virtual bool AllowNotParallel() const { return true; }
+
protected:
void WriteMainMakefile2();
void WriteMainCMakefile();
@@ -181,13 +184,14 @@ protected:
std::vector<unsigned long> Marks;
void WriteProgressVariables(unsigned long total, unsigned long& current);
};
- struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; };
- typedef std::map<cmTarget*, TargetProgress,
+ struct ProgressMapCompare { bool operator()(cmTarget const*,
+ cmTarget const*) const; };
+ typedef std::map<cmTarget const*, TargetProgress,
ProgressMapCompare> ProgressMapType;
ProgressMapType ProgressMap;
- size_t CountProgressMarksInTarget(cmTarget* target,
- std::set<cmTarget*>& emitted);
+ size_t CountProgressMarksInTarget(cmTarget const* target,
+ std::set<cmTarget const*>& emitted);
size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);
cmGeneratedFileStream *CommandDatabase;
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 614a79a..38c47ef 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator
tt = orderedProjectTargets.begin();
tt != orderedProjectTargets.end(); ++tt)
{
- cmTarget* target = *tt;
+ cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
@@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
const char* dspname,
const char* dir,
- cmTarget& target)
+ cmTarget const& target)
{
fout << "#########################################################"
"######################\n\n";
@@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
//----------------------------------------------------------------------------
std::string
-cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target)
+cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target)
{
std::string pname = target->GetName();
pname += "_UTILITY";
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index cb6cb8b..5521410 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -99,12 +99,12 @@ private:
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path, cmTarget &t);
+ const char* name, const char* path, cmTarget const& t);
void WriteExternalProject(std::ostream& fout,
const char* name, const char* path,
const std::set<cmStdString>& dependencies);
void WriteDSWFooter(std::ostream& fout);
- virtual std::string WriteUtilityDepend(cmTarget* target);
+ virtual std::string WriteUtilityDepend(cmTarget const* target);
std::string MSDevCommand;
bool MSDevCommandInitialized;
std::string const& GetMSDevCommand();
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 61d3c4c..22e4f08 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -157,7 +157,7 @@ void
cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
const char* dspname,
const char* dir,
- cmTarget& t)
+ cmTarget const& t)
{
// check to see if this is a fortran build
const char* ext = ".vcproj";
@@ -209,7 +209,7 @@ void
cmGlobalVisualStudio71Generator
::WriteProjectDepends(std::ostream& fout,
const char*,
- const char*, cmTarget& target)
+ const char*, cmTarget const& target)
{
VSDependSet const& depends = this->VSTargetDepends[&target];
for(VSDependSet::const_iterator di = depends.begin();
@@ -240,7 +240,7 @@ void cmGlobalVisualStudio71Generator
const std::set<cmStdString>& depends)
{
fout << "Project(\"{"
- << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << (typeGuid ? typeGuid : this->ExternalProjectType(location))
<< "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index e136db7..04e3a55 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -59,9 +59,11 @@ protected:
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProject(std::ostream& fout,
- const char* name, const char* path, cmTarget &t);
+ const char* name, const char* path,
+ cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout,
- const char* name, const char* path, cmTarget &t);
+ const char* name, const char* path,
+ cmTarget const& t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index a217d8c..bb63289 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -146,6 +146,41 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
}
//----------------------------------------------------------------------------
+const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
+ const char* location)
+{
+ std::string extension = cmSystemTools::GetFilenameLastExtension(location);
+ if (extension == ".vbproj")
+ {
+ return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
+ }
+ else if (extension == ".csproj")
+ {
+ return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
+ }
+ else if (extension == ".fsproj")
+ {
+ return "F2A71F9B-5D33-465A-A702-920D77279786";
+ }
+ else if (extension == ".vdproj")
+ {
+ return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
+ }
+ else if (extension == ".dbproj")
+ {
+ return "C8D11400-126E-41CD-887F-60BD40844F9E";
+ }
+ else if (extension == ".wixproj")
+ {
+ return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
+ }
+ else if (extension == ".pyproj")
+ {
+ return "888888A0-9F3D-457C-B088-3A5042F75D52";
+ }
+ return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
+}
+//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
std::vector<std::string>& makeCommand,
const char* makeProgram,
@@ -335,7 +370,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
- cmTarget* target = *tt;
+ cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
@@ -376,7 +411,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
- cmTarget* target = *tt;
+ cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
@@ -470,7 +505,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
- cmTarget* target = *tt;
+ cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
@@ -619,7 +654,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
// the libraries it uses are also done here
void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
const char* dspname,
- const char* dir, cmTarget& target)
+ const char* dir, cmTarget const& target)
{
// check to see if this is a fortran build
const char* ext = ".vcproj";
@@ -659,7 +694,7 @@ void
cmGlobalVisualStudio7Generator
::WriteProjectDepends(std::ostream& fout,
const char* dspname,
- const char*, cmTarget& target)
+ const char*, cmTarget const& target)
{
int depcount = 0;
std::string dspguid = this->GetGUID(dspname);
@@ -730,7 +765,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
std::string d = cmSystemTools::ConvertToOutputPath(location);
fout << "Project("
<< "\"{"
- << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << (typeGuid ? typeGuid : this->ExternalProjectType(location))
<< "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
@@ -819,7 +854,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
//----------------------------------------------------------------------------
std::string
-cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target)
+cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
{
std::string pname = target->GetName();
pname += "_UTILITY";
@@ -940,7 +975,7 @@ cmGlobalVisualStudio7Generator
std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
- cmTarget* target)
+ cmTarget const* target)
{
std::set<std::string> activeConfigs;
// if it is a utilitiy target then only make it part of the
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 59e74ba..f69bd84 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -115,15 +115,19 @@ protected:
std::string const& GetDevEnvCommand();
virtual std::string FindDevEnvCommand();
+ static const char* ExternalProjectType(const char* location);
+
static cmIDEFlagTable const* GetExtraFlagTableVS7();
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteProject(std::ostream& fout,
- const char* name, const char* path, cmTarget &t);
+ const char* name, const char* path,
+ cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout,
- const char* name, const char* path, cmTarget &t);
+ const char* name, const char* path,
+ cmTarget const&t);
virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
@@ -132,7 +136,7 @@ protected:
cmLocalGenerator* root);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
- virtual std::string WriteUtilityDepend(cmTarget* target);
+ virtual std::string WriteUtilityDepend(cmTarget const* target);
virtual void WriteTargetsToSolution(
std::ostream& fout,
@@ -158,7 +162,7 @@ protected:
std::string ConvertToSolutionPath(const char* path);
std::set<std::string> IsPartOfDefaultBuild(const char* project,
- cmTarget* target);
+ cmTarget const* target);
std::vector<std::string> Configurations;
std::map<cmStdString, cmStdString> GUIDMap;
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index e4ce13f..12c240b 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::WriteProjectDepends(
- std::ostream& fout, const char*, const char*, cmTarget& t)
+ std::ostream& fout, const char*, const char*, cmTarget const& t)
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
OrderedTargetDependSet depends(unordered);
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index ad01a24..5b952c4 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -84,7 +84,7 @@ protected:
const char* platformMapping = NULL);
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
- const char* path, cmTarget &t);
+ const char* path, cmTarget const& t);
std::string Name;
std::string WindowsCEVersion;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 6c782e4..93a597c 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
}
//----------------------------------------------------------------------------
-void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target,
+void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target,
TargetSet& linked)
{
if(linked.insert(target).second)
@@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target)
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::FollowLinkDepends(
- cmTarget* target, std::set<cmTarget*>& linked)
+ cmTarget const* target, std::set<cmTarget const*>& linked)
{
if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
@@ -397,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
}
//----------------------------------------------------------------------------
-static bool VSLinkable(cmTarget* t)
+static bool VSLinkable(cmTarget const* t)
{
return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY;
}
@@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
// Collect implicit link dependencies (target_link_libraries).
// Static libraries cannot depend on their link implementation
// due to behavior (2), but they do not really need to.
- std::set<cmTarget*> linkDepends;
+ std::set<cmTarget const*> linkDepends;
if(target.GetType() != cmTarget::STATIC_LIBRARY)
{
for(TargetDependSet::const_iterator di = depends.begin();
@@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
}
// Collect explicit util dependencies (add_dependencies).
- std::set<cmTarget*> utilDepends;
+ std::set<cmTarget const*> utilDepends;
for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di)
{
@@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
}
// Emit link dependencies.
- for(std::set<cmTarget*>::iterator di = linkDepends.begin();
+ for(std::set<cmTarget const*>::iterator di = linkDepends.begin();
di != linkDepends.end(); ++di)
{
- cmTarget* dep = *di;
+ cmTarget const* dep = *di;
vsTargetDepend.insert(dep->GetName());
}
// Emit util dependencies. Possibly use intermediate targets.
- for(std::set<cmTarget*>::iterator di = utilDepends.begin();
+ for(std::set<cmTarget const*>::iterator di = utilDepends.begin();
di != utilDepends.end(); ++di)
{
- cmTarget* dep = *di;
+ cmTarget const* dep = *di;
if(allowLinkable || !VSLinkable(dep) || linked.count(dep))
{
// Direct dependency allowed.
@@ -523,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
}
//----------------------------------------------------------------------------
-std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target)
+std::string
+cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target)
{
UtilityDependsMap::iterator i = this->UtilityDepends.find(target);
if(i == this->UtilityDepends.end())
@@ -845,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
}
}
}
-bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target)
+bool
+cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{
// check to see if this is a fortran build
std::set<cmStdString> languages;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index da2d021..54e3c28 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -60,7 +60,7 @@ public:
const char* vsSolutionFile = 0);
// return true if target is fortran only
- bool TargetIsFortranOnly(cmTarget& t);
+ bool TargetIsFortranOnly(cmTarget const& t);
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
@@ -75,7 +75,7 @@ public:
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; }
- class TargetSet: public std::set<cmTarget*> {};
+ class TargetSet: public std::set<cmTarget const*> {};
struct TargetCompare
{
bool operator()(cmTarget const* l, cmTarget const* r) const;
@@ -96,15 +96,15 @@ protected:
virtual bool ComputeTargetDepends();
class VSDependSet: public std::set<cmStdString> {};
- class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
+ class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
VSDependMap VSTargetDepends;
void ComputeVSTargetDepends(cmTarget&);
bool CheckTargetLinks(cmTarget& target, const char* name);
std::string GetUtilityForTarget(cmTarget& target, const char*);
- virtual std::string WriteUtilityDepend(cmTarget*) = 0;
- std::string GetUtilityDepend(cmTarget* target);
- typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
+ virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
+ std::string GetUtilityDepend(cmTarget const* target);
+ typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;
UtilityDependsMap UtilityDepends;
const char* AdditionalPlatformDefinition;
@@ -113,11 +113,12 @@ private:
void PrintCompilerAdvice(std::ostream&, std::string, const char*) {}
void ComputeTargetObjects(cmGeneratorTarget* gt) const;
- void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
+ void FollowLinkDepends(cmTarget const* target,
+ std::set<cmTarget const*>& linked);
class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
TargetSetMap TargetLinkClosure;
- void FillLinkClosure(cmTarget* target, TargetSet& linked);
+ void FillLinkClosure(cmTarget const* target, TargetSet& linked);
TargetSet const& GetTargetLinkClosure(cmTarget* target);
};
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index 23e60a1..d5350ef 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -43,6 +43,8 @@ public:
*/
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional);
+
+ virtual bool AllowNotParallel() const { return false; }
};
#endif
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 215d483..b5a46d0 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
}
//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t)
+cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
{
if(!t)
{
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index e8cbd14..6281c3b 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -125,7 +125,7 @@ private:
multipleOutputPairs
);
- cmXCodeObject* FindXCodeTarget(cmTarget*);
+ cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const char* name, const char* id);
// create cmXCodeObject from these functions so that memory can be managed
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 7b9109e..68f45a6 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
- const char* config,
- NameType nameType)
+std::string
+cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
+ const char* config,
+ NameType nameType)
{
std::string fname;
// Compute the name of the library.
@@ -515,11 +516,12 @@ cmInstallTargetGenerator
std::map<cmStdString, cmStdString> install_name_remap;
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
{
- std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked();
- for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin();
+ std::set<cmTarget const*> const& sharedLibs
+ = cli->GetSharedLibrariesLinked();
+ for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin();
j != sharedLibs.end(); ++j)
{
- cmTarget* tgt = *j;
+ cmTarget const* tgt = *j;
// The install_name of an imported target does not change.
if(tgt->IsImported())
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 8cf72f9..18c3957 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -53,7 +53,8 @@ public:
NameReal
};
- static std::string GetInstallFilename(cmTarget*target, const char* config,
+ static std::string GetInstallFilename(cmTarget const* target,
+ const char* config,
NameType nameType = NameNormal);
cmTarget* GetTarget() const { return this->Target; }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c3c5299..455f542 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -261,6 +261,10 @@ void cmLocalGenerator::TraceDependencies()
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
+ if (t->second->Target->IsImported())
+ {
+ continue;
+ }
t->second->TraceDependencies();
}
}
@@ -545,6 +549,10 @@ void cmLocalGenerator::GenerateTargetManifest()
{
continue;
}
+ if (target.Target->IsImported())
+ {
+ continue;
+ }
if(configNames.empty())
{
target.GenerateTargetManifest(0);
@@ -1386,7 +1394,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
//----------------------------------------------------------------------------
void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
- cmTarget* target,
+ cmTarget const* target,
const char* config)
{
std::vector<std::string> targetDefines;
@@ -1469,27 +1477,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
includeBinaryDir = true;
}
- // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do
- // not set the backwards compatibility level automatically.
- const char* vtkSourceDir =
- this->Makefile->GetDefinition("VTK_SOURCE_DIR");
- if(vtkSourceDir)
- {
- const char* vtk_major =
- this->Makefile->GetDefinition("VTK_MAJOR_VERSION");
- const char* vtk_minor =
- this->Makefile->GetDefinition("VTK_MINOR_VERSION");
- vtk_major = vtk_major? vtk_major : "4";
- vtk_minor = vtk_minor? vtk_minor : "4";
- int vmajor = 0;
- int vminor = 0;
- if(sscanf(vtk_major, "%d", &vmajor) &&
- sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4)
- {
- includeSourceDir = true;
- }
- }
-
// Do not repeat an include path.
std::set<cmStdString> emitted;
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9a89f0f..ad662d5 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -224,8 +224,9 @@ public:
bool stripImplicitInclDirs = true);
void AddCompileOptions(std::string& flags, cmTarget* target,
const char* lang, const char* config);
- void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target,
- const char* config);
+ void AddCompileDefinitions(std::set<std::string>& defines,
+ cmTarget const* target,
+ const char* config);
/** Compute the language used to compile the given source file. */
const char* GetSourceFileLanguage(const cmSourceFile& source);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 6ca386c..20e8eea 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -388,7 +388,6 @@ void cmLocalUnixMakefileGenerator3
(t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
- (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second->GetType() == cmTarget::UTILITY))
{
if (t->second->Target->IsImported())
@@ -1686,6 +1685,17 @@ void cmLocalUnixMakefileGenerator3
"default_target",
depends,
no_commands, true);
+
+ // Help out users that try "gmake target1 target2 -j".
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+ if(gg->AllowNotParallel())
+ {
+ std::vector<std::string> no_depends;
+ this->WriteMakeRule(ruleFileStream,
+ "Allow only one \"make -f Makefile2\" at a time, but pass parallelism.",
+ ".NOTPARALLEL", no_depends, no_commands, true);
+ }
}
this->WriteSpecialTargetsTop(ruleFileStream);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 35818ee..399b582 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -85,9 +85,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
case cmTarget::OBJECT_LIBRARY:
this->WriteObjectLibraryRules();
break;
- case cmTarget::INTERFACE_LIBRARY:
- // Nothing to do.
- break;
default:
// If language is not known, this is an error.
cmSystemTools::Error("Unknown Library Type");
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 2063a24..6e70285 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -76,7 +76,6 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY:
- case cmTarget::INTERFACE_LIBRARY:
result = new cmMakefileLibraryTargetGenerator(tgt);
break;
case cmTarget::UTILITY:
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 835e3b4..abf20cb 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -138,14 +138,14 @@ cmQtAutoGenerators::cmQtAutoGenerators()
}
}
-static std::string getAutogenTargetName(cmTarget *target)
+static std::string getAutogenTargetName(cmTarget const* target)
{
std::string autogenTargetName = target->GetName();
autogenTargetName += "_automoc";
return autogenTargetName;
}
-static std::string getAutogenTargetDir(cmTarget *target)
+static std::string getAutogenTargetDir(cmTarget const* target)
{
cmMakefile* makefile = target->GetMakefile();
std::string targetDir = makefile->GetCurrentOutputDirectory();
@@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
if (target->GetPropertyAsBool("AUTORCC"))
{
toolNames.push_back("rcc");
+ this->InitializeAutoRccTarget(target);
}
std::string tools = toolNames[0];
@@ -295,7 +296,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
return true;
}
-static void GetCompileDefinitionsAndDirectories(cmTarget *target,
+static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
const char * config,
std::string &incs,
std::string &defs)
@@ -303,10 +304,12 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target,
cmMakefile* makefile = target->GetMakefile();
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
std::vector<std::string> includeDirs;
- cmGeneratorTarget gtgt(target);
+ cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
// Get the include dirs for this target, without stripping the implicit
// include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
- localGen->GetIncludeDirectories(includeDirs, &gtgt, "CXX", config, false);
+ localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
const char* sep = "";
incs = "";
for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
@@ -332,7 +335,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target,
}
}
-void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
+void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -435,7 +438,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
}
}
-void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target,
+void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines)
@@ -614,7 +617,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-static void GetUicOpts(cmTarget *target, const char * config,
+static void GetUicOpts(cmTarget const* target, const char * config,
std::string &optString)
{
std::vector<std::string> opts;
@@ -631,7 +634,7 @@ static void GetUicOpts(cmTarget *target, const char * config,
}
}
-void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target,
+void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
std::map<std::string, std::string> &configUicOptions)
{
cmMakefile *makefile = target->GetMakefile();
@@ -801,14 +804,56 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target)
+void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target)
{
- std::string _rcc_files;
- const char* sepRccFiles = "";
cmMakefile *makefile = target->GetMakefile();
+ const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles();
+
std::vector<cmSourceFile*> newFiles;
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+ fileIt != srcFiles.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string ext = sf->GetExtension();
+ if (ext == "qrc")
+ {
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath().c_str());
+ bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
+
+ if (!skip)
+ {
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFile);
+
+ std::string rcc_output_file = makefile->GetCurrentOutputDirectory();
+ rcc_output_file += "/qrc_" + basename + ".cpp";
+ makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
+ rcc_output_file.c_str(), false);
+ cmSourceFile* rccCppSource
+ = makefile->GetOrCreateSource(rcc_output_file.c_str(), true);
+ newFiles.push_back(rccCppSource);
+ }
+ }
+ }
+
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin();
+ fileIt != newFiles.end();
+ ++fileIt)
+ {
+ target->AddSourceFile(*fileIt);
+ }
+}
+
+void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
+{
+ std::string _rcc_files;
+ const char* sepRccFiles = "";
+ cmMakefile *makefile = target->GetMakefile();
+
const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles();
std::string rccFileFiles;
@@ -841,17 +886,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target)
_rcc_files += absFile;
sepRccFiles = ";";
- std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(absFile);
-
- std::string rcc_output_file = makefile->GetCurrentOutputDirectory();
- rcc_output_file += "/qrc_" + basename + ".cpp";
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
- rcc_output_file.c_str(), false);
- cmSourceFile* rccCppSource
- = makefile->GetOrCreateSource(rcc_output_file.c_str(), true);
- newFiles.push_back(rccCppSource);
-
if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS"))
{
std::vector<std::string> optsVec;
@@ -880,13 +914,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target)
}
}
- for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin();
- fileIt != newFiles.end();
- ++fileIt)
- {
- target->AddSourceFile(*fileIt);
- }
-
makefile->AddDefinition("_rcc_files",
cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str());
@@ -1361,18 +1388,18 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
if (this->RunMocFailed)
{
- std::cerr << "moc failed..."<< std::endl;
+ std::cerr << "moc failed..." << std::endl;
return false;
}
if (this->RunUicFailed)
{
- std::cerr << "uic failed..."<< std::endl;
+ std::cerr << "uic failed..." << std::endl;
return false;
}
if (this->RunRccFailed)
{
- std::cerr << "rcc failed..."<< std::endl;
+ std::cerr << "rcc failed..." << std::endl;
return false;
}
outStream.flush();
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index e877f7d..80123d8 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -24,16 +24,17 @@ public:
bool Run(const char* targetDirectory, const char *config);
bool InitializeAutogenTarget(cmTarget* target);
- void SetupAutoGenerateTarget(cmTarget* target);
+ void SetupAutoGenerateTarget(cmTarget const* target);
private:
- void SetupAutoMocTarget(cmTarget* target,
+ void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
- void SetupAutoUicTarget(cmTarget* target,
+ void SetupAutoUicTarget(cmTarget const* target,
std::map<std::string, std::string> &configUicOptions);
- void SetupAutoRccTarget(cmTarget* target);
+ void InitializeAutoRccTarget(cmTarget* target);
+ void SetupAutoRccTarget(cmTarget const* target);
cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
const char* targetDirectory);
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 7369fe6..eb6e52f 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -423,19 +423,19 @@ struct cmStrCmp {
cmStrCmp(const char *test) : m_test(test) {}
cmStrCmp(std::string &test) : m_test(test.c_str()) {}
- bool operator()(const char * input)
+ bool operator()(const char * input) const
{
return strcmp(input, m_test) == 0;
}
// For use with binary_search
- bool operator()(const char *str1, const char *str2)
+ bool operator()(const char *str1, const char *str2) const
{
return strcmp(str1, str2) < 0;
}
private:
- const char *m_test;
+ const char * const m_test;
};
#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9ea7f07..9faf0d9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
//----------------------------------------------------------------------------
void cmTarget::GetInterfaceLinkLibraries(const char *config,
- std::vector<std::string> &libs, cmTarget *head) const
+ std::vector<std::string> &libs,
+ cmTarget const* head) const
{
const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES");
if (prop)
@@ -4903,6 +4904,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
const char** imp,
std::string& suffix) const
{
+ if (this->GetType() == INTERFACE_LIBRARY)
+ {
+ // This method attempts to find a config-specific LOCATION for the
+ // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no
+ // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate
+ // and valid response.
+ return true;
+ }
+
// Track the configuration-specific property suffix.
suffix = "_";
suffix += desired_config;
@@ -5035,8 +5045,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
const char* loc = 0;
const char* imp = 0;
std::string suffix;
- if (this->GetType() != INTERFACE_LIBRARY &&
- !this->GetMappedConfig(desired_config, &loc, &imp, suffix))
+ if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix))
{
return;
}
@@ -5648,7 +5657,7 @@ void cmTarget::ComputeLinkImplementation(const char* config,
{
e << "Target \"" << this->GetName() << "\" links to target \"" << item
<< "\" but the target was not found. Perhaps a find_package() "
- "call is missing for an IMPORTED target, or a ALIAS target is "
+ "call is missing for an IMPORTED target, or an ALIAS target is "
"missing?";
this->Makefile->GetCMakeInstance()->IssueMessage(messageType,
e.str(),
@@ -5805,7 +5814,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
//----------------------------------------------------------------------------
template<typename PropertyType>
-void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee,
+void checkPropertyConsistency(cmTarget const* depender,
+ cmTarget const* dependee,
const char *propName,
std::set<cmStdString> &emitted,
const char *config,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index e43d138..e026c59 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -188,7 +188,7 @@ public:
cmTarget const* head) const;
void GetInterfaceLinkLibraries(const char *config,
std::vector<std::string> &,
- cmTarget *head) const;
+ cmTarget const* head) const;
/** Compute the link type to use for the given configuration. */
LinkLibraryType ComputeLinkType(const char* config) const;
diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h
index 258bacd..1feb072 100644
--- a/Source/cmTargetDepend.h
+++ b/Source/cmTargetDepend.h
@@ -20,17 +20,17 @@ class cmTarget;
It may be marked as a 'link' or 'util' edge or both. */
class cmTargetDepend
{
- cmTarget* Target;
+ cmTarget const* Target;
// The set order depends only on the Target, so we use
// mutable members to acheive a map with set syntax.
mutable bool Link;
mutable bool Util;
public:
- cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {}
- operator cmTarget*() const { return this->Target; }
- cmTarget* operator->() const { return this->Target; }
- cmTarget& operator*() const { return *this->Target; }
+ cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {}
+ operator cmTarget const*() const { return this->Target; }
+ cmTarget const* operator->() const { return this->Target; }
+ cmTarget const& operator*() const { return *this->Target; }
friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r)
{ return l.Target < r.Target; }
void SetType(bool strong) const
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 10663b7..b9ae701 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
for( OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i)
{
- cmTarget* dt = *i;
+ cmTarget const* dt = *i;
if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
{
continue;
diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in
index 60a4a8e..aba4175 100644
--- a/Source/kwsys/Encoding.hxx.in
+++ b/Source/kwsys/Encoding.hxx.in
@@ -14,6 +14,7 @@
#include <@KWSYS_NAMESPACE@/Configure.hxx>
#include <@KWSYS_NAMESPACE@/stl/string>
+#include <@KWSYS_NAMESPACE@/stl/vector>
/* Define these macros temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
@@ -25,6 +26,36 @@ namespace @KWSYS_NAMESPACE@
class @KWSYS_NAMESPACE@_EXPORT Encoding
{
public:
+
+ // Container class for argc/argv.
+ class CommandLineArguments
+ {
+ public:
+ // On Windows, get the program command line arguments
+ // in this Encoding module's 8 bit encoding.
+ // On other platforms the given argc/argv is used, and
+ // to be consistent, should be the argc/argv from main().
+ static CommandLineArguments Main(int argc, char const* const* argv);
+
+ // Construct CommandLineArguments with the given
+ // argc/argv. It is assumed that the string is already
+ // in the encoding used by this module.
+ CommandLineArguments(int argc, char const* const* argv);
+
+ // Construct CommandLineArguments with the given
+ // argc and wide argv. This is useful if wmain() is used.
+ CommandLineArguments(int argc, wchar_t const* const* argv);
+ ~CommandLineArguments();
+ CommandLineArguments(const CommandLineArguments&);
+ CommandLineArguments& operator=(const CommandLineArguments&);
+
+ int argc() const;
+ char const* const* argv() const;
+
+ protected:
+ std::vector<char*> argv_;
+ };
+
/**
* Convert between char and wchar_t
*/
diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c
index a36eecc..cda78e2 100644
--- a/Source/kwsys/EncodingC.c
+++ b/Source/kwsys/EncodingC.c
@@ -68,7 +68,7 @@ size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n)
char* kwsysEncoding_DupToNarrow(const wchar_t* str)
{
char* ret = NULL;
- size_t length = kwsysEncoding_wcstombs(0, str, 0);
+ size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1;
if(length > 0)
{
ret = malloc(length);
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index aebc148..f76deb5 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -29,6 +29,7 @@
#endif
#include <stdlib.h>
+#include <string.h>
#ifdef _MSC_VER
# pragma warning (disable: 4786)
@@ -42,6 +43,98 @@
namespace KWSYS_NAMESPACE
{
+Encoding::CommandLineArguments
+Encoding::CommandLineArguments::Main(int argc, char const* const* argv)
+{
+#ifdef _WIN32
+ (void) argc;
+ (void) argv;
+
+ int ac;
+ LPWSTR* w_av = CommandLineToArgvW(GetCommandLineW(), &ac);
+
+ std::vector<std::string> av1(ac);
+ std::vector<char const*> av2(ac);
+ for(int i=0; i<ac; i++)
+ {
+ av1[i] = ToNarrow(w_av[i]);
+ av2[i] = av1[i].c_str();
+ }
+ LocalFree(w_av);
+ return CommandLineArguments(ac, &av2[0]);
+#else
+ return CommandLineArguments(argc, argv);
+#endif
+}
+
+Encoding::CommandLineArguments::CommandLineArguments(int ac,
+ char const* const* av)
+{
+ this->argv_.resize(ac+1);
+ for(int i=0; i<ac; i++)
+ {
+ this->argv_[i] = strdup(av[i]);
+ }
+ this->argv_[ac] = 0;
+}
+
+Encoding::CommandLineArguments::CommandLineArguments(int ac,
+ wchar_t const* const* av)
+{
+ this->argv_.resize(ac+1);
+ for(int i=0; i<ac; i++)
+ {
+ this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]);
+ }
+ this->argv_[ac] = 0;
+}
+
+Encoding::CommandLineArguments::~CommandLineArguments()
+{
+ for(size_t i=0; i<this->argv_.size(); i++)
+ {
+ free(argv_[i]);
+ }
+}
+
+Encoding::CommandLineArguments::
+ CommandLineArguments(const CommandLineArguments& other)
+{
+ this->argv_.resize(other.argv_.size());
+ for(size_t i=0; i<this->argv_.size(); i++)
+ {
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ }
+}
+
+Encoding::CommandLineArguments&
+Encoding::CommandLineArguments::operator=(const CommandLineArguments& other)
+{
+ size_t i;
+ for(i=0; i<this->argv_.size(); i++)
+ {
+ free(this->argv_[i]);
+ }
+
+ this->argv_.resize(other.argv_.size());
+ for(i=0; i<this->argv_.size(); i++)
+ {
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ }
+
+ return *this;
+}
+
+int Encoding::CommandLineArguments::argc() const
+{
+ return static_cast<int>(this->argv_.size() - 1);
+}
+
+char const* const* Encoding::CommandLineArguments::argv() const
+{
+ return &this->argv_[0];
+}
+
#if KWSYS_STL_HAS_WSTRING
kwsys_stl::wstring Encoding::ToWide(const kwsys_stl::string& str)
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index 8170fb3..c340c55 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -81,7 +81,7 @@ namespace @KWSYS_NAMESPACE@
internal_buffer_type *rdbuf() const
{
- return buf_.get();
+ return buf_;
}
~basic_ifstream()
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index b9af2f1..faeb967 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -2449,6 +2449,7 @@ static void kwsysProcessKill(pid_t process_id)
if(f)
{
size_t nread = fread(buffer, 1, KWSYSPE_PIPE_BUFFER_SIZE, f);
+ fclose(f);
buffer[nread] = '\0';
if(nread > 0)
{
@@ -2463,7 +2464,6 @@ static void kwsysProcessKill(pid_t process_id)
}
}
}
- fclose(f);
}
}
}
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 2f6c949..5f20853 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3162,8 +3162,17 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
kwsys_stl::string cores =
this->ExtractValueFromCpuInfoFile(buffer,"cpu cores");
int numberOfCoresPerCPU=atoi(cores.c_str());
- this->NumberOfPhysicalCPU=static_cast<unsigned int>(
- numberOfCoresPerCPU*(maxId+1));
+ if (maxId > 0)
+ {
+ this->NumberOfPhysicalCPU=static_cast<unsigned int>(
+ numberOfCoresPerCPU*(maxId+1));
+ }
+ else
+ {
+ // Linux Sparc: get cpu count
+ this->NumberOfPhysicalCPU=
+ atoi(this->ExtractValueFromCpuInfoFile(buffer,"ncpus active").c_str());
+ }
#else // __CYGWIN__
// does not have "physical id" entries, neither "cpu cores"
@@ -3185,7 +3194,19 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
// CPU speed (checking only the first processor)
kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz");
- this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str()));
+ if(!CPUSpeed.empty())
+ {
+ this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str()));
+ }
+#ifdef __linux
+ else
+ {
+ // Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
+ CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"Cpu0ClkTck");
+ this->CPUSpeedInMHz = static_cast<float>(
+ strtoull(CPUSpeed.c_str(),0,16))/1000000.0f;
+ }
+#endif
// Chip family
kwsys_stl::string familyStr =
@@ -4991,7 +5012,12 @@ bool SystemInformationImplementation::QueryHPUXProcessor()
case CPU_PA_RISC2_0:
this->ChipID.Vendor = "Hewlett-Packard";
this->ChipID.Family = 0x200;
+# ifdef CPU_HP_INTEL_EM_1_0
+ case CPU_HP_INTEL_EM_1_0:
+# endif
+# ifdef CPU_IA64_ARCHREV_0
case CPU_IA64_ARCHREV_0:
+# endif
this->ChipID.Vendor = "GenuineIntel";
this->Features.HasIA64 = true;
break;
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 4649f3b..f4a443f 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2115,10 +2115,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
SystemTools::RemoveFile(destination);
#if defined(_WIN32) || defined(__CYGWIN__)
- kwsys_ios::ofstream fout(destination,
+ kwsys::ofstream fout(destination,
kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc);
#else
- kwsys_ios::ofstream fout(destination,
+ kwsys::ofstream fout(destination,
kwsys_ios::ios::out | kwsys_ios::ios::trunc);
#endif
if(!fout)
diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx
index 8e74a50..094588c 100644
--- a/Source/kwsys/testEncoding.cxx
+++ b/Source/kwsys/testEncoding.cxx
@@ -16,14 +16,18 @@
#endif
#include KWSYS_HEADER(Encoding.hxx)
+#include KWSYS_HEADER(Encoding.h)
#include KWSYS_HEADER(ios/iostream)
#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "Encoding.hxx.in"
+# include "Encoding.h.in"
# include "kwsys_ios_iostream.h.in"
#endif
@@ -68,11 +72,16 @@ static int testHelloWorldEncoding()
std::cout << str << std::endl;
std::wstring wstr = kwsys::Encoding::ToWide(str);
std::string str2 = kwsys::Encoding::ToNarrow(wstr);
- if(!wstr.empty() && str != str2)
+ wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str());
+ char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr);
+ if(!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str())))
{
std::cout << "converted string was different: " << str2 << std::endl;
+ std::cout << "converted string was different: " << c_str2 << std::endl;
ret++;
}
+ free(c_wstr);
+ free(c_str2);
}
return ret;
}
@@ -136,6 +145,36 @@ static int testRobustEncoding()
return ret;
}
+static int testCommandLineArguments()
+{
+ int status = 0;
+
+ char const* argv[2] = {
+ "./app.exe",
+ (char const*)helloWorldStrings[1]
+ };
+
+ kwsys::Encoding::CommandLineArguments args(2, argv);
+ kwsys::Encoding::CommandLineArguments arg2 =
+ kwsys::Encoding::CommandLineArguments(args);
+
+ char const* const* u8_argv = args.argv();
+ for(int i=0; i<args.argc(); i++)
+ {
+ char const* u8_arg = u8_argv[i];
+ if(strcmp(argv[i], u8_arg) != 0)
+ {
+ std::cout << "argv[" << i << "] " << argv[i] << " != "
+ << u8_arg << std::endl;
+ status++;
+ }
+ }
+
+ kwsys::Encoding::CommandLineArguments args3 =
+ kwsys::Encoding::CommandLineArguments::Main(2, argv);
+
+ return status;
+}
//----------------------------------------------------------------------------
int testEncoding(int, char*[])
@@ -154,6 +193,7 @@ int testEncoding(int, char*[])
ret |= testHelloWorldEncoding();
ret |= testRobustEncoding();
+ ret |= testCommandLineArguments();
return ret;
}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 9e74b7d..5ea604f 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -285,24 +285,6 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
endif()
- if(CMAKE_TEST_GENERATOR MATCHES Make)
- set(InterfaceBuildTargets_libname testlib)
- if (CMAKE_TEST_GENERATOR MATCHES "Borland|Watcom")
- set(InterfaceBuildTargets_libname testlib.lib)
- endif()
- add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets"
- "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets"
- --build-two-config
- ${build_generator_args}
- --build-project InterfaceBuildTargets
- --build-options ${build_options}
- --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname}
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets")
- endif()
-
list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
if(NOT QT4_FOUND)
diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt
index ecfecdb..0b06045 100644
--- a/Tests/CPackWiXGenerator/CMakeLists.txt
+++ b/Tests/CPackWiXGenerator/CMakeLists.txt
@@ -49,6 +49,8 @@ set(CPACK_PACKAGE_EXECUTABLES
"my-other-app" "Second CPack WiX Test"
)
+set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml")
+
include(CPack)
cpack_add_install_type(Full DISPLAY_NAME "Everything")
diff --git a/Tests/CPackWiXGenerator/patch.xml b/Tests/CPackWiXGenerator/patch.xml
new file mode 100644
index 0000000..13c392d
--- /dev/null
+++ b/Tests/CPackWiXGenerator/patch.xml
@@ -0,0 +1,7 @@
+<CPackWiXPatch>
+ <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe">
+ <Environment Id="MyEnvironment" Action="set"
+ Name="CPackWiXGeneratorTest"
+ Value="CPackWiXGeneratorTest"/>
+ </CPackWiXFragment>
+</CPackWiXPatch>
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt
index b5162c9..9bd7249 100644
--- a/Tests/CTestTestMemcheck/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/CMakeLists.txt
@@ -1,5 +1,13 @@
REGEX_ESCAPE_STRING(CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+get_filename_component(CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR
+ "${CMAKE_CURRENT_BINARY_DIR}" REALPATH
+)
+
+REGEX_ESCAPE_STRING(CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR
+ "${CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR}"
+)
+
foreach (_retval 0 1)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY)
endforeach ()
@@ -180,7 +188,7 @@ set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES
PASS_REGULAR_EXPRESSION "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n(.*\n)?Error parsing XML in stream at line 1: no element found\n")
set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES
- PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n")
+ PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n")
set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES
PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n")
diff --git a/Tests/Contracts/VTK/Dashboard.cmake.in b/Tests/Contracts/VTK/Dashboard.cmake.in
index e33a2de..c3d10f4 100644
--- a/Tests/Contracts/VTK/Dashboard.cmake.in
+++ b/Tests/Contracts/VTK/Dashboard.cmake.in
@@ -1,3 +1,11 @@
+# This submission's role is to test leading edge of cmake development
+# against VTK release
+#
+# Maintainer: Zack Galbreath <zack.galbreath@kitware.com>
+#
+# This file was generated as part of the CMake/VTK Contracts test.
+# See <CMake-src>/Tests/Contracts/VTK/ for more information
+
set(CTEST_SITE "@SITE@")
set(CTEST_BUILD_NAME "Contracts.VTK")
set(CTEST_DASHBOARD_ROOT "@base_dir@")
@@ -6,6 +14,7 @@ set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/VTK-build")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_CONFIGURATION_TYPE Debug)
+set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
# Assume a Linux build, with a make that supports -j9. Modify this script if
# assumption is ever invalid.
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index edadb87..892f80f 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -193,9 +193,9 @@ add_custom_target(check-part3 ALL
-Dtest_platform_id_Linux=$<PLATFORM_ID:Linux>
-Dtest_platform_id_Windows=$<PLATFORM_ID:Windows>
-Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin>
- -Dlower_case=$<LOWER_CASE:MiXeD>
- -Dupper_case=$<UPPER_CASE:MiXeD>
- -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4foo:+bar-$>
+ -Dlower_case=$<LOWER_CASE:Mi,XeD>
+ -Dupper_case=$<UPPER_CASE:MiX,eD>
+ -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4f,oo:+bar-$>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
VERBATIM
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index a86db31..3361eeb 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -34,6 +34,6 @@ foreach(system Linux Windows Darwin)
check(test_platform_id_${system} 0)
endif()
endforeach()
-check(lower_case "mixed")
-check(upper_case "MIXED")
-check(make_c_identifier "_4foo__bar__")
+check(lower_case "mi,xed")
+check(upper_case "MIX,ED")
+check(make_c_identifier "_4f_oo__bar__")
diff --git a/Tests/InterfaceBuildTargets/CMakeLists.txt b/Tests/InterfaceBuildTargets/CMakeLists.txt
deleted file mode 100644
index a00e5d5..0000000
--- a/Tests/InterfaceBuildTargets/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-project(InterfaceBuildTargets)
-
-add_library(testlib EXCLUDE_FROM_ALL testlib.cxx)
-set_property(TARGET testlib PROPERTY PREFIX "")
-if(CMAKE_GENERATOR MATCHES "Borland|Watcom")
- # These librarians add the .lib suffix anyway.
- set_property(TARGET testlib PROPERTY SUFFIX ".lib")
-else()
- set_property(TARGET testlib PROPERTY SUFFIX "")
-endif()
-
-add_library(iface INTERFACE)
-target_link_libraries(iface INTERFACE testlib)
diff --git a/Tests/InterfaceBuildTargets/main.cxx b/Tests/InterfaceBuildTargets/main.cxx
deleted file mode 100644
index e9ad257..0000000
--- a/Tests/InterfaceBuildTargets/main.cxx
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int main(int, char**)
-{
- return 0;
-}
diff --git a/Tests/InterfaceBuildTargets/testlib.cxx b/Tests/InterfaceBuildTargets/testlib.cxx
deleted file mode 100644
index 02bd6b0..0000000
--- a/Tests/InterfaceBuildTargets/testlib.cxx
+++ /dev/null
@@ -1,5 +0,0 @@
-
-void testlib(void)
-{
-
-}
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index 53aeb03..8154ced 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -13,3 +13,17 @@ add_subdirectory(libsdir)
add_executable(sharedlibtestexe sharedlibtestexe.cpp)
target_link_libraries(sharedlibtestexe shared_iface)
+
+add_library(broken EXCLUDE_FROM_ALL broken.cpp)
+
+add_library(iface_broken INTERFACE)
+# This is not a dependency, so broken will not be built (and the error in
+# it will not be hit)
+target_link_libraries(iface_broken INTERFACE broken)
+
+add_library(iface_whitelist INTERFACE)
+# The target property CUSTOM will never be evaluated on the INTERFACE library.
+target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>)
+
+add_executable(exec_whitelist dummy.cpp)
+target_link_libraries(exec_whitelist iface_whitelist)
diff --git a/Tests/InterfaceLibrary/broken.cpp b/Tests/InterfaceLibrary/broken.cpp
new file mode 100644
index 0000000..1fd1041
--- /dev/null
+++ b/Tests/InterfaceLibrary/broken.cpp
@@ -0,0 +1,2 @@
+
+#error Broken
diff --git a/Tests/InterfaceLibrary/dummy.cpp b/Tests/InterfaceLibrary/dummy.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/InterfaceLibrary/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index 09f1881..bf867a9 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -55,93 +55,9 @@ else()
endif()
endif()
-set(DEPS
- libshared
- libstatic
- lib_shared_and_static
-)
-
-foreach(DEP ${DEPS})
- try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build
- ${CMAKE_CURRENT_SOURCE_DIR}/${DEP}
- ${DEP}
- OUTPUT_VARIABLE Out
- )
- if (NOT Result)
- message("OUTPUT: ${Out}")
- endif()
-endforeach()
-
-# The _do_build macro is called from a child scope, where
-# the current source and binary dir are different. Save them here
-# for use in the macro.
-set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
-
-# We seem to get race conditions is writing this stuff to the same file at least on MinGW
-# So to write to separate source and build directories, we use a count to differentiate.
-set (COUNT 0)
-macro(_do_build Include Library LibrarySource Source)
-
- math(EXPR COUNT "${COUNT} + 1" )
-
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n"
- "int main() { ${Source}; }\n"
- )
-
- if ("${Library}" STREQUAL "static_variant")
- set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n")
- endif()
-
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
- "cmake_minimum_required(VERSION 2.8)\n"
-
- "project(compiletest)\n"
-
- "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n"
-
- "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n"
-
- "include(GenerateExportHeader)\n"
-
- "add_compiler_export_flags()\n"
-
- "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n"
- " add_definitions(${ERROR_FLAG})\n"
- "endif()\n"
-
- "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n"
-
- "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n"
- " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n"
-
- "${CONDITIONAL_STATIC_DEFINE}"
-
- "add_executable(compiletest src.cpp)\n"
- "target_link_libraries(compiletest ${Library})\n"
- )
-
- try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT}
- ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}
- compiletest
- OUTPUT_VARIABLE Out
- )
-endmacro()
-
-macro(build_fail Include Library LibrarySource Source Message)
- _do_build(${Include} ${Library} ${LibrarySource} "${Source}")
- test_fail(Result ${Message})
-endmacro()
-
-macro(build_pass Include Library LibrarySource Source Message)
- _do_build(${Include} ${Library} ${LibrarySource} "${Source}")
- test_pass(Result ${Message})
-endmacro()
-
include(GenerateExportHeader)
-add_subdirectory(visibility_preset)
+add_subdirectory(lib_shared_and_static)
add_compiler_export_flags()
@@ -159,23 +75,17 @@ macro(macro_add_test_library name)
${${name}_BINARY_DIR} # For the export header.
)
list(APPEND link_libraries ${name})
- add_subdirectory(${name}test)
endmacro()
macro_add_test_library(libshared)
macro_add_test_library(libstatic)
-add_subdirectory(lib_shared_and_static)
-add_subdirectory(lib_shared_and_statictest)
-add_subdirectory(override_symbol)
add_subdirectory(nodeprecated)
-add_subdirectory(prefix)
if(NOT BORLAND)
add_subdirectory(c_identifier)
endif()
if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
- # We deliberately call deprecated methods, and test for that elsewhere.
# No need to clutter the test output with warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()
@@ -187,3 +97,24 @@ endif()
add_executable(GenerateExportHeader exportheader_test.cpp)
target_link_libraries(GenerateExportHeader ${link_libraries})
+if (WIN32)
+ if(MSVC AND COMPILER_HAS_DEPRECATED)
+ set(_platform Win32)
+ elseif(MINGW AND COMPILER_HAS_DEPRECATED)
+ set(_platform MinGW)
+ else()
+ set(_platform WinEmpty)
+ endif()
+elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY)
+ set(_platform UNIX)
+elseif(COMPILER_HAS_DEPRECATED)
+ set(_platform UNIX_DeprecatedOnly)
+else()
+ set(_platform Empty)
+endif()
+message("#### Testing reference: ${_platform}")
+target_compile_definitions(GenerateExportHeader
+ PRIVATE
+ "SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}"
+ "BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+)
diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
index 55c3c1a..146374a 100644
--- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
@@ -11,6 +11,52 @@
#define DOES_NOT_BUILD(function) function
#endif
+#include <fstream>
+#include <iostream>
+#include <stdlib.h>
+#include <string>
+
+void compare(const char* refName, const char* testName)
+{
+ std::ifstream ref;
+ ref.open(refName);
+ if (!ref.is_open())
+ {
+ std::cout << "Could not open \"" << refName << "\"." << std::endl;
+ exit(1);
+ }
+ std::ifstream test;
+ test.open(testName);
+ if (!test.is_open())
+ {
+ std::cout << "Could not open \"" << testName << "\"." << std::endl;
+ exit(1);
+ }
+
+ while (!ref.eof() && !test.eof())
+ {
+ std::string refLine;
+ std::string testLine;
+ std::getline(ref, refLine);
+ std::getline(test, testLine);
+ if (testLine.size() && testLine[testLine.size()-1] == ' ')
+ {
+ testLine = testLine.substr(0, testLine.size() - 1);
+ }
+ if (refLine != testLine)
+ {
+ std::cout << "Ref and test are not the same:\n Ref: \""
+ << refLine << "\"\n Test: \"" << testLine << "\"\n";
+ exit(1);
+ }
+ }
+ if (!ref.eof() || !test.eof())
+ {
+ std::cout << "Ref and test have differing numbers of lines.";
+ exit(1);
+ }
+}
+
int main()
{
{
@@ -78,5 +124,13 @@ int main()
libstatic_not_exported();
libstatic_excluded();
+#define STRINGIFY_IMPL(A) #A
+#define STRINGIFY(A) STRINGIFY_IMPL(A)
+
+ compare(STRINGIFY(SRC_DIR) "/libshared_export.h",
+ STRINGIFY(BIN_DIR) "/libshared/libshared_export.h");
+ compare(STRINGIFY(SRC_DIR) "/libstatic_export.h",
+ STRINGIFY(BIN_DIR) "/libstatic/libstatic_export.h");
+
return 0;
}
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt
index be0387f..c1be125 100644
--- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt
@@ -5,7 +5,15 @@ project(lib_shared_and_static)
include(GenerateExportHeader)
-add_compiler_export_flags()
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
+ message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
+endif()
+if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden")
+ message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
+endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -14,9 +22,13 @@ set(lib_SRCS
)
add_library(shared_variant SHARED ${lib_SRCS})
+set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL)
add_library(static_variant ${lib_SRCS})
-generate_export_header(shared_variant BASE_NAME libshared_and_static)
+generate_export_header(shared_variant
+ BASE_NAME libshared_and_static
+ PREFIX_NAME MYPREFIX_
+)
set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
index 049bfe9..5ad77f4 100644
--- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
@@ -4,51 +4,51 @@
#include "libshared_and_static_export.h"
-class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
+class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
public:
int libshared_and_static() const;
int libshared_and_static_exported() const;
- int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
- int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
class LibsharedAndStaticNotExported {
public:
int libshared_and_static() const;
- int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
- int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
- int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
-class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
+class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
public:
int libshared_and_static() const;
- int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
- int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
- int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+ int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
-LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
+MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
-LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
+MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
int libshared_and_static_not_exported();
-int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
+int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
#endif
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt
deleted file mode 100644
index 207534d..0000000
--- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-
-macro(shared_variant_build_pass Source Message)
- build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message})
-endmacro()
-
-macro(shared_variant_build_fail Source Message)
- build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message})
-endmacro()
-
-macro(static_variant_build_pass Source Message)
- build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message})
-endmacro()
-
-macro(static_variant_build_fail Source Message)
- build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message})
-endmacro()
-
-static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant")
-shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant")
-# if (COMPILER_HAS_DEPRECATED)
-# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant")
-# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant")
-# else()
-# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant")
-# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant")
-# endif()
-static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant")
-
-if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY)
- shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant")
-else()
- shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant")
-endif()
diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt
deleted file mode 100644
index 2a97d8f..0000000
--- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-
-macro(shared_build_pass Source Message)
- build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message})
-endmacro()
-
-macro(shared_build_fail Source Message)
- build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message})
-endmacro()
-
-shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported")
-shared_build_pass("return libshared_exported();" "Failed to build exported function.")
-
-# if (COMPILER_HAS_DEPRECATED)
-# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.")
-# else()
-# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.")
-# endif()
-if (COMPILER_HAS_HIDDEN_VISIBILITY)
- shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.")
-else()
- # There is no MSVC equivalent to hiding symbols.
- shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.")
-endif()
-
-if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY)
- shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.")
- shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.")
- shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.")
- shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.")
- shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.")
- shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.")
-
- shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.")
- shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.")
-else()
- shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.")
- shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.")
- shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.")
- shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.")
- shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.")
- shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.")
-
- shared_build_pass("return libshared_excluded();" "Built use of excluded function.")
- shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.")
-endif()
diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt
deleted file mode 100644
index eb6bb87..0000000
--- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-
-macro(static_build_pass Source Message)
- build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message})
-endmacro()
-
-macro(static_build_fail Source Message)
- build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message})
-endmacro()
-
-static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.")
-
-# if (COMPILER_HAS_DEPRECATED)
-# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.")
-# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.")
-# else()
-# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.")
-# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.")
-# endif()
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt
deleted file mode 100644
index aeeef20..0000000
--- a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-project(override_symbol)
-
-add_library(somelib SHARED someclass.cpp)
-
-set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL)
-
-generate_export_header(somelib)
-
-add_executable(consumer main.cpp)
-
-target_link_libraries(consumer somelib)
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp
deleted file mode 100644
index eec46d3..0000000
--- a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "someclass.h"
-
-int main(int, char**)
-{
- SomeClass sc;
- sc.someMethod();
- return 0;
-}
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp
deleted file mode 100644
index 427ec29..0000000
--- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "someclass.h"
-
-void SomeClass::someMethod() const
-{
-
-}
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h
deleted file mode 100644
index ae5e844..0000000
--- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include "somelib_export.h"
-
-class SOMELIB_EXPORT SomeClass
-{
-public:
- void someMethod() const;
-};
diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt
deleted file mode 100644
index bd64df2..0000000
--- a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-project(use_prefix)
-
-set(use_prefix_lib_SRCS
- useprefixclass.cpp
-)
-
-add_library(use_prefix_lib SHARED useprefixclass.cpp)
-
-generate_export_header(use_prefix_lib
- PREFIX_NAME MYPREFIX_
-)
-
-add_executable(use_prefix main.cpp)
-
-target_link_libraries(use_prefix use_prefix_lib) \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp
deleted file mode 100644
index 507f6fd..0000000
--- a/Tests/Module/GenerateExportHeader/prefix/main.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include "useprefixclass.h"
-
-int main(int argc, char **argv)
-{
- UsePrefixClass upc;
- return upc.someMethod();
-}
diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp
deleted file mode 100644
index 1fd2cb2..0000000
--- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "useprefixclass.h"
-
-int UsePrefixClass::someMethod() const
-{
- return 0;
-}
diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h
deleted file mode 100644
index f5e31b5..0000000
--- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#ifndef USEPREFIXCLASS_H
-#define USEPREFIXCLASS_H
-
-#include "use_prefix_lib_export.h"
-
-class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass
-{
-public:
- int someMethod() const;
-};
-
-#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h
new file mode 100644
index 0000000..b6749b2
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h
new file mode 100644
index 0000000..e8000e2
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h
new file mode 100644
index 0000000..d376631
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT __declspec(dllexport)
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT __declspec(dllimport)
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h
new file mode 100644
index 0000000..fd021e9
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h
new file mode 100644
index 0000000..7d8087f
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT __attribute__((visibility("default")))
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT __attribute__((visibility("default")))
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT __attribute__((visibility("hidden")))
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h
new file mode 100644
index 0000000..fd021e9
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
new file mode 100644
index 0000000..5681f58
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
new file mode 100644
index 0000000..fd021e9
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h
new file mode 100644
index 0000000..976c92e
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT __declspec(dllexport)
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT __declspec(dllimport)
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED __declspec(deprecated)
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h
new file mode 100644
index 0000000..db4df61
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED __declspec(deprecated)
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h
new file mode 100644
index 0000000..2dc41d4
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+# define LIBSHARED_EXPORT
+# define LIBSHARED_NO_EXPORT
+#else
+# ifndef LIBSHARED_EXPORT
+# ifdef libshared_EXPORTS
+ /* We are building this library */
+# define LIBSHARED_EXPORT __declspec(dllexport)
+# else
+ /* We are using this library */
+# define LIBSHARED_EXPORT __declspec(dllimport)
+# endif
+# endif
+
+# ifndef LIBSHARED_NO_EXPORT
+# define LIBSHARED_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+# define LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSHARED_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
new file mode 100644
index 0000000..e8000e2
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
@@ -0,0 +1,41 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+# define LIBSTATIC_EXPORT
+# define LIBSTATIC_NO_EXPORT
+#else
+# ifndef LIBSTATIC_EXPORT
+# ifdef libstatic_EXPORTS
+ /* We are building this library */
+# define LIBSTATIC_EXPORT
+# else
+ /* We are using this library */
+# define LIBSTATIC_EXPORT
+# endif
+# endif
+
+# ifndef LIBSTATIC_NO_EXPORT
+# define LIBSTATIC_NO_EXPORT
+# endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+# define LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#define DEFINE_NO_DEPRECATED 0
+#if DEFINE_NO_DEPRECATED
+# define LIBSTATIC_NO_DEPRECATED
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
deleted file mode 100644
index 2571d22..0000000
--- a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-
-set(CMAKE_CXX_VISIBILITY_PRESET hidden)
-set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
-
-if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
- message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
-endif()
-if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden")
- message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
-endif()
-
-add_library(visibility_preset SHARED visibility_preset.cpp)
-generate_export_header(visibility_preset)
-
-add_executable(visibility_preset_exe main.cpp)
-
-target_link_libraries(visibility_preset_exe visibility_preset)
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp
deleted file mode 100644
index 89c3977..0000000
--- a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "visibility_preset.h"
-
-int main()
-{
- VisibilityPreset vp;
- vp.someMethod();
- return 0;
-}
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp
deleted file mode 100644
index c97dec6..0000000
--- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "visibility_preset.h"
-
-void VisibilityPreset::someMethod()
-{
-
-}
diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h
deleted file mode 100644
index 8becbe1..0000000
--- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#ifndef VISIBILITY_PRESET_H
-#define VISIBILITY_PRESET_H
-
-#include "visibility_preset_export.h"
-
-class VISIBILITY_PRESET_EXPORT VisibilityPreset
-{
-public:
- void someMethod();
-};
-
-#endif
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
index a7b0799..711ad0e 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
@@ -1,6 +1,6 @@
CMake Error at CMP0028-NEW.cmake:4 \(add_library\):
Target "foo" links to target "External::Library" but the target was not
found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- a ALIAS target is missing\?
+ an ALIAS target is missing\?
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
index 2ff6927..41d7560 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
@@ -5,7 +5,7 @@ CMake Warning \(dev\) at CMP0028-WARN.cmake:2 \(add_library\):
Target "foo" links to target "External::Library" but the target was not
found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- a ALIAS target is missing\?
+ an ALIAS target is missing\?
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
index e257fb3..0d00b71 100644
--- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake
@@ -4,3 +4,4 @@ run_cmake(invalid_name)
run_cmake(target_commands)
run_cmake(no_shared_libs)
run_cmake(whitelist)
+run_cmake(genex_link)
diff --git a/Tests/RunCMake/interface_library/genex_link-result.txt b/Tests/RunCMake/interface_library/genex_link-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/interface_library/genex_link-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/interface_library/genex_link-stderr.txt b/Tests/RunCMake/interface_library/genex_link-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/interface_library/genex_link-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/interface_library/genex_link.cmake b/Tests/RunCMake/interface_library/genex_link.cmake
new file mode 100644
index 0000000..0dbf029
--- /dev/null
+++ b/Tests/RunCMake/interface_library/genex_link.cmake
@@ -0,0 +1,22 @@
+
+cmake_minimum_required(VERSION 2.8.12.20131125 FATAL_ERROR)
+
+project(genex_link)
+
+set(_main_cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
+file(WRITE ${_main_cpp}
+ "int main(int argc, char** argv) { return 0; }\n"
+)
+
+add_library(foo::bar INTERFACE IMPORTED)
+set_target_properties(foo::bar
+ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
+ # When not using a generator expression here, no error is generated
+ INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:foo_bar.lib>"
+)
+
+add_executable(main ${_main_cpp})
+target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
+
+target_link_libraries(main foo::bar)
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 146e1f6..1955e42 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -14,7 +14,12 @@ import re
from docutils.parsers.rst import Directive, directives
from docutils.transforms import Transform
-from docutils.utils.error_reporting import SafeString, ErrorString
+try:
+ from docutils.utils.error_reporting import SafeString, ErrorString
+except ImportError:
+ # error_reporting was not in utils before version 0.11:
+ from docutils.error_reporting import SafeString, ErrorString
+
from docutils import io, nodes
from sphinx.directives import ObjectDescription
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index a4dc710..c7c808f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -2412,9 +2412,10 @@ tar_atol(const char *p, size_t char_cnt)
static int64_t
tar_atol_base_n(const char *p, size_t char_cnt, int base)
{
- int64_t l, limit, last_digit_limit;
+ int64_t l, maxval, limit, last_digit_limit;
int digit, sign;
+ maxval = INT64_MAX;
limit = INT64_MAX / base;
last_digit_limit = INT64_MAX % base;
@@ -2431,6 +2432,10 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base)
sign = -1;
p++;
char_cnt--;
+
+ maxval = INT64_MIN;
+ limit = -(INT64_MIN / base);
+ last_digit_limit = INT64_MIN % base;
}
l = 0;
@@ -2438,8 +2443,7 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base)
digit = *p - '0';
while (digit >= 0 && digit < base && char_cnt != 0) {
if (l>limit || (l == limit && digit > last_digit_limit)) {
- l = INT64_MAX; /* Truncate on overflow. */
- break;
+ return maxval; /* Truncate on overflow. */
}
l = (l * base) + digit;
digit = *++p - '0';
@@ -2462,32 +2466,56 @@ tar_atol10(const char *p, size_t char_cnt)
}
/*
- * Parse a base-256 integer. This is just a straight signed binary
- * value in big-endian order, except that the high-order bit is
- * ignored.
+ * Parse a base-256 integer. This is just a variable-length
+ * twos-complement signed binary value in big-endian order, except
+ * that the high-order bit is ignored. The values here can be up to
+ * 12 bytes, so we need to be careful about overflowing 64-bit
+ * (8-byte) integers.
+ *
+ * This code unashamedly assumes that the local machine uses 8-bit
+ * bytes and twos-complement arithmetic.
*/
static int64_t
tar_atol256(const char *_p, size_t char_cnt)
{
- int64_t l, upper_limit, lower_limit;
+ uint64_t l;
const unsigned char *p = (const unsigned char *)_p;
+ unsigned char c, neg;
+
+ /* Extend 7-bit 2s-comp to 8-bit 2s-comp, decide sign. */
+ c = *p;
+ if (c & 0x40) {
+ neg = 0xff;
+ c |= 0x80;
+ l = ~ARCHIVE_LITERAL_ULL(0);
+ } else {
+ neg = 0;
+ c &= 0x7f;
+ l = 0;
+ }
- upper_limit = INT64_MAX / 256;
- lower_limit = INT64_MIN / 256;
+ /* If more than 8 bytes, check that we can ignore
+ * high-order bits without overflow. */
+ while (char_cnt > sizeof(int64_t)) {
+ --char_cnt;
+ if (c != neg)
+ return neg ? INT64_MIN : INT64_MAX;
+ c = *++p;
+ }
- /* Sign-extend the 7-bit value to 64 bits. */
- if ((0x40 & *p) == 0x40)
- l = ~((int64_t)0x3f) | *p++;
- else
- l = 0x3f & *p++;
+ /* c is first byte that fits; if sign mismatch, return overflow */
+ if ((c ^ neg) & 0x80) {
+ return neg ? INT64_MIN : INT64_MAX;
+ }
+
+ /* Accumulate remaining bytes. */
while (--char_cnt > 0) {
- if (l > upper_limit)
- return (INT64_MAX); /* Truncate on overflow */
- else if (l < lower_limit)
- return (INT64_MIN);
- l = (l << 8) | (0xff & (int64_t)*p++);
+ l = (l << 8) | c;
+ c = *++p;
}
- return (l);
+ l = (l << 8) | c;
+ /* Return signed twos-complement value. */
+ return (int64_t)(l);
}
/*