[CMake] Can't add empty directories when using CPack

Daniel Nelson torham at connect2.com
Fri Nov 21 20:56:20 EST 2008


Is it possible to add empty directories with cpack?  If my 
CMakeLists.txt file is:

project(empty-dir)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/foo/bar/baz)
install(DIRECTORY ${CMAKE_BINARY_DIR}/foo DESTINATION cpack-test)
install(FILES CMakeLists.txt DESTINATION cpack-test)
include(CPack)

Then when I run cpack I get something like:

$ cpack -G TGZ --verbose
...
CPack Verbose: Installing: TGZ/empty-dir/cpack-test/foo
CPack Verbose: Installing: TGZ/empty-dir/cpack-test/foo/bar
CPack Verbose: Installing: TGZ/empty-dir/cpack-test/foo/bar/baz
CPack Verbose: Installing: TGZ/empty-dir/cpack-test/CMakeLists.txt
CPack: Compress package
CPack Verbose: Compress files to: TGZ/empty-dir.tar.gz
CPack: Finalize package
CPack Verbose: Copy final package: TGZ/empty-dir.tar.gz to empty-dir.tar.gz
CPack: Package empty-dir.tar.gz generated.

But then the archive doesn't actually contain the empty folders:

$ tar -tf empty-dir.tar.gz
empty-dir-0.1.1-Linux/cpack-test/CMakeLists.txt


More information about the CMake mailing list