View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008996CMakeCMakepublic2009-05-11 09:352016-06-10 14:30
ReporterDenis Scherbakov 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionCMake 2.8.12Fixed in Version 
Summary0008996: Bug in MATH EXPR
DescriptionMATH(EXPR varOutput "-1 + 1")

gives an error:

CMake Error at CMakeLists.txt:1 (MATH):
  math cannot parse the expression: "-1 + 1": syntax error, unexpected
  exp_MINUS, expecting exp_OPENPARENT or exp_NUMBER (1)

I think "+1 + 1" also does not work.
Additional InformationCMake 2.6.4 on Linux
TagsNo tags attached.
Attached Files

 Relationships
has duplicate 0015181closedRobert Maynard math can't handle negative numbers. 
has duplicate 0015707closedRobert Maynard Error at: math(EXPR value "-1 + 1") 

  Notes
(0017440)
Bill Hoffman (manager)
2009-09-14 12:47

MATH(EXPR varOutput "0 -1 + 1")
message("${varOutput}")
(0018093)
Greg Sharp (reporter)
2009-10-17 10:35

No floating point?

MATH (EXPR OUTPUT_VAR "1.1 + 1.1")

CMake Error at /home/gcs6/projects/plastimatch/test.cmake:1 (MATH):
  math cannot parse the expression: "1.1 + 1.1": syntax error, unexpected
  exp_NUMBER, expecting $end (4)

2.6.3 on linux
(0029384)
Gili (reporter)
2012-05-01 22:12

Bill,

How are we supposed to increment a number?

  MATH (EXPR index "0 + ${index} + 1")

does not work because:

  math cannot parse the expression: "0 + -1 + 1"

Is there a workaround for this?
(0040249)
Nicholas Braden (reporter)
2016-01-16 19:16
edited on: 2016-01-16 19:28

This still affects CMake 3.4.1

@Gili This will always work whether the number is negative or positive:

math(EXPR index "0${index} + 1")

Hopefully they never add support for C-style octal numbers...

(0041556)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2009-05-11 09:35 Denis Scherbakov New Issue
2009-09-14 12:47 Bill Hoffman Note Added: 0017440
2009-09-14 12:48 Bill Hoffman Status new => assigned
2009-09-14 12:48 Bill Hoffman Assigned To => Bill Hoffman
2009-10-17 10:35 Greg Sharp Note Added: 0018093
2012-05-01 22:12 Gili Note Added: 0029384
2012-11-14 10:28 David Cole Target Version => CMake 2.8.11
2013-05-17 09:33 Robert Maynard Target Version CMake 2.8.11 => CMake 2.8.12
2014-09-30 13:52 David Cole Relationship added has duplicate 0015181
2015-08-22 05:42 David Cole Relationship added has duplicate 0015707
2016-01-16 19:16 Nicholas Braden Note Added: 0040249
2016-01-16 19:28 Nicholas Braden Note Edited: 0040249
2016-06-10 14:27 Kitware Robot Note Added: 0041556
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team