[CMake] CMake, Cpack and NSIS woes.

Bill Hoffman bill.hoffman at kitware.com
Tue Oct 6 20:17:39 EDT 2009


Andrew Maclean wrote:
> I am going to admit the possibility that I am doing something stupid.
> If so please tell me what I am doing wrong!
> 
> In a nutshell:
> Creating a windows package to install to a subdirectory does not work.
> Also I don't think CPACK_NSIS_DISPLAY_NAME works.
> 
> In order to illustrate the problem I have attached a minimal example.
> I am using a recent development version of CMake and NSIS 2.45 but
> this problem does occur with CMake 2.6.4
> 
> I want to install the program into a directory that is a subdirectory
> of C:\Program Files or /usr/local
> When using the attached minimal example, the directory is: C:/Program
> Files/VTK_Utilities/CMakeTest_1.1
> 
> It seems that that the install prefix is correct and the package
> install directory is correct. I can install and uninstall it
> correctly.
> 
> However when I create a package, C:\Program Files is appended to the
> path and it looks like this:
> C:\Program Files\C:/Program Files/VTK_Utilities/CMakeTest_1.1
> The "\" is then treated as an escape character upon install, so the
> path ends up as:
> C:\Program Files\CProgram FilesVTK_UtilitiesCMakeTest_1.1
> And the directory in the start menu becomes:
> CProgram FilesVTK_UtilitiesCMakeTest_1.1
> 
> So the problem is that setting CPACK_PACKAGE_INSTALL_DIRECTORY to be
> the CMAKE_INSTALL_PREFIX does not work for two reasons:
> 1) C:\Program Files\ seems to be automatically appended.
> 2) / are stripped out when logically I would expect them to be replaced by \.
> 
> When you run CMake, these are correct:
> CMakeTest_INSTALL_PREFIX: C:/Program Files/VTK_Utilities/CMakeTest_1.1
> CMAKE_INSTALL_PREFIX: C:/Program Files/VTK_Utilities/CMakeTest_1.1
> CPACK_PACKAGE_INSTALL_DIRECTORY: C:/Program Files/VTK_Utilities/CMakeTest_1.1
> 
> But notice that the packager changes CPACK_PACKAGE_INSTALL_DIRECTORY
> as evidenced by running the package.
> 
> Some other things I have tried:
> 1) Converting CMAKE_INSTALL_PREFIX to a native file path before
> assigning to CPACK_PACKAGE_INSTALL_DIRECTORY.
> 2)   string(REPLACE "/" "\\\\" NATIVE_CMAKE_INSTALL_PATH
> ${CMAKE_INSTALL_PREFIX})
>      set(CPACK_PACKAGE_INSTALL_DIRECTORY ${NATIVE_CMAKE_INSTALL_PATH}
> CACHE INTERNAL "")
> 	 We still get C:\Program Files appended and the following warnings:
> 	
> 	 4>CMake Warning (dev) at
> C:/Users/amaclean/Code/Miscellaneous/CMakeTest/build/CPackConfig.cmake:56
> (SET):
> 	 4>  Syntax error in cmake code at
> 	 4>    C:/Users/amaclean/Code/Miscellaneous/CMakeTest/build/CPackConfig.cmake:56
> 	 4>  when parsing string
> 	 4>    C:\Program Files\VTK_Utilities\CMakeTest_1.1
> 	 4>  Invalid escape sequence \P
> 	 4>  Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
> 	 4>  "cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
> 	 4>  command to set the policy and suppress this warning.
> 	 4>This warning is for project developers.  Use -Wno-dev to suppress it.
> 
>      i.e. \P is being treated as an escape character.
> 
> Thanks in advance for any help.
> 
You don't want to convert the path to native, CPack should take care of 
that.

By default CPack does not use the DESTDIR option during the installation 
phase.  Instead it sets the CMAKE_INSTALL_PREFIX to the full path of the 
temporary directory being used by CPack to stage the install package. 
This can be changed by setting CPACK_SET_DESTDIR to on. If the DESTDIR 
option is on, CPack will use the projects cache value for 
CPACK_INSTALL_PREFIX, and set DESTDIR to the temporary staging area. 
This allows absolute paths to be installed under the temporary 
directory. Relative paths are installed into DESTDIR/${project’s 
CMAKE_INSTALL_PREFIX} where DESTDIR is set to the temporary staging area.

I think you want CPACK_SET_DESTDIR, then make sure CMAKE_INSTALL_PREFIX 
is how you want it before you run cpack.

-Bill


More information about the CMake mailing list