On 10/06/2011 08:51 PM, Robert Dailey wrote: > Well there you go, deleting the cache & reconfiguring fixed it. That was > weird. > > Thanks for the help!
FYI, the attached CMakeLists.txt examines a variable's value in 5 cases: NONEXIST: No value in current scope or in cache. SCOPEONLY: Value in current scope, no value in cache. CACHEONLY: No value in current scope, value in cache. BOTHEQUAL: The same value in current scope and cache. BOTHUNEQUAL: Different values in current scope and cache. The findings are: NOT STREQUAL, NONEXIST[SCOPE]=, NONEXIST[CACHE]= STREQUAL, SCOPEONLY[SCOPE]=xyz, SCOPEONLY[CACHE]= STREQUAL, CACHEONLY[SCOPE]=xyz, CACHEONLY[CACHE]=xyz STREQUAL, BOTHEQUAL[SCOPE]=xyz, BOTHEQUAL[CACHE]=xyz STREQUAL, BOTHUNEQUAL[SCOPE]=xyz, BOTHUNEQUAL[CACHE]=abc AFAICS, this is exactly what one would expect, i.e. STREQUAL refers to the variable's value in the current scope and uses the cached value as fallback - in CACHEONLY - if the variable has no current-scope value. This is with CMake 2.8.6; do you gain different results? Regards, Michael > On Thu, Oct 6, 2011 at 1:50 PM, Robert Dailey <rcdai...@gmail.com> wrote: > >> Ok interesting, it is working for me too. I guess my reproducible use case >> was invalid. >> >> (BTW, I'm running through cmake-gui on Windows 7 x64 using CMake version >> 2.8.5) >> >> My use case was a simplified version of the real code. FUBARTEST is >> actually a cache variable defined by the root CMakeLists.txt file. In my >> real test case, my STREQUAL statement is failing to execute the conditional >> code when I do this: >> >> if( NEMO_TARGET STREQUAL "NSPR" ) >> >> However if I do this, it works: >> >> if( "${NEMO_TARGET}" STREQUAL "NSPR" ) >> >> I don't know why both would behave differently. Just to rule out the cache >> variable being the issue, I tried this (I attempted to make the SET() call >> override the originally defined cache variable. I did not actually remove >> the variable from cache): >> >> set( NEMO_TARGET "NSPR" ) >> if( NEMO_TARGET STREQUAL "NSPR" ) >> >> Of course, this statement did not result in the enclosed message() being >> executed. >> >> I have tried creating a small test case to reproduce this issue but so far >> I have been unsuccessful. I'll try clearing my cache to rule out any issues >> there. In the meantime if you have any suspicions or have run into this >> before, please give me some ideas on how to solve this :) >> >> Thanks. >> >> --------- >> Robert Dailey >> >> >> >> On Thu, Oct 6, 2011 at 1:31 PM, Eric Noulard <eric.noul...@gmail.com>wrote: >> >>> 2011/10/6 Robert Dailey <rcdai...@gmail.com>: >>>> According to the CMake documentation, the `STREQUAL` comparison is >>> allowed >>>> to take either a VARIABLE or a STRING as either parameter. So, in this >>>> example below, the message does NOT print, which is broken: >>>> set( FUBARTEST "OK" ) >>>> if( FUBARTEST STREQUAL "OK" ) >>>> message( "It Worked" ) >>>> endif() >>>> Any reason why this isn't working as documented? >>> >>> Don't know but it works just fine for on Linux + CMake 2.8.6 >>> which cmake version are you using? >>> >>> Could you try running >>> cmake --trace --debug-output -P fubartest.cmake >>> >>> and tell us waht's printed out? >>> >>> >>> >>> -- >>> Erk >>> Membre de l'April - « promouvoir et défendre le logiciel libre » - >>> http://www.april.org
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(STREQUAL NONE) SET(CMAKE_VERBOSE_MAKEFILE ON) UNSET(NONEXIST) UNSET(NONEXIST CACHE) IF(NONEXIST STREQUAL "xyz") MESSAGE("STREQUAL, NONEXIST[SCOPE]=${NONEXIST}, NONEXIST[CACHE]=$CACHE{NONEXIST}") ELSE() MESSAGE("NOT STREQUAL, NONEXIST[SCOPE]=${NONEXIST}, NONEXIST[CACHE]=$CACHE{NONEXIST}") ENDIF() SET(SCOPEONLY "xyz") UNSET(SCOPEONLY CACHE) IF(SCOPEONLY STREQUAL "xyz") MESSAGE("STREQUAL, SCOPEONLY[SCOPE]=${SCOPEONLY}, SCOPEONLY[CACHE]=$CACHE{SCOPEONLY}") ELSE() MESSAGE("NOT STREQUAL, SCOPEONLY[SCOPE]=${SCOPEONLY}, SCOPEONLY[CACHE]=$CACHE{SCOPEONLY}") ENDIF() SET(CACHEONLY "xyz" CACHE STRING "" FORCE) SET(CACHEONLY "pqr") # In order to check if UNSET(CACHEONLY) really... UNSET(CACHEONLY) # ...unsets CACHEONLY only in the current scope. IF(CACHEONLY STREQUAL "xyz") MESSAGE("STREQUAL, CACHEONLY[SCOPE]=${CACHEONLY}, CACHEONLY[CACHE]=$CACHE{CACHEONLY}") ELSE() MESSAGE("NOT STREQUAL, CACHEONLY[SCOPE]=${CACHEONLY}, CACHEONLY[CACHE]=$CACHE{CACHEONLY}") ENDIF() SET(BOTHEQUAL "xyz" CACHE STRING "" FORCE) SET(BOTHEQUAL "xyz") # Actually unnecessary. IF(BOTHEQUAL STREQUAL "xyz") MESSAGE("STREQUAL, BOTHEQUAL[SCOPE]=${BOTHEQUAL}, BOTHEQUAL[CACHE]=$CACHE{BOTHEQUAL}") ELSE() MESSAGE("NOT STREQUAL, BOTHEQUAL[SCOPE]=${BOTHEQUAL}, BOTHEQUAL[CACHE]=$CACHE{BOTHEQUAL}") ENDIF() SET(BOTHUNEQUAL "abc" CACHE STRING "" FORCE) SET(BOTHUNEQUAL "xyz") IF(BOTHUNEQUAL STREQUAL "xyz") MESSAGE("STREQUAL, BOTHUNEQUAL[SCOPE]=${BOTHUNEQUAL}, BOTHUNEQUAL[CACHE]=$CACHE{BOTHUNEQUAL}") ELSE() MESSAGE("NOT STREQUAL, BOTHUNEQUAL[SCOPE]=${BOTHUNEQUAL}, BOTHUNEQUAL[CACHE]=$CACHE{BOTHUNEQUAL}") ENDIF()
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake