Notes |
|
(0035175)
|
Brad King
|
2014-02-24 12:44
|
|
This is as documented:
http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:if [^]
The 4.96 value is a non-zero number so it is true under the if(<constant>) case. The 4.96.0 value is not a number so it falls through to the if(<variable>) case and no variable named "4.96.0" is defined.
One can do
set(version 4.96.0)
if(version)
...
endif()
or use the VERSION_LESS, VERSION_EQUAL, or VERSION_GREATER comparison operator.
|
|
|
(0035176)
|
Aurélien Gâteau
|
2014-02-24 13:44
|
|
Actually the issue is a bit more complex. It appeared in a macro. The following code:
"""
cmake_minimum_required(VERSION 2.8)
macro(foo dep)
if (${ARGV1})
message("ARGV1(${ARGV1}) is TRUE")
else()
message("ARGV1(${ARGV1}) is FALSE")
endif()
endmacro()
foo(me)
foo(me 4.96)
foo(me 4.96.0)
"""
Yields:
"""
ARGV1() is FALSE
ARGV1(4.96) is TRUE
ARGV1(4.96.0) is FALSE
"""
I expected the last line to be TRUE. |
|
|
(0035177)
|
Brad King
|
2014-02-24 14:00
|
|
Macro replacements are performed before the code is executed so my explanation stands as it does for literal code.
You can do:
macro(foo dep)
set(argv1 "${ARGV1}")
if (argv1)
message("ARGV1(${argv1}) is TRUE")
else()
message("ARGV1(${argv1}) is FALSE")
endif()
endmacro()
Please post on the mailing list:
http://www.cmake.org/cgi-bin/mailman/listinfo/cmake [^]
if you need further help. That has a much broader audience. |
|
|
(0036913)
|
Robert Maynard
|
2014-10-06 10:32
|
|
Closing resolved issues that have not been updated in more than 4 months. |
|