[CMake] copy a source file at configure

Andy Cedilnik andy.cedilnik at kitware.com
Tue Dec 7 15:17:08 EST 2004


Hi Leila,

You might want to specify the full path to the files.

You do this by saying:

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/source/A.h-win32 ${CMAKE_CURRENT_SOURCE_DIR}/source/B/A.h COPYONLY)

That said, it is very bad to write into the source dir. So, what you should really do is:

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/source/A.h-win32 ${CMAKE_CURRENT_BINARY_DIR}/source/B/A.h COPYONLY)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/source/B)

		Andy



Leila baghdadi wrote:

>Hi everyone
>
>I was just wondering if anyone knows how to do a following
>
>
>I need to create a directory and then copy some header files to this
>directory before the built
>
>i.e only filename and location changed and the content remains the same 
>
>source/A.h-win32 to
>source/B/A.h
>
>so I tried MAKE_DIRECTORY(B) and then
>
>CONFIGURE_FILE(source/A.h-win32 source/B/A.h COPYONLY)
>
>but I can not get it to work
>
>I also tried 
>
>ADD_CUSTOM_COMMAND(..)
>
>but that was also not successful,
>  
>


-- 
Andy Cedilnik
Kitware Inc.



More information about the CMake mailing list