View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009590CMakeCMakepublic2009-09-24 02:242010-12-14 18:49
ReporterRolf Eike Beer 
Assigned ToDavid Cole 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0009590: IF(VARIABLE) doesn't work inside Makro
DescriptionI'll attach a CMakeLists.txt that is a stripped down version of one of our makros where it took me some hours only to find out that IF(VARIABLE) simply doesn't work inside the makro even if the variable is set.
Additional InformationExample output (running on Win32 using CMake 2.6.4)

-- BASE_DIR IS NOT! /usr/local/lib
-- BASE_DIR IS NOT! /usr/local/lib
-- BASE_DIR IS NOT! /usr/local/lib
-- BASE_DIR IS!
-- Lib_dirs: /usr/local/lib
-- TESTVAR IS!
-- TESTVAR IS!
-- TESTVAR IS NOT! /usr/local/lib
-- TESTVAR IS!
TagsNo tags attached.
Attached Filestxt file icon CMakeLists.txt [^] (1,467 bytes) 2009-09-24 02:25 [Show Content]

 Relationships
has duplicate 0012398closedDavid Cole "IF" infamous <variable/string> functionality fails to work with macro arguments 

  Notes
(0017743)
David Cole (manager)
2009-09-25 11:50

This behavior is intentional and the way that CMake works. Macro arguments are not CMake variables. They are substituted when dereferenced inside a macro, but the argument names used in the MACRO command are not CMake variables.

They can become CMake variables inside the macro if you do something like this at the very top of the macro:
  SET(BASE_DIR "${BASE_DIR}")
  SET(LIB_DIR "${LIB_DIR}")

Alternatively, you can change the MACRO to a FUNCTION. Function arguments *do* become CMake variables for the scope of the function...

From the cmake MACRO documentation:
http://www.cmake.org/cmake/help/cmake2.6docs.html#command:macro [^]

"Note that the parameters to a macro and values such as ARGN are not variables in the usual CMake sense. They are string replacements much like the c preprocessor would do with a macro. If you want true CMake variables you should look at the function command."
(0024084)
David Cole (manager)
2010-12-14 18:49

Closing bugs that have been resolved for more than 3 months without any further updates.

 Issue History
Date Modified Username Field Change
2009-09-24 02:24 Rolf Eike Beer New Issue
2009-09-24 02:25 Rolf Eike Beer File Added: CMakeLists.txt
2009-09-25 11:45 David Cole Status new => assigned
2009-09-25 11:45 David Cole Assigned To => David Cole
2009-09-25 11:50 David Cole Note Added: 0017743
2009-09-25 11:50 David Cole Status assigned => resolved
2009-09-25 11:50 David Cole Resolution open => won't fix
2010-12-14 18:49 David Cole Note Added: 0024084
2010-12-14 18:49 David Cole Status resolved => closed
2011-08-12 10:36 David Cole Relationship added has duplicate 0012398


Copyright © 2000 - 2018 MantisBT Team