[CMake] INSTALLing a directory
Filipe Sousa
filipe at ipb.pt
Mon Jun 26 09:18:40 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Philippe Poilbarbe wrote:
> 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
You can use INSTALL(SCRIPT
INSTALL([[SCRIPT <file>] [CODE <code>]] [...])
The SCRIPT form will invoke the given CMake script files during
installation. If the script file name is a relative path it will be
interpreted with respect to the current source directory. The CODE
form will invoke the given CMake code during installation. Code is
specified as a single argument inside a double-quoted string. For
example, the code
- --
Filipe Sousa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD4DBQFEn96wbQdNYqwwwCwRAromAJY5/d2+6n2vDltB2oeU3TivLKK8AJ9X6vi3
tJ7YS74sYBCMlRm0unG62Q==
=WH8v
-----END PGP SIGNATURE-----
More information about the CMake
mailing list