2003-07-08 01:47:17 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2007-06-07 21:51:17 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
2003-07-08 01:47:17 +04:00
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef cmFileCommand_h
|
|
|
|
#define cmFileCommand_h
|
|
|
|
|
|
|
|
#include "cmCommand.h"
|
|
|
|
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
struct cmFileInstaller;
|
|
|
|
|
2003-07-08 01:47:17 +04:00
|
|
|
/** \class cmFileCommand
|
|
|
|
* \brief Command for manipulation of files
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class cmFileCommand : public cmCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* This is a virtual constructor for the command.
|
|
|
|
*/
|
2007-06-07 21:51:17 +04:00
|
|
|
virtual cmCommand* Clone()
|
2003-07-08 01:47:17 +04:00
|
|
|
{
|
|
|
|
return new cmFileCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when the command is first encountered in
|
|
|
|
* the CMakeLists.txt file.
|
|
|
|
*/
|
|
|
|
virtual bool InitialPass(std::vector<std::string> const& args);
|
|
|
|
|
2004-01-27 00:05:58 +03:00
|
|
|
/**
|
|
|
|
* This determines if the command is invoked when in script mode.
|
|
|
|
*/
|
|
|
|
virtual bool IsScriptable() { return true; }
|
|
|
|
|
2003-07-08 01:47:17 +04:00
|
|
|
/**
|
|
|
|
* The name of the command as specified in CMakeList.txt.
|
|
|
|
*/
|
|
|
|
virtual const char* GetName() { return "FILE";}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Succinct documentation.
|
|
|
|
*/
|
2007-06-07 21:51:17 +04:00
|
|
|
virtual const char* GetTerseDocumentation()
|
2003-07-08 01:47:17 +04:00
|
|
|
{
|
|
|
|
return "File manipulation command.";
|
|
|
|
}
|
2007-06-07 21:51:17 +04:00
|
|
|
|
2003-07-08 01:47:17 +04:00
|
|
|
/**
|
|
|
|
* More documentation.
|
|
|
|
*/
|
|
|
|
virtual const char* GetFullDocumentation()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
" FILE(WRITE filename \"message to write\"... )\n"
|
|
|
|
" FILE(APPEND filename \"message to write\"... )\n"
|
2007-03-01 23:53:09 +03:00
|
|
|
" FILE(READ filename variable [LIMIT numBytes])\n"
|
2007-04-26 01:22:07 +04:00
|
|
|
" FILE(STRINGS filename variable [LIMIT_COUNT num]\n"
|
|
|
|
" [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n"
|
|
|
|
" [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n"
|
2007-05-26 00:46:50 +04:00
|
|
|
" [NEWLINE_CONSUME] [REGEX regex]\n"
|
|
|
|
" [NO_HEX_CONVERSION])\n"
|
2006-03-22 00:03:19 +03:00
|
|
|
" FILE(GLOB variable [RELATIVE path] [globbing expressions]...)\n"
|
2006-05-10 23:46:45 +04:00
|
|
|
" FILE(GLOB_RECURSE variable [RELATIVE path] \n"
|
|
|
|
" [globbing expressions]...)\n"
|
2007-06-13 22:36:26 +04:00
|
|
|
" FILE(REMOVE [file1 ...])\n"
|
|
|
|
" FILE(REMOVE_RECURSE [file1 ...])\n"
|
|
|
|
" FILE(MAKE_DIRECTORY [directory1 directory2 ...])\n"
|
2005-10-17 17:10:20 +04:00
|
|
|
" FILE(RELATIVE_PATH variable directory file)\n"
|
2006-04-05 15:46:32 +04:00
|
|
|
" FILE(TO_CMAKE_PATH path result)\n"
|
|
|
|
" FILE(TO_NATIVE_PATH path result)\n"
|
2003-07-08 01:47:17 +04:00
|
|
|
"WRITE will write a message into a file called 'filename'. It "
|
|
|
|
"overwrites the file if it already exists, and creates the file "
|
2005-11-16 19:25:47 +03:00
|
|
|
"if it does not exist.\n"
|
2003-07-08 01:47:17 +04:00
|
|
|
"APPEND will write a message into a file same as WRITE, except "
|
2003-07-09 00:33:29 +04:00
|
|
|
"it will append it to the end of the file\n"
|
2004-04-18 22:41:46 +04:00
|
|
|
"NOTE: When using FILE WRITE and FILE APPEND, the produced file "
|
|
|
|
"cannot be used as an input to CMake (CONFIGURE_FILE, source file ...) "
|
2005-11-16 19:25:47 +03:00
|
|
|
"because it will lead to an infinite loop. Use CONFIGURE_FILE if you "
|
2004-04-18 22:41:46 +04:00
|
|
|
"want to generate input files to CMake.\n"
|
2003-07-08 22:18:17 +04:00
|
|
|
"READ will read the content of a file and store it into the "
|
2003-07-09 00:33:29 +04:00
|
|
|
"variable.\n"
|
2007-05-26 00:46:50 +04:00
|
|
|
"STRINGS will parse a list of ASCII strings from a file and "
|
2007-05-25 23:22:22 +04:00
|
|
|
"store it in a variable. Binary data in the file are ignored. Carriage "
|
|
|
|
"return (CR) characters are ignored. It works also for Intel Hex and "
|
2007-05-26 00:46:50 +04:00
|
|
|
"Motorola S-record files, which are automatically converted to binary "
|
|
|
|
"format when reading them. Disable this using NO_HEX_CONVERSION.\n "
|
2007-04-26 01:22:07 +04:00
|
|
|
"LIMIT_COUNT sets the maximum number of strings to return. "
|
|
|
|
"LIMIT_INPUT sets the maximum number of bytes to read from "
|
|
|
|
"the input file. "
|
|
|
|
"LIMIT_OUTPUT sets the maximum number of bytes to store in the "
|
|
|
|
"output variable. "
|
|
|
|
"LENGTH_MINIMUM sets the minimum length of a string to return. "
|
|
|
|
"Shorter strings are ignored. "
|
|
|
|
"LENGTH_MAXIMUM sets the maximum length of a string to return. Longer "
|
|
|
|
"strings are split into strings no longer than the maximum length. "
|
|
|
|
"NEWLINE_CONSUME allows newlines to be included in strings instead "
|
|
|
|
"of terminating them. "
|
|
|
|
"REGEX specifies a regular expression that a string must match to be "
|
|
|
|
"returned. "
|
|
|
|
"Typical usage \n"
|
|
|
|
" FILE(STRINGS myfile.txt myfile)\n"
|
|
|
|
"stores a list in the variable \"myfile\" in which each item is "
|
|
|
|
"a line from the input file.\n"
|
2003-07-09 00:33:29 +04:00
|
|
|
"GLOB will generate a list of all files that match the globbing "
|
|
|
|
"expressions and store it into the variable. Globbing expressions "
|
2006-03-22 00:03:19 +03:00
|
|
|
"are similar to regular expressions, but much simpler. If RELATIVE "
|
|
|
|
"flag is specified for an expression, the results will be returned "
|
|
|
|
"as a relative path to the given path.\n"
|
2005-11-16 19:25:47 +03:00
|
|
|
"Examples of globbing expressions include:\n"
|
2003-07-09 00:33:29 +04:00
|
|
|
" *.cxx - match all files with extension cxx\n"
|
2005-11-16 19:25:47 +03:00
|
|
|
" *.vt? - match all files with extension vta,...,vtz\n"
|
2003-07-09 00:33:29 +04:00
|
|
|
" f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n"
|
2003-07-14 17:15:13 +04:00
|
|
|
"GLOB_RECURSE will generate similar list as the regular GLOB, except "
|
|
|
|
"it will traverse all the subdirectories of the matched directory and "
|
|
|
|
"match the files.\n"
|
2005-11-16 19:25:47 +03:00
|
|
|
"Examples of recursive globbing include:\n"
|
|
|
|
" /dir/*.py - match all python files in /dir and subdirectories\n"
|
2007-06-13 22:36:26 +04:00
|
|
|
"MAKE_DIRECTORY will create the given directories, also if their parent "
|
|
|
|
"directories don't exist yet\n"
|
|
|
|
"REMOVE will remove the given files, also in subdirectories\n"
|
|
|
|
"REMOVE_RECURSE will remove the given files and directories, also "
|
|
|
|
"non-empty directories\n"
|
2006-03-10 21:54:57 +03:00
|
|
|
"RELATIVE_PATH will determine relative path from directory to the given"
|
2006-04-05 15:46:32 +04:00
|
|
|
" file.\n"
|
2007-02-20 23:09:09 +03:00
|
|
|
"TO_CMAKE_PATH will convert path into a cmake style path with unix /. "
|
2006-04-05 15:46:32 +04:00
|
|
|
" The input can be a single path or a system path like \"$ENV{PATH}\". "
|
|
|
|
" Note the double quotes around the ENV call TO_CMAKE_PATH only takes "
|
|
|
|
" one argument.\n"
|
|
|
|
"TO_NATIVE_PATH works just like TO_CMAKE_PATH, but will convert from "
|
|
|
|
" a cmake style path into the native path style \\ for windows and / "
|
|
|
|
"for UNIX.";
|
2003-07-09 00:33:29 +04:00
|
|
|
}
|
2007-06-07 21:51:17 +04:00
|
|
|
|
2003-07-08 01:47:17 +04:00
|
|
|
cmTypeMacro(cmFileCommand, cmCommand);
|
|
|
|
|
|
|
|
protected:
|
2006-03-09 22:30:35 +03:00
|
|
|
bool HandleRemove(std::vector<std::string> const& args, bool recurse);
|
2003-07-08 01:47:17 +04:00
|
|
|
bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
|
|
|
|
bool HandleReadCommand(std::vector<std::string> const& args);
|
2007-04-26 01:22:07 +04:00
|
|
|
bool HandleStringsCommand(std::vector<std::string> const& args);
|
2003-07-14 17:15:13 +04:00
|
|
|
bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
|
2003-07-09 00:33:29 +04:00
|
|
|
bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
|
2007-06-07 21:51:17 +04:00
|
|
|
|
2005-10-17 17:10:20 +04:00
|
|
|
bool HandleRelativePathCommand(std::vector<std::string> const& args);
|
2006-04-05 15:46:32 +04:00
|
|
|
bool HandleCMakePathCommand(std::vector<std::string> const& args,
|
|
|
|
bool nativePath);
|
2006-06-05 21:45:43 +04:00
|
|
|
void ComputeVersionedName(std::string& name, const char* version);
|
2007-06-07 21:51:17 +04:00
|
|
|
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
// FILE(INSTALL ...) related functions
|
|
|
|
bool HandleInstallCommand(std::vector<std::string> const& args);
|
|
|
|
bool ParseInstallArgs(std::vector<std::string> const& args,
|
|
|
|
cmFileInstaller& installer,
|
|
|
|
std::set<cmStdString>& components,
|
|
|
|
std::set<cmStdString>& configurations,
|
|
|
|
std::map<cmStdString, const char*>& properties,
|
|
|
|
int& itype,
|
|
|
|
std::string& destination,
|
|
|
|
std::string& rename,
|
|
|
|
std::vector<std::string>& files,
|
|
|
|
bool& optional
|
|
|
|
);
|
|
|
|
bool DoInstall(cmFileInstaller& installer,
|
|
|
|
const std::set<cmStdString>& components,
|
|
|
|
const std::set<cmStdString>& configurations,
|
|
|
|
std::map<cmStdString, const char*>& properties,
|
|
|
|
const int itype,
|
|
|
|
const std::string& rename,
|
|
|
|
const std::string& destination,
|
|
|
|
const std::vector<std::string>& files,
|
|
|
|
const bool optional
|
|
|
|
);
|
|
|
|
void GetTargetTypeFromString(const std::string& stype, int& itype) const;
|
2007-06-07 21:51:17 +04:00
|
|
|
bool HandleInstallDestination(cmFileInstaller& installer,
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
std::string& destination);
|
2007-06-07 21:51:17 +04:00
|
|
|
void HandleInstallPermissions(cmFileInstaller& installer,
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
mode_t& permissions_file,
|
|
|
|
mode_t& permissions_dir,
|
|
|
|
int itype,
|
|
|
|
bool use_given_permissions_file,
|
|
|
|
bool use_given_permissions_dir,
|
|
|
|
bool use_source_permissions) const;
|
2003-07-08 01:47:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|