[CMake] cpack error in visual studio

Eric Noulard eric.noulard at gmail.com
Thu May 2 13:50:41 EDT 2013


2013/5/2 Lloyd <lloydkl.tech at gmail.com>:
> Hi,
>
> I am trying CPack in visual studio. When I build "PACKAGE" it throws me an
> error like this:
>
>   CMake Error at C:/BuildDir1/src/cmake_install.cmake:38 (message):
>     ABSOLUTE path INSTALL DESTINATION forbidden (by caller):
>
> C:/BuildDir1/src/Debug/QtGuid4.dll;C:/BuildDir1/src/Debug/QtCored4.dll;C:/BuildDir1/src/Debug/reverse.dll
>   Call Stack (most recent call first):
>     C:/BuildDir1/cmake_install.cmake:33 (INCLUDE)
>
> I cannot interpret this error, can you please help me?

You are trying to install some files using an ABSOLUTE path DESTINATION.
99.999% of the time this is an error on the Windows platform.

Normally you should be installing files to a RELATIVE path DESTINATION.


> I have written packaging related code only in my main cmakelist file. Its
> content is given below
>
> #Packing related code
> SET (GENERATE_PACKAGE false CACHE BOOL "Do package generation?")

[...]
this part looks good.


> One of the install command present in my cmake file is also given below
>
> INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/Debug/Tutorial.exe DESTINATION
> ${CPACK_PACKAGE_INSTALL_DIRECTORY} CONFIGURATIONS Debug)

Here comes the culprit:

1) if "Tutorial.exe" is one of your target then you should write

 install(TARGET Tutorial DESTINATION ...)

2) you should never use an ASBOLUTE path DESTINATION

i.e. I guess that ${CPACK_PACKAGE_INSTALL_DIRECTORY} is an absolute path.
and usually you do not use this var for that purpose you do something like:

install(TARGET Tutorial DESTINATION bin CONFIGURATIONS Debug)

i.e. "bin" is the relative installation path.

set(CPACK_PACKAGE_INSTALL_DIRECTORY "Tutorial")

the var will be used by CPack in order to propose a folder name
for the package to be installed by some installer(e.g. NSIS).

The final (absolute) path is chosen by the user when running the installer
generated by CPack, NOT when CPack (nor CMake) is running.

I hope this helps.

--
Erk


More information about the CMake mailing list