[CMake] CPack: Installing applications in separate folders (NSIS)

David Cole david.cole at kitware.com
Mon May 21 13:27:35 EDT 2012


The install rule:

  install(FILES ${CMAKE_SOURCE_DIR}/somefolder/myfile.txt DESTINATION
$CustomDir)

doesn't make sense because $CustomDir is not known at CMake-time or even at
build-time or install-time. It's not known except to NSIS at packaging time.

make install runs before NSIS runs.

Sounds like you need a completely custom installer -- if you have installed
files that are not contained within the make install tree prefix, then you
cannot use the recursive "install all files from one root" technique in the
NSIS script that CPack uses by default.


We generally encourage and expect a "re-locatable" install tree to be used
with the CPack built NSIS installers. (i.e. -- no matter where the end-user
finally installs your package, they will be able to run the installed
programs just fine.) That's why the entire install tree is copied using the
following:

  this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL",
                            "File /r \"${INST_DIR}\\*.*\"");

That results in the following generated in project.nsi:

  File /r "${INST_DIR}\*.*"

which installs all files and directories recursively (from your make
install tree) to the installation directory chosen by the end user of your
installation program.


This stuff is not easy, especially when we can't see your code.

Cheers, (& good luck),
David


On Mon, May 21, 2012 at 12:39 PM, NoRulez <norulez at me.com> wrote:

> Hi,
>
> I know that the install commands collect files and copy them into the
> temporary cpack directory for the specified generator.
> How is it possible to install an application for example into those
> folders:
> C:\myapp
> C:\somefolder
>
> I defined 'Var CustomDir="C:\somefolder"' in the NSIS template.
>
> When I then use the following in the CMakeLists.txt:
> install(FILES ${CMAKE_SOURCE_DIR}/somefolder/myfile.txt DESTINATION
> $CustomDir)
>
> Then the files are installed in
> _CPACK_PACKAGES/NSIS/myproject_1.0.0.1/$CustomDir.
> The generated project.nsi has the content: $INSTDIR\$CustomDir\...
>
> How can I avoid that $INSTDIR\ is added, or did I need to use the install
> command in a different way?
>
> Thanks in advance
>
> Best Regards
> NoRulez
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120521/075c601a/attachment-0001.htm>


More information about the CMake mailing list