[CMake] Only install file if it does not exist?
Bob Tanner
tanner at real-time.com
Fri Sep 11 14:36:36 EDT 2009
On 2009-09-10 01:12:43 -0500, Eric Noulard
<eric.noulard at gmail.com> said:
> 0) Write your parameterized CMake script CopyIfNotExists.cmake.in
>
> 1) CONFIGURE_FILE(CopyIfNotExists.cmake.in CopyIfNotExists.cmake)
> This step will replace appropriate vars in CopyIfNotExists.cmake.in
> with value coming from your current config.
>
> 2) INSTALL(SCRIPT CopyIfNotExists.cmake)
Thank you for your help!
I tried this approach.
CMakeLists.txt
INSTALL (SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/CopyIfNotExists.cmake)
CopyIfNotExists.cmake
MACRO (COPY_IF_NOT_EXISTS _SRC _DEST)
MESSAGE ("Copy ${CMAKE_CURRENT_SOURCE_DIR}/${_SRC} to
${CMAKE_INSTALL_PREFIX}/${_DEST}")
IF (NOT EXISTS ${CMAKE_INSTALL_PREFIX}/${_DEST})
EXECUTE_PROCESS (COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}
${CMAKE_INSTALL_PREFIX}/${_DEST})
ENDIF (NOT EXISTS ${CMAKE_INSTALL_PREFIX}/${_DEST})
ENDMACRO (COPY_IF_NOT_EXISTS _SRC _DEST)
COPY_IF_NOT_EXISTS ("sample_features" "etc/features")
The problem is ${CMAKE_CURRENT_SOURCE_DIR} is set to the out-of-source
build directory.
Is this why you said to use a parameterized cmake script?
--
Bob Tanner <tanner at real-time.com> | Phone : (952 943-8700
http://www.real-time.com, Linux, OSX, VMware | Fax : (952)943-8500
Key fingerprint = F785 DDFC CF94 7CE8 AA87 3A9D 3895 26F1 0DDB E378
More information about the CMake
mailing list