# \`if(${VAR})\` and \`if("${VAR}")\` Show same in --trace output but actually different when CMP0054 being set.

**URL:** https://discourse.cmake.org/t/if-var-and-if-var-show-same-in-trace-output-but-actually-different-when-cmp0054-being-set/14079
**Category:** Development
**Tags:** os:linux
**Created:** [May 11, 2025, 6:11am UTC](https://discourse.cmake.org/t/if-var-and-if-var-show-same-in-trace-output-but-actually-different-when-cmp0054-being-set/14079 "2025-05-11T06:11:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![PEMessage](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pemessage/32/5560_2.png) [@PEMessage](https://discourse.cmake.org/u/PEMessage)
#### Post date: [May 11, 2025, 6:11am UTC](https://discourse.cmake.org/t/if-var-and-if-var-show-same-in-trace-output-but-actually-different-when-cmp0054-being-set/14079/1 "2025-05-11T06:11:27Z")

</div>

```auto
set(DO_NOTHING "-----------Set Policy CMP0054-------------")
if(POLICY CMP0054)
  cmake_policy(SET CMP0054 NEW)
endif()
set(MY_VAR "Hello")
set(Hello "Hello")
set(DO_NOTHING "-----------After Policy CMP0054-----------")

if(${MY_VAR})
    message(STATUS "If branch")
else()
    message(STATUS "Else branch") # <--- this
endif()

if("${MY_VAR}")
    message(STATUS "If branch") # <--- this
else()
    message(STATUS "Else branch") 
endif()

```

However, when examining the --trace output, I couldn’t see any difference between these two conditions. The output looks like this:

```auto
/main.cmake(40): set(DO_NOTHING -----------Set Policy CMP0054------------- )
/main.cmake(41): if(POLICY CMP0054 )
/main.cmake(42): cmake_policy(SET CMP0054 NEW )
/main.cmake(45): set(Hello Hello )
/main.cmake(46): set(DO_NOTHING -----------After Policy CMP0054----------- )
/main.cmake(49): if(${MY_VAR} )
/main.cmake(50): message(STATUS If branch )
-- If branch
/main.cmake(55): if(${MY_VAR} ) ####### Same as above
/main.cmake(57): else()
/main.cmake(58): message(STATUS Else branch )
-- Else branch

```

It’s work as expect?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 11, 2025, 4:21pm UTC](https://discourse.cmake.org/t/if-var-and-if-var-show-same-in-trace-output-but-actually-different-when-cmp0054-being-set/14079/2 "2025-05-11T16:21:59Z")

</div>

`--trace` only shows what CMake reads. You probably want `--trace-expand` which shows what the command receives (though predicate commands like `if` receive quoting information that isn’t shown). Neither behaviors differently for any `CMP0054` setting; that is inside of `if` and friends directly.
