[CMake] CMAKE_INSTALL_PREFIX: Win32 quoting problem

Michael Jackson mike.jackson at bluequartz.net
Wed Mar 25 08:55:49 EDT 2009


I don't have my windows machine fired up at the moment so I can not  
check this out but that _should_ have really worked.

Seems like maybe a bug with cpack?

And yes, quoting _can_ be this difficult.. at least IMO.


---
Mike Jackson                 www.bluequartz.net

On Mar 25, 2009, at 8:37 AM, Stephen Collyer wrote:

> Thanks. However that doesn't help things either. I have hardcoded the
> "C:\Program Files" string, though in place of the ENV variables, and  
> it's
> happy with that. This looks like it may be a cmake bug. I'm sure cmake
> quoting isn't supposed to be this hard.
>
> 2009/3/25 Michael Jackson <mike.jackson at bluequartz.net>
> Yep, sorry about that, too early over here, Try this.
>
>
> SET(CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}/${PROJECT_NAME}_$ 
> {VERSION}")
>
>   IF (WIN32)
>      STRING(REPLACE "\\" "\\\\" CMAKE_INSTALL_PREFIX $ 
> {CMAKE_INSTALL_PREFIX} )
>      STRING(REPLACE "/" "\\\\" CMAKE_INSTALL_PREFIX $ 
> {CMAKE_INSTALL_PREFIX} )
>    endif()
>
> That should replace all '\' with '\\' and '/' with '\\' so the path  
> becomes correct, I use something like this in my own cmake files to  
> encode paths into a configured header file.
>
> _________________________________________________________
>
> Mike Jackson                  mike.jackson at bluequartz.net
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
>
>
>
>
> On Mar 25, 2009, at 8:12 AM, Stephen Collyer wrote:
>
> Unfortunately neither of those work for me. (This is with Cmake  
> 2.6.1, BTW)
>
> e.g. with the /, I get:
>
> CMake Error: Invalid escape sequence \P
> Syntax error in cmake code at
> C:/Program Files/CMake 2.6/share/cmake-2.6/Modules/CPack.cmake:788:
> syntax error, unexpected cal_ERROR, expecting $end (4), when parsing  
> string "C:\Program Files/MDP_1.0.0"
>
> This looks like it's complaining about the interpolated "C:\Program"  
> part of the text, rather than my later backslashes.
>
> 2009/3/25 Mike Jackson <mike.jackson at bluequartz.net>
> SET(CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}\\${PROJECT_NAME}_$ 
> {VERSION}")
>
> or
>
> SET(CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}/${PROJECT_NAME}_$ 
> {VERSION}")
>
> Strings in CMake are like C Strings. '\' is special so it needs to be
> escaped with another '\'. You can also use the normal '/' and cmake
> _should_ do the right thing with it.
>
> Mike
>
> On Wed, Mar 25, 2009 at 7:10 AM, Stephen Collyer
> <scollyer at netspinner.co.uk> wrote:
> > I've got the following code in my top-level CMakeLists.txt file:
> >
> > IF (WIN32)
> >     SET(CMAKE_INSTALL_PREFIX
> > "$ENV{ProgramFiles}\${PROJECT_NAME}_${VERSION}")
> >     SET(CPACK_GENERATOR "ZIP")
> > ELSE(WIN32)
> >     SET(CMAKE_INSTALL_PREFIX "/opt/${PROJECT_NAME}_${VERSION}")
> >     SET(CPACK_GENERATOR "RPM")
> > ENDIF(WIN32)
> >
> > Regardless of how I try to construct the Win32  
> CMAKE_INSTALL_PREFIX, I get
> > some kind of quoting-related
> > problem e,g:
> >
> > CMake Error: Invalid escape sequence \P
> > Syntax error in cmake code at
> > C:/Program Files/CMake 2.6/share/cmake-2.6/Modules/CPack.cmake:788:
> > syntax error, unexpected cal_ERROR, expecting $end (4), when  
> parsing string
> > "C:\Program Files\MDP_1.0.0"
> >
> > with variants, depending on presence/absence of quotes and number  
> of \
> >
> > Can someone put me out of my misery and tell me what I need to do  
> to get
> > this right ?
> >
> > Steve Collyer
> >
> > _______________________________________________
> > 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
> >
>
>
>



More information about the CMake mailing list