[cmake-developers] [CMake 0011795]: Extending the STRING command with a FIND sub-command
Mantis Bug Tracker
mantis at public.kitware.com
Fri Feb 4 11:26:15 EST 2011
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=11795
======================================================================
Reported By: Tim Hütz
Assigned To:
======================================================================
Project: CMake
Issue ID: 11795
Category: CMake
Reproducibility: N/A
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2011-02-04 11:26 EST
Last Modified: 2011-02-04 11:26 EST
======================================================================
Summary: Extending the STRING command with a FIND sub-command
Description:
Recently I was searching for a CMake option to get the position of a single
character (first appearance) out of a string. As I found nothing which could
provide me an easy solution, I pulled the latest development version and added a
FIND sub-command to the STRING command.
The attached patch supports a forward search (finds the first occurrence of the
substring) and a reverse search (which finds the last occurrence of a
substring).
Here is a sample how the sub-commands works:
-----
project( "STRING FIND command" )
cmake_minimum_required(VERSION 2.8)
set( TESTSTRING "This is a test and here is another test." )
string( FIND ${TESTSTRING} "a" APOSITION )
string( FIND REVERSE ${TESTSTRING} "a" APOSITIONREV )
message( STATUS "Firt position of character 'a' (8) is ${APOSITION}" )
message( STATUS "Last position of character 'a' (27) is ${APOSITIONREV}" )
-----
I've already discussed this sub-command on the CMake mailing list
(http://www.cmake.org/pipermail/cmake/2011-February/042521.html).
Maybe, this would be a nice feature for one of the next CMake releases.
Best regards,
Tim
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-02-04 11:26 Tim Hütz New Issue
2011-02-04 11:26 Tim Hütz File Added:
0001-Added-a-new-STRING-sub-command-called-FIND.patch
======================================================================
More information about the cmake-developers
mailing list