2009/9/11 Bob Tanner <[email protected]>:
> On 2009-09-10 01:12:43 -0500, Eric Noulard <[email protected]> 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?

Yes you are right.
Most (if not all) variable you expect to use are not defined when
CopyIfNotExists.cmake is invoked.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
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

Reply via email to