ENH: Add development version support in CMake

This commit is contained in:
Andy Cedilnik 2004-10-22 15:44:54 -04:00
parent f4a04a96eb
commit fc70a2bb2a
9 changed files with 147 additions and 15 deletions

View File

@ -22,6 +22,7 @@ cmGlobalUnixMakefileGenerator.cxx
cmLocalGenerator.cxx
cmLocalUnixMakefileGenerator.cxx
cmVariableWatch.cxx
cmVersion.cxx
cmake.h
cmakewizard.h
cmMakeDepend.h
@ -40,6 +41,7 @@ cmGlobalUnixMakefileGenerator.h
cmLocalGenerator.h
cmLocalUnixMakefileGenerator.h
cmVariableWatch.h
cmVersion.h
)
@ -118,6 +120,8 @@ ENDIF(CMAKE_BUILD_MFC_DIALOG)
ADD_EXECUTABLE(cmake cmakemain.cxx)
ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
ADD_CUSTOM_TARGET(foo ALL /bin/sh ${CMAKE_CURRENT_BINARY_DIR}/../foo.sh)
SET(CMTEST_SRCS ctest.cxx cmCTest.cxx
CTest/cmCTestBuildHandler.cxx
CTest/cmCTestConfigureHandler.cxx

View File

@ -22,6 +22,7 @@
#include "cmMakefile.h"
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmVersion.h"
//#include <cmsys/RegularExpression.hxx>
#include <cmsys/Process.h>
@ -122,7 +123,8 @@ int cmCTestUpdateHandler::UpdateDirectory(cmCTest *ctest_inst)
}
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<Update mode=\"Client\" Generator=\"ctest-" << CMake_VERSION_FULL << "\">\n"
<< "<Update mode=\"Client\" Generator=\"ctest-"
<< cmVersion::GetCMakeVersion() << "\">\n"
<< "\t<Site>" << m_CTest->GetDartConfiguration("Site") << "</Site>\n"
<< "\t<BuildName>" << m_CTest->GetDartConfiguration("BuildName")
<< "</BuildName>\n"

View File

