[CMake] INSTALLing a directory
Philippe Poilbarbe
Philippe.Poilbarbe at cls.fr
Mon Jun 26 09:12:46 EDT 2006
Benjamin THYREAU a écrit :
> Hi,
> i want to copy a whole recursive directory of runtime files, during the
> INSTALL phase.
> I use FILE(GLOB_RECURSE to catch the files, but then, it loses the
> subdirectory structure.
> (ie. python/__init__.py and python/test/something.py got both INSTALLed on the
> same DESTINATION directory..)
> Did anyone had the same problem ?
> Thanks
>
Here is a solution. I don't know if is optimal but, for me it works :)
I do it for documentation directory because we
cannot know what will be inside before building it:
Create a file named (for example) IntallMyDir.cmake.in containing:
MESSAGE (STATUS "Installation of MyDir)
EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS -E copy_directory "@MYDIR@"
"@CMAKE_INSTALL_PREFIX@/mydirectory" RETURN_VALUE INSTALL_MYDIR_STATUS)
IF (INSTALL_MYDIR_STATUS)
MESSAGE(FATAL_ERROR "Error installing mydir")
ENDIF (INSTALL_MYDIR_STATUS)
where MYDIR contains the path of the directory to copy and
"/mydirectory" is the destination path relative to installation prefix
Then in CMakeList.txt put:
CONFIGURE_FILE(InstallMyDir.cmake.in
${CMAKE_CURRENT_SOURCE_DIR}/InstallMyDir.cmake @ONLY)
SET_TARGET_PROPERTIES(TheTarget
PROPERTIES POST_INSTALL_SCRIPT InstallMyDir.cmake)
where TheTarget is a target which launch the build of the directory
--
Philippe Poilbarbe
CLS - Space Oceanography Division
More information about the CMake
mailing list