[CMake] Backlashes on Windows: bug or feature?
Pau Garcia i Quiles
pgquiles at elpauer.org
Thu Mar 5 17:14:41 EST 2009
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)
More information about the CMake
mailing list