[CMake] Small, realistic Cpack example

Boudewijn Rempt boud at valdyas.org
Tue Sep 16 10:26:53 EDT 2008


On Tue, 16 Sep 2008, Stephen Collyer wrote:

> Does anyone know of/have a realistic cpack example
> showing packaging of 3rd party libraries, as well
> as those built from the install target ? If the
> "third party libraries" happened to include Qt,
> that'd be just fine ..

Ah... Well, we're struggling with that ourselves at the moment, and looking
in vain some good examples. Right now, we're using CPack for Linux and Windows,
and have stopped using CPack for OS X -- where I am right now writing a shell 
script to fill out the .app bundle and create a dmg out of it, following E. Wing's
advice last weekend.

For linux, we do things like:

IF(UNIX AND NOT APPLE)
    INSTALL(TARGETS HyvesDesktop
        DESTINATION bin
    )
    FOREACH(LIB QtCore QtXml QtTest QtWebKit QtGui QtNetwork QtScript)
        INSTALL(FILES
            "${QT_LIBRARY_DIR}/lib${LIB}.so.${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}"
            RENAME "lib${LIB}.so.${QT_VERSION_MAJOR}"
            DESTINATION bin
        )
    ENDFOREACH(LIB)
ENDIF(UNIX AND NOT APPLE)

combined with the shellscript TT advices in their deployment help page at http://doc.trolltech.com/4.4/deployment-x11.html.

For windows, I've got something like this: 

IF(WIN32)
    INSTALL(TARGETS HyvesDesktop
        DESTINATION bin
    )
    INSTALL(FILES
        "${QT_LIBRARY_DIR}/QtCore${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtXml${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtTest${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtWebKit${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtGui${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtNetwork${QT_VERSION_MAJOR}.dll"
        "${QT_LIBRARY_DIR}/QtScript${QT_VERSION_MAJOR}.dll"
        DESTINATION bin
    )
ENDIF(WIN32)

in our toplevel CMakeLists.txt file.

But then, this is probably not quite the right way of doing things. I've been looking at 
a lot of Qt+CMake floss projects lately, and almost all of them are using a mix of shell
scripts (sometimes even hand-coded makefiles) and CMake to achieve their packaging. 

If we could manage to get a good example of a CMakeLists.txt file that does the following:

 * package Qt for three platforms
 * package at least one third-party lib on each platform (like sparkle on OS X and exiv
   on Win/Linux or something like that)
 * create an nsis installer for windows, a .sh installer on linux and a nice bundle with
   a graphic on OS X
 * and can run QTestLib unittests on all platforms

And put it on the cmake wiki, countless coders will be way more productive :-)

Boudewijn



More information about the CMake mailing list