Commit 5bbae885 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

Add ccommand for executing commands on the system, so by using...

Add ccommand for executing commands on the system, so by using ADD_CUSTOM_COMMAND, you can make rules to do some system commands during build. Currently supported commands are copy and remove. Others will follow.
parent c8924864
......@@ -97,6 +97,7 @@ ADD_EXECUTABLE(cmake cmakemain)
ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx)
ADD_EXECUTABLE(ccommand ccommand.cxx cmSystemTools.cxx cmMakefile.cxx)
CONFIGURE_FILE(
${CMake_SOURCE_DIR}/Source/cmaketest.h.in
......@@ -149,5 +150,6 @@ INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
INSTALL_TARGETS(/bin cmake)
INSTALL_TARGETS(/bin ctest)
INSTALL_TARGETS(/bin ccommand)
INSTALL_TARGETS(/bin cmaketest)
......@@ -32,6 +32,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name ctest
End Project Dependency
Begin Project Dependency
Project_Dep_Name ccommand
End Project Dependency
}}}
###############################################################################
......@@ -81,6 +84,21 @@ Package=<4>
###############################################################################
Project: "ccommand"=.\ccommand.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name CMakeLib
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
......
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmMakefile.h"
#include "cmSystemTools.h"
void CMakeCommandUsage(const char* program)
{
std::strstream errorStream;
errorStream << "cmake version " << cmMakefile::GetMajorVersion()
<< "." << cmMakefile::GetMinorVersion() << "\n";
errorStream << "Usage: " << program << " [command] [arguments ...]\n"
<< " Available commands: \n"
<< " copy file1 file2 - copy first file to the second one\n"
<< " remove file1 file2 ... - remove the file(s)\n";
errorStream << std::ends;
cmSystemTools::Error(errorStream.str());
}
int main(int ac, char** av)
{
std::vector<std::string> args;
for(int i =0; i < ac; ++i)
{
args.push_back(av[i]);
}
if ( args.size() > 1 )
{
if ( args[1] == "copy" && args.size() == 4 )
{
cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str());
return 0;
}
if ( args[1] == "remove" && args.size() > 2 )
{
for ( int cc = 2; cc < args.size(); cc ++ )
{
cmSystemTools::RemoveFile(args[cc].c_str());
}
return 0;
}
}
::CMakeCommandUsage(args[0].c_str());
return 1;
}
# Microsoft Developer Studio Project File - Name="ccommand" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=ccommand - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ccommand.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ccommand.mak" CFG="ccommand - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ccommand - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "ccommand - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "ccommand - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"ccommand.pdb" /machine:I386 /out:"ccommand.exe"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "ccommand - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "ccommand___Win32_Debug"
# PROP BASE Intermediate_Dir "ccommand___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "ccommand___Win32_Debug"
# PROP Intermediate_Dir "ccommand___Win32_Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"ccommand.pdb" /debug /machine:I386 /out:"ccommand.exe" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "ccommand - Win32 Release"
# Name "ccommand - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\ccommand.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\ccommand.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
......@@ -252,6 +252,23 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
cmSystemTools::EscapeSpaces(cMakeSelf.c_str()).c_str(),
"Path to CMake executable.",
cmCacheManager::INTERNAL);
// Find ccommand
std::string cCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
"/ccommand" + cmSystemTools::GetFilenameExtension(cMakeSelf);
if( !cmSystemTools::FileExists(cMakeSelf.c_str()))
{
cmSystemTools::Error("CMAKE can not find the command line program "
"ccommand. Attempted path: ", cMakeSelf.c_str());
return;
}
// Save the value in the cache
cmCacheManager::GetInstance()->AddCacheEntry
("CCOMMAND_COMMAND",
cmSystemTools::EscapeSpaces(cCommand.c_str()).c_str(),
"Path to CMakeCommand executable.",
cmCacheManager::INTERNAL);
// do CMAKE_ROOT, look for the environment variable first
std::string cMakeRoot;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment