Commit Graph

47 Commits

Author SHA1 Message Date
Gabor Bencze
6377efd154 cmCommand refactor: cmGetFilenameComponentCommand 2019-08-20 14:42:19 -04:00
Sebastian Holtermann
20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn
This replaces invocations of

- `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn`
- `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND`
- `cmSystemTools::IsOn` with `cmIsOn`
- `cmSystemTools::IsOff` with `cmIsOff`
2019-08-17 12:14:14 +02:00
Sebastian Holtermann
7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`:

- `cmIsSpace`
- `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`)
- `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`)
- `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to
  accept `cm::string_view`)
2019-08-05 11:25:30 +02:00
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Tushar Maheshwari
e50a36df48 cmGetFilenameComponentCommand: Add more components
LAST_EXT: gets last extension from filename with multiple periods
NAME_WLE: gets the name without the last extension
2019-01-24 22:38:52 +05:30
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Brad King
31f73eb12d get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics
The KWSys `SystemTools::SplitProgramFromArgs` implementation goes into
an infinite loop when the value is just " " (a space).  Since the
"program path with unquoted spaces plus command-line arguments"
operation it is trying to provide is poorly defined (string parsing
should not depend on filesystem content), just stop using it.

Instead consider the main two use cases the old approach tried to handle:

* The value is the name or absolute path of a program with no quoting
  or escaping, but also no command-line arguments.  In this case we
  can use the value as given with no parsing, and assume no arguments.

* The value is a command-line string containing the program name/path
  plus arguments.  In this case we now assume that the command line
  is properly quoted or escaped.

Fixes: #17262
2017-09-13 10:47:04 -04:00
Pavel Solodovnikov
8b6f439ef2 Access string npos without instance 2017-06-01 14:19:51 -04:00
Daniel Pfeifer
e81c323da9 Include necessary headers in commands 2016-10-26 09:02:44 +02:00
Stephen Kelly
2fe3e55d53 cmState: Move CacheEntryType enum to separate namespace
Port dependent code to the change.
2016-10-19 15:40:58 +02:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King
180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
James Johnston
e89ea3d190 get_filename_component: Teach new BASE_DIR parameter.
In the get_filename_component command, add a new BASE_DIR parameter to
use with the ABSOLUTE and REALPATH options.  This will be used when
finding an absolute path from a relative path.
2015-08-17 23:55:38 -04:00
James Johnston
d035e9687a get_filename_component: Fix bug where CACHE was ignored.
If PROGRAM_ARGS is provided to get_filename_component, fix bug where the
command failed to honor the CACHE argument.

Added test cases to RunCMake.get_filename_component that fail when the
bug is not fixed to prevent regressions.

Signed-off-by: James Johnston <johnstonj.public@codenest.com>
2015-08-06 17:53:34 +00:00
Stephen Kelly
55d80d0a85 cmMakefile: Rename GetCurrent{,Source}Directory.
Match the names used in cmake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly
f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly
fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly
5eb4d7590e Remove some unneeded c_str calls. 2014-11-23 11:09:54 +01:00
Nils Gladitz
cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02:00
Stephen Kelly
21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Brad King
7d1590e6f9 get_filename_component: Add DIRECTORY option (#14091)
The name "PATH" is not precise so add equivalent option "DIRECTORY".
Document the latter as preferred and the former as a legacy alias.
2013-04-16 09:37:37 -04:00
Kitware Robot
7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Brad King
5fbefd66dc Fix get_filename_component(... REALPATH) work dir
The commit "Fix get_filename_component ABSOLUTE mode" broke REALPATH
treatment of relative paths because it stopped storing the absolute path
in local variable 'filename'.  This commit fixes the call to GetRealPath
to use the proper local variable and adds a test.
2009-11-18 10:56:40 -05:00
Brad King
c63e3bd13c Fix get_filename_component() registry view
Some find-modules use get_filename_component() to expand registry
values.  We need to look in both the 32-bit and 64-bit registry views
when expanding values.  We prefer the one that the target application
would see.  See issue #8792.
2009-09-30 13:45:24 -04:00
Brad King
96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King
f10c258167 BUG: Fix get_filename_component ABSOLUTE mode
This teaches the command to recognize full windows paths when built on
UNIX.  CollapseFullPath knows when the input path is relative better
than FileIsFullPath because the latter is only meant for paths from the
host platform.
2009-07-23 08:10:02 -04:00
Brad King
ae873d4a89 ENH: Add get_filename_component(... REALPATH)
This patch from Philip Lowman creates a REALPATH mode in the
get_filename_component command.  It is like ABSOLUTE, but will also
resolve symlinks (which ABSOLUTE once did but was broken long ago).
See issue #8423.
2009-02-09 09:23:55 -05:00
Brad King
16fe328dfc BUG: Alternative fix to bug #8423
The patch used to fix this bug used SystemTools::GetRealPath which works
only for existing files.  It broke the case of using the command
get_filename_component for a non-existing file.  Also, it changed
long-standing behavior in a possibly incompatible way even for existing
files.  This reverts the original fix and instead updates the
documentation to be consistent with the behavior.
2009-02-06 08:33:52 -05:00
Bill Hoffman
33c296a44e BUG: fix for #8423 2009-01-29 11:39:03 -05:00
Ken Martin
0e69d38004 ENH: add return and break support to cmake, also change basic command invocation signature to be able to return extra informaiton via the cmExecutionStatus class 2008-01-23 10:28:26 -05:00
Ken Martin
71b993560b STYLE: fix line length 2006-05-10 15:56:00 -04:00
Ken Martin
3d96e52261 STYLE: some m_ to this-> cleanup 2006-03-15 11:02:08 -05:00
Brad King
0dbe4edcfc BUG: ABSOLUTE option should evaluate relative paths with respect to CMAKE_CURRENT_SOURCE_DIR. This addresses bug#2797. 2006-01-31 10:46:29 -05:00
Brad King
cde384411d Several fixes/improvements:
- Fixed CollapseFullPath to work on relative paths with base paths
    not in the current working directory.
  - INCLUDE command now supports relative paths (using above fix).
  - Added ABSOLUTE option to GET_FILENAME_COMPONENT command to
    unwind symlinks and relative paths.
  - Fixed libName_EXPORTS macro definition to be valid C identifier.
  - Added DEFINE_SYMBOL target propterty for customizing the export symbol.
  - Implemented LINK_FLAGS target propterty for libraries in VC6 and VC7.

Several of these fixes were contributed by Gareth Jones.
2003-02-07 14:04:16 -05:00
Bill Hoffman
f58d7df66a ENH: add checking for NOTFOUND 2003-01-31 13:50:42 -05:00
Sebastien Barre
937c87bd69 FIX: this command was not processing its arg to expand registery values 2003-01-23 10:35:14 -05:00
Brad King
6435f608b9 ERR: Fixed signed/unsigned warning. 2002-11-20 09:06:38 -05:00
Bill Hoffman
5a75e03037 allow flags to be in the CC and CXX environment variables 2002-11-19 18:17:17 -05:00
Brad King
1f6a3c67b1 ENH: Added reference to Copyright.txt. Removed old reference to ITK copyright. Changed program name to CMake instead of Insight in source file header. Also removed tabs. 2002-10-23 18:03:27 -04:00
Ken Martin
44a7cd55ff removed all source lists from the system and made them vectors. Also appended _CMAKE_PATH to the end of the automatic cache entries for executables and libraries. Odds of all these changes working are slim but cmake builds and passes all its tests. VTK40 starts building 2002-06-27 15:57:09 -04:00
Bill Hoffman
4651dbcfc6 ENH: expand variables in arguments before the commands get them 2002-03-05 18:41:24 -05:00
Will Schroeder
a6a43d5320 ENH:Updated copyright 2002-01-21 15:30:43 -05:00
Sebastien Barre
cc731ac548 The result of this utility command can now be optionally added to the cache 2001-10-23 17:49:13 -04:00
Bill Hoffman
baa28efd10 ENH: change InitialPass to take a const reference to the argument string, to avoid changes to the file cache 2001-09-20 15:08:30 -04:00
Bill Hoffman
9922155423 ENH: rename Invoke to InitialPass 2001-06-06 13:19:15 -04:00
Sebastien Barre
d8c34cfb81 Welcome to cmGetFilenameComponentCommand ("Get a specific component of a full filename") 2001-05-24 21:13:56 -04:00