[CMake] CMAKE_INSTALL_PREFIX: Win32 quoting problem

Mike Jackson mike.jackson at bluequartz.net
Wed Mar 25 07:47:17 EDT 2009


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