@ -33,6 +33,7 @@
#include "cmCTestConfigureHandler.h"
#include "cmCTestSubmit.h"
#include "cmVersion.h"
#include <cmsys/RegularExpression.hxx>
#include <cmsys/Process.h>
@ -1064,7 +1065,8 @@ void cmCTest::StartXML(std::ostream& ostr)
<< "<Site BuildName=\"" << m_DartConfiguration["BuildName"]
<< "\" BuildStamp=\"" << m_CurrentTag << "-"
<< this->GetTestModelString() << "\" Name=\""
<< m_DartConfiguration["Site"] << "\" Generator=\"ctest-" << CMake_VERSION_FULL
<< m_DartConfiguration["Site"] << "\" Generator=\"ctest"
<< cmVersion::GetCMakeVersion()
<< "\">" << std::endl;
}
@ -1080,7 +1082,8 @@ int cmCTest::GenerateDartNotesOutput(std::ostream& os, const cmCTest::tm_VectorO
<< "<?xml-stylesheet type=\"text/xsl\" href=\"Dart/Source/Server/XSL/Build.xsl <file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
<< "<Site BuildName=\"" << m_DartConfiguration["BuildName"] << "\" BuildStamp=\""
<< m_CurrentTag << "-" << this->GetTestModelString() << "\" Name=\""
<< m_DartConfiguration["Site"] << "\" Generator=\"ctest-" << CMake_VERSION_FULL
<< m_DartConfiguration["Site"] << "\" Generator=\"ctest"
<< cmVersion::GetCMakeVersion()
<< "\">\n"
<< "<Notes>" << std::endl;

View File

@ -17,6 +17,7 @@
#include "cmDocumentation.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationStandardOptions[] =
@ -127,7 +128,6 @@ cmDocumentation::cmDocumentation()
//----------------------------------------------------------------------------
bool cmDocumentation::PrintCopyright(std::ostream& os)
{
os << "CMake version " CMake_VERSION_FULL "\n";
for(const cmDocumentationEntry* op = cmDocumentationCopyright;
op->brief; ++op)
{
@ -150,7 +150,7 @@ bool cmDocumentation::PrintCopyright(std::ostream& os)
//----------------------------------------------------------------------------
bool cmDocumentation::PrintVersion(std::ostream& os)
{
os << this->GetNameString() << " version " CMake_VERSION_FULL "\n";
os << this->GetNameString() << " version " << cmVersion::GetCMakeVersion() << "\n";
return true;
}
@ -172,6 +172,11 @@ void cmDocumentation::ClearSections()
//----------------------------------------------------------------------------
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
{
if ( ht != cmDocumentation::HTML &&
ht != cmDocumentation::Man )
{
this->PrintVersion(os);
}
switch (ht)
{
case cmDocumentation::Usage: return this->PrintDocumentationUsage(os);
@ -181,7 +186,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
case cmDocumentation::HTML: return this->PrintDocumentationHTML(os);
case cmDocumentation::Man: return this->PrintDocumentationMan(os);
case cmDocumentation::Copyright: return this->PrintCopyright(os);
case cmDocumentation::Version: return this->PrintVersion(os);
case cmDocumentation::Version: return true;
default: return false;
}
}
@ -875,7 +880,8 @@ bool cmDocumentation::PrintDocumentationMan(std::ostream& os)
this->CreateManDocumentation();
os << ".TH " << this->GetNameString() << " 1 \""
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
<< "\" \"" << this->GetNameString() << " " CMake_VERSION_FULL "\"\n";
<< "\" \"" << this->GetNameString() << " " << cmVersion::GetCMakeVersion()
<< "\"\n";
this->Print(ManForm, os);
return true;
}

View File

@ -20,6 +20,7 @@
#include "cmake.h"
#include "cmDocumentation.h"
#include "cmVersion.h"
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationName[] =
@ -69,8 +70,10 @@ int DumpHTML(const char* outname)
cmDocumentation doc;
std::vector<cmDocumentationEntry> commands;
cmi.GetCommandDocumentation(commands);
doc.AddSection("Documentation for Commands of CMake " CMake_VERSION_FULL,
&commands[0]);
cmOStringStream str;
str << "Documentation for Commands of CMake "
<< cmVersion::GetCMakeVersion();
doc.AddSection(str.str().c_str(), &commands[0]);
doc.Print(cmDocumentation::HTMLForm, fout);
return 0;

74
Source/cmVersion.cxx Normal file
View File

@ -0,0 +1,74 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVersion.h"
std::string cmVersion::GetReleaseVersion()
{
#if CMake_VERSION_MINOR & 1
std::string cver = "Date: 2004-10-22 19:44:54 +0000";
std::string res = "";
std::string::size_type cc, len = cver.size();
bool aftercol = false;
int cnt = 0;
for ( cc = 0; cc < len; cc ++ )
{
if ( aftercol )
{
char ch = cver[cc];
switch ( ch )
{
case ' ':
case ':':
case '/':
case '-':
case '$':
break;
default:
res += ch;
cnt ++;
}
if ( cnt >= 8 )
{
return res;
}
}
else
{
if ( cver[cc] == ':' )
{
aftercol = true;
}
}
}
return res;
#else
# if CMake_VERSION_PATCH == 0
return "beta";
# else
return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH);
# endif
#endif
}
std::string cmVersion::GetCMakeVersion()
{
cmOStringStream str;
str << CMake_VERSION_MAJOR << "." << CMake_VERSION_MINOR
<< "-"
<< cmVersion::GetReleaseVersion();
return str.str();
}

40
Source/cmVersion.h Normal file
View File

@ -0,0 +1,40 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVersion_h
#define cmVersion_h
#include "cmStandardIncludes.h"
/** \class cmVersion
* \brief Helper class for providing CMake and CTest version information.
*
* Finds all version related information.
*/
class cmVersion
{
public:
/**
* Return major and minor version numbers for cmake.
*/
static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
static std::string GetReleaseVersion();
static std::string GetCMakeVersion();
};
#endif

View File

@ -22,6 +22,7 @@
#include "cmCommands.h"
#include "cmCommand.h"
#include "cmVariableWatch.h"
#include "cmVersion.h"
// only build kdevelop generator on non-windows platforms
// when not bootstrapping cmake
@ -175,8 +176,7 @@ void cmake::Usage(const char* program)
{
cmOStringStream errorStream;
errorStream << "cmake version " << cmMakefile::GetMajorVersion()
<< "." << cmMakefile::GetMinorVersion() << "\n";
errorStream << "cmake version " << cmVersion::GetCMakeVersion() << "\n";
errorStream << "Usage: " << program << " [srcdir] [options]\n"
<< "Where cmake is run from the directory where you want the object files written. If srcdir is not specified, the current directory is used for both source and object files.\n";
errorStream << "Options are:\n";
@ -653,8 +653,7 @@ void CMakeCommandUsage(const char* program)
cmOStringStream errorStream;
errorStream
<< "cmake version " << cmMakefile::GetMajorVersion()
<< "." << cmMakefile::GetMinorVersion() << "\n";
<< "cmake version " << cmVersion::GetCMakeVersion() << "\n";
errorStream
<< "Usage: " << program << " -E [command] [arguments ...]\n"
@ -1382,8 +1381,8 @@ int cmake::DumpDocumentationToFile(std::ostream& f)
const char *terse;
const char *full;
char tmp[1024];
sprintf(tmp,"Version %d.%d", cmake::GetMajorVersion(),
cmake::GetMinorVersion());
sprintf(tmp,"Version %d.%d (%s)", cmake::GetMajorVersion(),
cmake::GetMinorVersion(), cmVersion::GetReleaseVersion().c_str());
f << "<html>\n";
f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n";
f << "<ul>\n";

View File

@ -52,6 +52,7 @@ CMAKE_CXX_SOURCES="\
cmCacheManager \
cmListFileCache \
cmVariableWatch \
cmVersion \
cmSourceGroup"
CMAKE_C_SOURCES="\