summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/add_library.rst28
-rw-r--r--Help/manual/cmake-buildsystem.7.rst38
-rw-r--r--Help/manual/cmake-developer.7.rst7
-rw-r--r--Modules/ProcessorCount.cmake4
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake10
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/cpack.cxx2
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx40
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h5
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx167
-rw-r--r--Source/CTest/cmParseJacocoCoverage.h59
-rw-r--r--Source/CursesDialog/ccmake.cxx2
-rw-r--r--Source/cmDefinitions.cxx38
-rw-r--r--Source/cmDefinitions.h17
-rw-r--r--Source/cmMakefile.cxx2
-rw-r--r--Source/cmakemain.cxx2
-rw-r--r--Source/ctest.cxx2
-rw-r--r--Tests/CMakeLists.txt16
-rw-r--r--Tests/JacocoCoverage/Coverage/src/main/java/org/cmake/CoverageTest.java52
-rw-r--r--Tests/JacocoCoverage/Coverage/target/site/jacoco.xml1
-rw-r--r--Tests/JacocoCoverage/DartConfiguration.tcl.in8
22 files changed, 455 insertions, 48 deletions
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index e93ef53..f19b5c0 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -1,8 +1,15 @@
add_library
-----------
+.. only:: html
+
+ .. contents::
+
Add a library to the project using the specified source files.
+Normal Libraries
+^^^^^^^^^^^^^^^^
+
::
add_library(<name> [STATIC | SHARED | MODULE]
@@ -44,7 +51,8 @@ the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
---------------------------------------------------------------------------
+Imported Libraries
+^^^^^^^^^^^^^^^^^^
::
@@ -65,14 +73,15 @@ variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the
location of the main library file on disk. See documentation of the
``IMPORTED_*`` and ``INTERFACE_*`` properties for more information.
---------------------------------------------------------------------------
+Object Libraries
+^^^^^^^^^^^^^^^^
::
add_library(<name> OBJECT <src>...)
-Creates a special "object library" target. An object library compiles
-source files but does not archive or link their object files into a
+Creates an :ref:`Object Library <Object Libraries>`. An object library
+compiles source files but does not archive or link their object files into a
library. Instead other targets created by :command:`add_library` or
:command:`add_executable` may reference the objects using an expression of the
form ``$<TARGET_OBJECTS:objlib>`` as a source, where ``objlib`` is the
@@ -93,7 +102,8 @@ systems may not like targets that have only object files, so consider
adding at least one real source file to any target that references
``$<TARGET_OBJECTS:objlib>``.
---------------------------------------------------------------------------
+Alias Libraries
+^^^^^^^^^^^^^^^
::
@@ -111,7 +121,8 @@ operand of :command:`set_property`, :command:`set_target_properties`,
:command:`target_link_libraries` etc. An ``ALIAS`` target may not be
installed or exported.
---------------------------------------------------------------------------
+Interface Libraries
+^^^^^^^^^^^^^^^^^^^
::
@@ -124,8 +135,9 @@ imported. Typically the ``INTERFACE_*`` properties are populated on
the interface target using the :command:`set_property`,
:command:`target_link_libraries(INTERFACE)`,
:command:`target_include_directories(INTERFACE)`,
-:command:`target_compile_options(INTERFACE)`
-and :command:`target_compile_definitions(INTERFACE)` commands, and then it
+:command:`target_compile_options(INTERFACE)`,
+:command:`target_compile_definitions(INTERFACE)`,
+and :command:`target_sources(INTERFACE)` commands, and then it
is used as an argument to :command:`target_link_libraries` like any other
target.
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index fdd1be4..a7402f7 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -19,8 +19,8 @@ and the rules for regeneration in response to change.
Binary Targets
==============
-Executables and libraries are defined using the :command:`add_library`
-and :command:`add_executable` commands. The resulting binary files have
+Executables and libraries are defined using the :command:`add_executable`
+and :command:`add_library` commands. The resulting binary files have
appropriate prefixes, suffixes and extensions for the platform targeted.
Dependencies between binary targets are expressed using the
:command:`target_link_libraries` command:
@@ -37,9 +37,28 @@ is defined as an executable formed by compiling and linking ``zipapp.cpp``.
When linking the ``zipapp`` executable, the ``archive`` static library is
linked in.
+Binary Executables
+------------------
+
+The :command:`add_executable` command defines an executable target:
+
+.. code-block:: cmake
+
+ add_executable(mytool mytool.cpp)
+
+Commands such as :command:`add_custom_command`, which generates rules to be
+run at build time can transparently use an :prop_tgt:`EXECUTABLE <TYPE>`
+target as a ``COMMAND`` executable. The buildsystem rules will ensure that
+the executable is built before attempting to run the command.
+
Binary Library Types
--------------------
+.. _`Normal Libraries`:
+
+Normal Libraries
+^^^^^^^^^^^^^^^^
+
By default, the :command:`add_library` command defines a static library,
unless a type is specified. A type may be specified when using the command:
@@ -66,6 +85,11 @@ It is a type which is loaded as a plugin using runtime techniques.
add_library(archive MODULE 7z.cpp)
+.. _`Object Libraries`:
+
+Object Libraries
+^^^^^^^^^^^^^^^^
+
The ``OBJECT`` library type is also not linked to. It defines a non-archival
collection of object files resulting from compiling the given source files.
The object files collection can be used as source inputs to other targets:
@@ -83,11 +107,6 @@ they may not be installed, exported, or used in the right hand side of
:command:`target_link_libraries`. They also may not be used as the ``TARGET``
in a use of the :command:`add_custom_command(TARGET)` command signature.
-Commands such as :command:`add_custom_command`, which generates rules to be
-run at build time can transparently use an :prop_tgt:`EXECUTABLE <TYPE>`
-target as a ``COMMAND`` executable. The buildsystem rules will ensure that
-the executable is built before attempting to run the command.
-
Build Specification and Usage Requirements
==========================================
@@ -786,11 +805,12 @@ It may specify usage requirements such as
:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS`,
:prop_tgt:`INTERFACE_COMPILE_OPTIONS`,
:prop_tgt:`INTERFACE_LINK_LIBRARIES`, and
+:prop_tgt:`INTERFACE_SOURCES`,
:prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE`.
Only the ``INTERFACE`` modes of the :command:`target_include_directories`,
:command:`target_compile_definitions`, :command:`target_compile_options`,
-and :command:`target_link_libraries` commands may be used with ``INTERFACE``
-libraries.
+:command:`target_sources`, and :command:`target_link_libraries` commands
+may be used with ``INTERFACE`` libraries.
A primary use-case for ``INTERFACE`` libraries is header-only libraries.
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index 9851c12..cd979c9 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -521,14 +521,15 @@ Style: CMake Command Signatures
Command signatures should be marked up as plain literal blocks, not as
cmake ``code-blocks``.
-Signatures are separated from preceding content by a horizontal
-line. That is, use:
+Signatures are separated from preceding content by a section header.
+That is, use:
.. code-block:: rst
... preceding paragraph.
- ---------------------------------------------------------------------
+ Normal Libraries
+ ^^^^^^^^^^^^^^^^
::
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index e034a28..8f21adf 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -103,6 +103,10 @@ function(ProcessorCount var)
OUTPUT_VARIABLE machinfo_output)
string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}")
set(count "${CMAKE_MATCH_1}")
+ if(NOT count)
+ string(REGEX MATCHALL "([0-9]+) logical processors" procs "${machinfo_output}")
+ set(count "${CMAKE_MATCH_1}")
+ endif()
#message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'")
else()
find_program(ProcessorCount_cmd_mpsched mpsched)
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index bf2dc37..d7992fe 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -146,6 +146,16 @@
# ``[[deprecated]]`` attribute or a compiler-specific decorator such
# as ``__attribute__((__deprecated__))`` used by GNU compilers.
#
+# The ``cxx_alignas`` feature provides a macro definition
+# ``<PREFIX>_ALIGNAS`` which expands to either the standard ``alignas``
+# decorator or a compiler-specific decorator such as
+# ``__attribute__ ((__aligned__))`` used by GNU compilers.
+#
+# The ``cxx_alignof`` feature provides a macro definition
+# ``<PREFIX>_ALIGNOF`` which expands to either the standard ``alignof``
+# decorator or a compiler-specific decorator such as ``__alignof__``
+# used by GNU compilers.
+#
# ============================= ================================ =====================
# Feature Define Symbol
# ============================= ================================ =====================
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index fe6cc1b..c3c24fe 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -518,6 +518,7 @@ set(CTEST_SRCS cmCTest.cxx
CTest/cmParseMumpsCoverage.cxx
CTest/cmParseCacheCoverage.cxx
CTest/cmParseGTMCoverage.cxx
+ CTest/cmParseJacocoCoverage.cxx
CTest/cmParsePHPCoverage.cxx
CTest/cmParseCoberturaCoverage.cxx
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index c1694c6..b8fbc7e 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 0)
-set(CMake_VERSION_PATCH 20140612)
+set(CMake_VERSION_PATCH 20140613)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index ad37c42..98c62d5 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -101,7 +101,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
// this is CPack.
int main (int argc, char const* const* argv)
{
- setlocale(LC_ALL, "");
+ setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = args.argc();
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index da27c8c..76f6584 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -14,6 +14,7 @@
#include "cmParseCoberturaCoverage.h"
#include "cmParseGTMCoverage.h"
#include "cmParseCacheCoverage.h"
+#include "cmParseJacocoCoverage.h"
#include "cmCTest.h"
#include "cmake.h"
#include "cmMakefile.h"
@@ -415,6 +416,13 @@ int cmCTestCoverageHandler::ProcessHandler()
return error;
}
+ file_count += this->HandleJacocoCoverage(&cont);
+ error = cont.Error;
+ if ( file_count < 0 )
+ {
+ return error;
+ }
+
std::set<std::string> uncovered = this->FindUncoveredFiles(&cont);
if ( file_count == 0 )
@@ -872,6 +880,38 @@ struct cmCTestCoverageHandlerLocale
};
//----------------------------------------------------------------------
+int cmCTestCoverageHandler::HandleJacocoCoverage(
+ cmCTestCoverageHandlerContainer* cont)
+{
+ cmParseJacocoCoverage cov =
+ cmParseJacocoCoverage(*cont, this->CTest);
+ cmsys::Glob g;
+ std::vector<std::string> files;
+ g.SetRecurse(true);
+
+ std::string SourceDir
+ = this->CTest->GetCTestConfiguration("SourceDirectory");
+ std::string coverageFile = SourceDir+ "/*jacoco.xml";
+
+ g.FindFiles(coverageFile);
+ files=g.GetFiles();
+ if (files.size() > 0)
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found Jacoco Files, Performing Coverage" << std::endl);
+ cov.LoadCoverageData(files);
+ }
+ else
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Cannot find Jacoco coverage files: " << coverageFile
+ << std::endl);
+ }
+ return static_cast<int>(cont->TotalCoverage.size());
+}
+
+
+//----------------------------------------------------------------------
int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestCoverageHandlerContainer* cont)
{
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 38a3353..d0f274c 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -81,7 +81,10 @@ private:
//! Handle coverage for mumps
int HandleMumpsCoverage(cmCTestCoverageHandlerContainer* cont);
- //! Handle coverage using Bullseye
+ //! Handle coverage for Jacoco
+ int HandleJacocoCoverage(cmCTestCoverageHandlerContainer* cont);
+
+//! Handle coverage using Bullseye
int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont,
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
new file mode 100644
index 0000000..4723dd3
--- /dev/null
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -0,0 +1,167 @@
+#include "cmStandardIncludes.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "cmSystemTools.h"
+#include "cmXMLParser.h"
+#include "cmParseJacocoCoverage.h"
+#include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/FStream.hxx>
+
+
+class cmParseJacocoCoverage::XMLParser: public cmXMLParser
+{
+ public:
+ XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
+ : CTest(ctest), Coverage(cont)
+ {
+ this->PackageName = "";
+ this->ModuleName = "";
+ this->FileName = "";
+ this->CurFileName = "";
+ this->FilePaths.push_back(this->Coverage.SourceDir);
+ }
+
+ virtual ~XMLParser()
+ {
+ }
+
+ protected:
+
+ virtual void EndElement(const std::string&)
+ {
+ }
+
+ virtual void StartElement(const std::string& name,
+ const char** atts)
+ {
+ if(name == "package")
+ {
+ this->PackageName = atts[1];
+ std::string FilePath = this->Coverage.SourceDir +
+ "/" + this->ModuleName + "/src/main/java/" +
+ this->PackageName;
+ this->FilePaths.push_back(FilePath);
+ }
+ else if(name == "sourcefile")
+ {
+ this->FileName = atts[1];
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: "
+ << this->FileName << std::endl);
+ for(size_t i=0;i < FilePaths.size();i++)
+ {
+ std::string finalpath = FilePaths[i] + "/" + this->FileName;
+ if(cmSystemTools::FileExists(finalpath.c_str()))
+ {
+ this->CurFileName = finalpath;
+ break;
+ }
+ }
+ cmsys::ifstream fin(this->CurFileName.c_str());
+ if(this->CurFileName == "" || !fin )
+ {
+ this->CurFileName = this->Coverage.BinaryDir + "/" +
+ this->FileName;
+ fin.open(this->CurFileName.c_str());
+ if (!fin)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Jacoco Coverage: Error opening " << this->CurFileName
+ << std::endl);
+ this->Coverage.Error++;
+ }
+ }
+ std::string line;
+ FileLinesType& curFileLines =
+ this->Coverage.TotalCoverage[this->CurFileName];
+ curFileLines.push_back(-1);
+ while(cmSystemTools::GetLineFromStream(fin, line))
+ {
+ curFileLines.push_back(-1);
+ }
+ }
+ else if(name == "report")
+ {
+ this->ModuleName=atts[1];
+ }
+ else if(name == "line")
+ {
+ int tagCount = 0;
+ int nr = -1;
+ int ci = -1;
+ while(true)
+ {
+ if(strcmp(atts[tagCount],"ci") == 0)
+ {
+ ci = atoi(atts[tagCount+1]);
+ }
+ else if (strcmp(atts[tagCount],"nr") == 0)
+ {
+ nr = atoi(atts[tagCount+1]);
+ }
+ if (ci > -1 && nr > 0)
+ {
+ FileLinesType& curFileLines=
+ this->Coverage.TotalCoverage[this->CurFileName];
+ if(curFileLines.size() > 0)
+ {
+ curFileLines[nr-1] = ci;
+ }
+ break;
+ }
+ ++tagCount;
+ }
+ }
+ }
+
+ private:
+ std::string PackageName;
+ std::string FileName;
+ std::string ModuleName;
+ std::string CurFileName;
+ std::vector<std::string> FilePaths;
+ typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+ FileLinesType;
+ cmCTest* CTest;
+ cmCTestCoverageHandlerContainer& Coverage;
+};
+
+cmParseJacocoCoverage::cmParseJacocoCoverage(
+ cmCTestCoverageHandlerContainer& cont,
+ cmCTest* ctest)
+ :Coverage(cont), CTest(ctest)
+ {
+ }
+
+bool cmParseJacocoCoverage::LoadCoverageData(
+ const std::vector<std::string> files)
+{
+ // load all the jacoco.xml files in the source directory
+ cmsys::Directory dir;
+ size_t i;
+ std::string path;
+ size_t numf = files.size();
+ for (i = 0; i < numf; i++)
+ {
+ path = files[i];
+
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Reading XML File " << path << std::endl);
+ if(cmSystemTools::GetFilenameLastExtension(path) == ".xml")
+ {
+ if(!this->ReadJacocoXML(path.c_str()))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool cmParseJacocoCoverage::ReadJacocoXML(const char* file)
+{
+ cmParseJacocoCoverage::XMLParser
+ parser(this->CTest, this->Coverage);
+ parser.ParseFile(file);
+ return true;
+}
diff --git a/Source/CTest/cmParseJacocoCoverage.h b/Source/CTest/cmParseJacocoCoverage.h
new file mode 100644
index 0000000..dad05a3
--- /dev/null
+++ b/Source/CTest/cmParseJacocoCoverage.h
@@ -0,0 +1,59 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 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 cmParseJacocoCoverage_h
+#define cmParseJacocoCoverage_h
+
+#include "cmStandardIncludes.h"
+#include "cmCTestCoverageHandler.h"
+
+
+/** \class cmParseJacocoCoverage
+ * \brief Parse JaCoCO coverage information
+ *
+ * This class is used to parse coverage information for
+ * java using the JaCoCo tool:
+ *
+ * http://www.eclemma.org/jacoco/trunk/index.html
+ */
+class cmParseJacocoCoverage
+{
+public:
+ cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont,
+ cmCTest* ctest);
+ bool LoadCoverageData(const std::vector<std::string> files);
+
+ std::string PackageName;
+ std::string FileName;
+ std::string ModuleName;
+ std::string CurFileName;
+private:
+ // implement virtual from parent
+ // remove files with no coverage
+ void RemoveUnCoveredFiles();
+ // Read a single mcov file
+ bool ReadJacocoXML(const char* f);
+ // split a string based on ,
+ bool SplitString(std::vector<std::string>& args,
+ std::string const& line);
+ bool FindJavaFile(std::string const& routine,
+ std::string& filepath);
+ void InitializeJavaFile(std::string& file);
+ bool LoadSource(std::string d);
+
+ class XMLParser;
+ std::map<std::string, std::string> RoutineToDirectory;
+ cmCTestCoverageHandlerContainer& Coverage;
+ cmCTest* CTest;
+};
+
+#endif
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index a9d4d98..54f2151 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -83,7 +83,7 @@ void CMakeMessageHandler(const char* message, const char* title, bool&,
int main(int argc, char const* const* argv)
{
- setlocale(LC_ALL, "");
+ setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index babf1c4..5515f35 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -15,7 +15,8 @@
cmDefinitions::Def cmDefinitions::NoDef;
//----------------------------------------------------------------------------
-cmDefinitions::cmDefinitions(cmDefinitions* parent): Up(parent)
+cmDefinitions::cmDefinitions(cmDefinitions* parent)
+ : Up(parent)
{
}
@@ -28,18 +29,17 @@ void cmDefinitions::Reset(cmDefinitions* parent)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
-cmDefinitions::GetInternal(const std::string& key)
+cmDefinitions::GetInternal(const std::string& key) const
{
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
{
return i->second;
}
- else if(cmDefinitions* up = this->Up)
+ if(cmDefinitions* up = this->Up)
{
- // Query the parent scope and store the result locally.
- Def def = up->GetInternal(key);
- return this->Map.insert(MapType::value_type(key, def)).first->second;
+ // Query the parent scope.
+ return up->GetInternal(key);
}
return this->NoDef;
}
@@ -51,16 +51,7 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
if(this->Up || def.Exists)
{
// In lower scopes we store keys, defined or not.
- MapType::iterator i = this->Map.find(key);
- if(i == this->Map.end())
- {
- i = this->Map.insert(MapType::value_type(key, def)).first;
- }
- else
- {
- i->second = def;
- }
- return i->second;
+ return (this->Map[key] = def);
}
else
{
@@ -71,13 +62,26 @@ cmDefinitions::SetInternal(const std::string& key, Def const& def)
}
//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key)
+const char* cmDefinitions::Get(const std::string& key) const
{
Def const& def = this->GetInternal(key);
return def.Exists? def.c_str() : 0;
}
//----------------------------------------------------------------------------
+void cmDefinitions::Pull(const std::string& key)
+{
+ if (this->Up)
+ {
+ Def const& def = this->Up->GetInternal(key);
+ if (def.Exists)
+ {
+ this->SetInternal(key, def);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
const char* cmDefinitions::Set(const std::string& key, const char* value)
{
Def const& def = this->SetInternal(key, Def(value));
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index d615fb0..5209a8b 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -13,6 +13,9 @@
#define cmDefinitions_h
#include "cmStandardIncludes.h"
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+#include "cmsys/hash_map.hxx"
+#endif
/** \class cmDefinitions
* \brief Store a scope of variable definitions for CMake language.
@@ -33,9 +36,11 @@ public:
/** Returns the parent scope, if any. */
cmDefinitions* GetParent() const { return this->Up; }
- /** Get the value associated with a key; null if none.
- Store the result locally if it came from a parent. */
- const char* Get(const std::string& key);
+ /** Get the value associated with a key; null if none. */
+ const char* Get(const std::string& key) const;
+
+ /** Pull a variable from the parent. */
+ void Pull(const std::string& key);
/** Set (or unset if null) a value associated with a key. */
const char* Set(const std::string& key, const char* value);
@@ -69,11 +74,15 @@ private:
cmDefinitions* Up;
// Local definitions, set or unset.
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ typedef cmsys::hash_map<std::string, Def> MapType;
+#else
typedef std::map<std::string, Def> MapType;
+#endif
MapType Map;
// Internal query and update methods.
- Def const& GetInternal(const std::string& key);
+ Def const& GetInternal(const std::string& key) const;
Def const& SetInternal(const std::string& key, Def const& def);
// Implementation of Closure() method.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 630957f..412c998 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4422,7 +4422,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
if(cmDefinitions* up = cur.GetParent())
{
// First localize the definition in the current scope.
- cur.Get(var);
+ cur.Pull(var);
// Now update the definition in the parent scope.
up->Set(var, varDef);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 9f9f6bb..d8540cb 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -163,7 +163,7 @@ static void cmakemainProgressCallback(const char *m, float prog,
int main(int ac, char const* const* av)
{
- setlocale(LC_ALL, "");
+ setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(ac, av);
ac = args.argc();
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 167e348..ff32de9 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -116,7 +116,7 @@ static const char * cmDocumentationOptions[][2] =
// this is a test driver program for cmCTest.
int main (int argc, char const* const* argv)
{
- setlocale(LC_ALL, "");
+ setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 3e69f93..273a541 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2202,6 +2202,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*"
ENVIRONMENT COVFILE=)
+
+ # Adding a test case for JaCoCo Coverage
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/DartConfiguration.tcl.in"
+ "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl")
+ file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage"
+ DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage")
+ add_test(NAME CTestJacocoCoverage
+ COMMAND cmake -E chdir
+ ${CMake_BINARY_DIR}/Testing/JacocoCoverage
+ $<TARGET_FILE:ctest> -T Coverage --debug)
+ set_tests_properties(CTestJacocoCoverage PROPERTIES
+ PASS_REGULAR_EXPRESSION
+ "Process file.*CoverageTest.java.*Total LOC:.*17.*Percentage Coverage: 76.47*"
+ ENVIRONMENT COVFILE=)
+
function(add_config_tests cfg)
set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
diff --git a/Tests/JacocoCoverage/Coverage/src/main/java/org/cmake/CoverageTest.java b/Tests/JacocoCoverage/Coverage/src/main/java/org/cmake/CoverageTest.java
new file mode 100644
index 0000000..4fb43c6
--- /dev/null
+++ b/Tests/JacocoCoverage/Coverage/src/main/java/org/cmake/CoverageTest.java
@@ -0,0 +1,52 @@
+package org.cmake.Coverage;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.List;
+import java.awt.*;
+
+public class CoverageTest {
+
+ public static String VarOne = "test1";
+ public static String VarTwo = "test2";
+ private Integer IntOne = 4;
+
+ public static Boolean equalsVarOne(String inString) {
+
+ if(VarOne.equals(inString)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public static boolean equalsVarTwo(String inString){
+
+ if(VarTwo.equals(inString)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private Integer timesIntOne(Integer inVal){
+
+ return inVal * IntOne;
+ }
+
+ public static boolean whileLoop(Integer StopInt){
+
+ Integer i = 0;
+ while(i < StopInt){
+ i=i+1;
+ }
+ if (i.equals(5)){
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+}
diff --git a/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml b/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml
new file mode 100644
index 0000000..49c3e87
--- /dev/null
+++ b/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd"><report name="Coverage"><sessioninfo id="vagrant-ubuntu-precise-32-f1c264e9" start="1402427058670" dump="1402427059269"/><package name="org/cmake"><class name="org/cmake/Coverage/CoverageTest"><method name="&lt;init&gt;" desc="()V" line="8"><counter type="INSTRUCTION" missed="7" covered="0"/><counter type="LINE" missed="2" covered="0"/><counter type="COMPLEXITY" missed="1" covered="0"/><counter type="METHOD" missed="1" covered="0"/></method><method name="equalsVarOne" desc="(Ljava/lang/String;)Ljava/lang/Boolean;" line="16"><counter type="INSTRUCTION" missed="3" covered="7"/><counter type="BRANCH" missed="1" covered="1"/><counter type="LINE" missed="1" covered="2"/><counter type="COMPLEXITY" missed="1" covered="1"/><counter type="METHOD" missed="0" covered="1"/></method><method name="equalsVarTwo" desc="(Ljava/lang/String;)Z" line="26"><counter type="INSTRUCTION" missed="0" covered="8"/><counter type="BRANCH" missed="0" covered="2"/><counter type="LINE" missed="0" covered="3"/><counter type="COMPLEXITY" missed="0" covered="2"/><counter type="METHOD" missed="0" covered="1"/></method><method name="timesIntOne" desc="(Ljava/lang/Integer;)Ljava/lang/Integer;" line="36"><counter type="INSTRUCTION" missed="8" covered="0"/><counter type="LINE" missed="1" covered="0"/><counter type="COMPLEXITY" missed="1" covered="0"/><counter type="METHOD" missed="1" covered="0"/></method><method name="whileLoop" desc="(Ljava/lang/Integer;)Z" line="41"><counter type="INSTRUCTION" missed="0" covered="24"/><counter type="BRANCH" missed="0" covered="4"/><counter type="LINE" missed="0" covered="6"/><counter type="COMPLEXITY" missed="0" covered="3"/><counter type="METHOD" missed="0" covered="1"/></method><method name="&lt;clinit&gt;" desc="()V" line="10"><counter type="INSTRUCTION" missed="0" covered="5"/><counter type="LINE" missed="0" covered="2"/><counter type="COMPLEXITY" missed="0" covered="1"/><counter type="METHOD" missed="0" covered="1"/></method><counter type="INSTRUCTION" missed="18" covered="44"/><counter type="BRANCH" missed="1" covered="7"/><counter type="LINE" missed="4" covered="13"/><counter type="COMPLEXITY" missed="3" covered="7"/><counter type="METHOD" missed="2" covered="4"/><counter type="CLASS" missed="0" covered="1"/></class><sourcefile name="CoverageTest.java"><line nr="8" mi="2" ci="0" mb="0" cb="0"/><line nr="10" mi="0" ci="2" mb="0" cb="0"/><line nr="11" mi="0" ci="3" mb="0" cb="0"/><line nr="12" mi="5" ci="0" mb="0" cb="0"/><line nr="16" mi="0" ci="4" mb="1" cb="1"/><line nr="17" mi="0" ci="3" mb="0" cb="0"/><line nr="20" mi="3" ci="0" mb="0" cb="0"/><line nr="26" mi="0" ci="4" mb="0" cb="2"/><line nr="27" mi="0" ci="2" mb="0" cb="0"/><line nr="30" mi="0" ci="2" mb="0" cb="0"/><line nr="36" mi="8" ci="0" mb="0" cb="0"/><line nr="41" mi="0" ci="3" mb="0" cb="0"/><line nr="42" mi="0" ci="5" mb="0" cb="2"/><line nr="43" mi="0" ci="7" mb="0" cb="0"/><line nr="45" mi="0" ci="5" mb="0" cb="2"/><line nr="46" mi="0" ci="2" mb="0" cb="0"/><line nr="49" mi="0" ci="2" mb="0" cb="0"/><counter type="INSTRUCTION" missed="18" covered="44"/><counter type="BRANCH" missed="1" covered="7"/><counter type="LINE" missed="4" covered="13"/><counter type="COMPLEXITY" missed="3" covered="7"/><counter type="METHOD" missed="2" covered="4"/><counter type="CLASS" missed="0" covered="1"/></sourcefile><counter type="INSTRUCTION" missed="18" covered="44"/><counter type="BRANCH" missed="1" covered="7"/><counter type="LINE" missed="4" covered="13"/><counter type="COMPLEXITY" missed="3" covered="7"/><counter type="METHOD" missed="2" covered="4"/><counter type="CLASS" missed="0" covered="1"/></package><counter type="INSTRUCTION" missed="18" covered="44"/><counter type="BRANCH" missed="1" covered="7"/><counter type="LINE" missed="4" covered="13"/><counter type="COMPLEXITY" missed="3" covered="7"/><counter type="METHOD" missed="2" covered="4"/><counter type="CLASS" missed="0" covered="1"/></report>
diff --git a/Tests/JacocoCoverage/DartConfiguration.tcl.in b/Tests/JacocoCoverage/DartConfiguration.tcl.in
new file mode 100644
index 0000000..cc10e9c
--- /dev/null
+++ b/Tests/JacocoCoverage/DartConfiguration.tcl.in
@@ -0,0 +1,8 @@
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: ${CMake_BINARY_DIR}/Testing/JacocoCoverage
+BuildDirectory: ${CMake_BINARY_DIR}/Testing/JacocoCoverage