[CMake] Backlashes on Windows: bug or feature?

Pau Garcia i Quiles pgquiles at elpauer.org
Thu Mar 5 18:20:44 EST 2009


I forgot to say if I edit the variable value in the Qt GUI and replace
"C://Intersystems//Cache" with "C:\\Intersystems\\Cache", the
backslashed value is stored in the cache and shdir.c contains the
expected output (with '\\').

But if I call CMake form the command line:
 cmake -DCALLIN_PATH:PATH="C:\\\\Intersystems\\\\Cache"

I get forward slashes in the CMake cache and in the generated shdir.c.
Interestingly, on Windows only 2 forward slashes make it into the
CMake cache but on Linux all 4 of them are in the CMake cache.

On Thu, Mar 5, 2009 at 11:14 PM, Pau Garcia i Quiles
<pgquiles at elpauer.org> wrote:
> Hello,
>
> I started writing a bug report but I'm not really sure if this is a
> bug or a feature.
>
> On Win32, if you assign a path value to a variable in a
> CMakeLists.txt, then open the CMakeLists.txt with the CMakeQtGui, it
> will convert all the backslashes to forward-slashes, although this
> might not be desired.
>
> For example, I have this in my CMakeLists.txt:
>
> IF( NOT DEFINED CALLIN_PATH )
>  IF(WIN32)
>    SET( CALLIN_PATH "C:\\\\Intersystems\\\\Cache" CACHE PATH "Path to
> the Mgr directory in ISC Cache" FORCE )
>  ELSE(WIN32)
>    SET(CALLIN_PATH "/opt/cachesys" CACHE PATH "Path to the Mgr
> directory in ISC Cache" FORCE )
>  ENDIF(WIN32)
> ENDIF( NOT DEFINED CALLIN_PATH )
>
> On Win32, the Qt GUI shows CALLIN_PATH as "C://Intersystems//Cache"
> and clicking "Configure" will store it in the CMake cache as
> "C://Intersystems//Cache".
>
> This is undesired behavior because you may want to use the value of
> that variable to generate, for instance, a .c or .cpp file. In my
> case, I have this shdir.c.cmake:
>
> char shdir[256]="@CACHEMGRDIR@";
>
> Doing:
>
> CONFIGURE_FILE( 3rdparty/src/isccache/shdir.c.cmake
> ${LHDFAMILY_BINARY_DIR}/shdir.c )
>
> Creates this shdir.c:
>
> char shdir[256]="C://Intersystems//Cache";
>
> Which made my application behave oddly because the path is not valid
> but the file still compiles.
>
> This behavior (replacing "\\" with "//") is consistent with what CMake
> does when invoked from the command line. On the other hand, the (now
> deprecated) CMakeSetup would not replace "\\" with "//", i. e.
> CMakeSetup would show CALLIN_PATH as "C:\\Intersystems\\Cache" and
> would generate this shdir.c, which is exactly what I want:
>
> char shdir[256]="C:\\Intersystems\\Cache";
>
> In the end, I'm not sure if this is a bug in CMake and the Qt GUI, or
> it was a bug in CMakeSetup, but the CMakeSetup behavior is what a
> Win32 user would expect.
>
> (it's easy to work around the backslash-to-forwardslash substitution
> with STRING, but it's not ideal and it's unexpected)
>
> --
> Pau Garcia i Quiles
> http://www.elpauer.org
> (Due to my workload, I may need 10 days to answer)
>



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the CMake mailing list