On 01/11/2011 09:48 AM, Eric Noulard wrote: > 2011/1/11 Michael Hertling <mhertl...@online.de>: >> On 01/11/2011 12:55 AM, Tobias Ellinghaus wrote: >>> >>> Because some information (like latest git commit as version string) is no >>> longer available when using a source package. Of course I can put the >>> generated files into the source tree, but that's kind of against the idea of >>> out-of-source builds. >> >> You might use "cmake --build" in conjunction with a custom target: >> >> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) >> PROJECT(PKGSRC NONE) >> IF(EXISTS ${CMAKE_SOURCE_DIR}/manifest.txt) >> # In packaged source tree. >> FILE(COPY ${CMAKE_SOURCE_DIR}/manifest.txt >> DESTINATION ${CMAKE_BINARY_DIR}) >> ELSE() >> # In original source tree. >> FILE(WRITE ${CMAKE_BINARY_DIR}/manifest.txt "...\n") >> INCLUDE(CPack) >> ADD_CUSTOM_TARGET(pkgsrc >> COMMAND ${CMAKE_COMMAND} >> -E copy ${CMAKE_BINARY_DIR}/manifest.txt >> ${CMAKE_SOURCE_DIR}/manifest.txt >> COMMAND ${CMAKE_COMMAND} >> --build ${CMAKE_BINARY_DIR} >> --target package_source >> COMMAND ${CMAKE_COMMAND} >> -E remove ${CMAKE_SOURCE_DIR}/manifest.txt >> ) >> ENDIF() > > Nice solution. > >> The pkgsrc target prepares the source tree for packaging, builds the >> source package via "cmake --build" and cleans up. AFAICS, writing to >> the source tree is unavoidable in order to achieve your aim, > > in fact I think the "real" source for this is the fact the CPack lacks > the notion > of "EXTRA" distribution file which is available with autoconf, EXTRA_DIST var > http://www.gnu.org/software/hello/manual/automake/Basics-of-Distribution.html > or the dist-hook: > http://www.gnu.org/software/hello/manual/automake/The-dist-Hook.html#The-dist-Hook > > The fact is CPack doesn't know much about "source package" and > in fact it package source using the CPACK_INSTALLED_DIRECTORIES directory > list. > (look at the generated CPackSourceConfig.cmake) > > I think you can "emulate" the extra thing of autoconf. > If you want ot package "more" than the source tree with > "package_source" you can try > the following in your main CMakeLists.txt (before include(CPack)) > > SET(CPACK_SOURCE_INSTALLED_DIRECTORIES > "${CMAKE_SOURCE_DIR};/;${CMAKE_BINARY_DIR}/extra;/extra") > > then the content of the directory > ${CMAKE_BINARY_DIR}/extra will added in the package source archive > inside "extra" dir. > > it should work.
Indeed, it does; thanks for this hint, Eric. :) Just two remarks about that solution from my side: 1) Is it an official feature? The CPACK_SOURCE_INSTALLED_DIRECTORIES variable is not documented anywhere and does hardly appear on the ML or the BT, and even G**gle says that it is used rather seldom. 2) In contrast to the usual "package" target, there is no dependency of "package_source" on "all", so one will possibly miss something if the source package ingredients need to be set up at build time. AFAICS, the latter can be addressed with CPACK_INSTALL_COMMANDS set to "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}" or whatever is necessary to prepare the source tree for packaging, but there's no source-package specific CPACK_SOURCE_INSTALL_COMMANDS variable or the like. Perhaps, this is worth a feature request as concerns like the OP's one, i.e. the addition of certain build-time generated files to the source package, are somewhat reasonable, IMO. Regards, Michael _______________________________________________ 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