[CMake] Small, complete CPack example?

Chris Wolf cw10025 at gmail.com
Thu Aug 5 17:06:28 EDT 2010


I'm looking all over for an end-to-end basic example of using CPack
to create a package with a single shared library target.  It can
even be with the TGZ generator.

I already checked these pages:

http://www.cmake.org/cmake/help/cpack-2-8-docs.html#see:FrequentlyAskedQuestions
http://www.itk.org/Wiki/CMake:CPackConfiguration
http://www.cmake.org/pipermail/cmake/2008-September/024003.html

...and nothing helps.  My CMake file just has a single shared 
library target and when I run "make package", the built 
library gets copied to the destination directory,
however the *.tgz file is empty but the generated
"install_manifest.txt" does have the path of the library in
the destination directory.  The generated shell archive
is also empty, so is the generated *.pkg and *.dmg.


The question is, how to make the build artifacts go into
the package?  A basic (even very basic) example would be
helpful.

Thanks,

Chris Wolf

P.S. Here is my current CMakeList.txt:

cmake_minimum_required(VERSION 2.8)
project(libusb)
set(NAME libusb)

include(CheckIncludeFiles)
include(CPack)

set(CPACK_PACKAGE_EXECUTABLES "libusb.dylib" "libusb-1.0.8")
#set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1)

CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)

if(APPLE)
  set(CMAKE_OSX_ARCHITECTURES "ppc7400;ppc64;x86_64;i386")
  set(TARGETSDK MacOSX10.5.sdk)
  set(CMAKE_OSX_SYSROOT /Developer/SDKs/${TARGETSDK})
  macro(ADD_FRAMEWORK fwname appname)
    find_library(FRAMEWORK_${fwname}
        NAMES ${fwname}
        PATHS ${CMAKE_OSX_SYSROOT}/System/Library
        PATH_SUFFIXES Frameworks
        NO_DEFAULT_PATH)
    if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
        MESSAGE(ERROR ": Framework ${fwname} not found")
    else()
        TARGET_LINK_LIBRARIES(${appname} ${FRAMEWORK_${fwname}})
        MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
    endif()
  endmacro(ADD_FRAMEWORK)
endif(APPLE)

include_directories(.)
set(libusb_srcs descriptor.c libusb.h core.c io.c libusbi.h sync.c)

if(APPLE)
    set(libusb_srcs ${libusb_srcs} os/darwin_usb.h os/darwin_usb.c)
endif(APPLE)

add_library(usb SHARED ${libusb_srcs})
install(TARGETS "usb" LIBRARY 
        DESTINATION /tmp/local/crap/lib 
        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                    GROUP_READ GROUP_EXECUTE
                    WORLD_READ WORLD_EXECUTE)

if(APPLE)
    add_framework(CoreFoundation usb)
    add_framework(IOKit usb)
endif(APPLE)




More information about the CMake mailing list