[CMake] Changing directory layout with Cpack ?

Eric Noulard eric.noulard at gmail.com
Fri Nov 30 07:15:48 EST 2007


2007/11/30, Stephen Collyer <scollyer at netspinner.co.uk>:
> and in a lower level directory, src/lib, I have:
>
> IF (WIN32)
>     INSTALL(TARGETS Comms Runnable
>             ARCHIVE DESTINATION .
>             LIBRARY DESTINATION install/win32
>             RUNTIME DESTINATION install/win32
>            )
> ELSE(WIN32)
>     INSTALL(TARGETS Comms Runnable
>             ARCHIVE DESTINATION install/linux/lib
>             LIBRARY DESTINATION install/linux/lib
>             RUNTIME DESTINATION install/linux/bin
>            )
> ENDIF(WIN32)

OK I see.
You are using install command with ABSOLUTE PATH
which does not seems to be your need (correct me if I'm wrong).
You may try this:


In a first step do not set CMAKE_INSTALL_PREFIX.
Later you may uncomment and update this
#SET(CMAKE_INSTALL_PREFIX "/some/prefix")

> and in a lower level directory, src/lib, I have:
>
IF (WIN32)
     INSTALL(TARGETS Comms Runnable
             ARCHIVE DESTINATION .
             LIBRARY DESTINATION .
             RUNTIME DESTINATION .
            )
 ELSE(WIN32)
     INSTALL(TARGETS Comms Runnable
             ARCHIVE DESTINATION lib
             LIBRARY DESTINATION lib
             RUNTIME DESTINATION bin
            )
ENDIF(WIN32)

Then after a compilation you may

On Linux (from within your linux  build tree)
make DESTDIR=/<your_absolute_prefix>/install/linux install
or
On Win32 (from within your Win32  build tree)
make DESTDIR=/<your_absolute_prefix>/install/win32 install

If you use VisualStudio on Win32 and you want to use the
INSTALL target to install your software from VisualStudio
you may add to your top level CMakeLists.txt

IF (WIN32)
    SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR})/install/win32")
ENDIF(WIN32)

Using this scheme you should be able to create a package with CPack
which does not contains your absolute path.
On Win32 if you use NSIS CPack generator you will be prompt
by the NSIS installer to chose the prefix before the installation.

On Linux you'll depending on the generator used (tgz, RPM, DEB)
you'll get a binary package containing:

For RPM and DEB
${CMAKE_INSTALL_PREFIX}/bin
${CMAKE_INSTALL_PREFIX}/lib

For TGZ
<some-prefix-using-system-name>/bin
<some-prefix-using-system-name>/lib

the default value of CMAKE_INSTALL_PREFIX on linux is "/usr/local"
but you may change this with a SET if you need that.

The short advice is DOT NOT USE absolute path in INSTALL commands
unless you __REALLY__ want to have absolute path INSTALL.

You may have more control of the content (including install prefix)
of the CPack generated archive depending on the generator:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators


-- 
Erk


More information about the CMake mailing list