[CMake] Simple CMakeLists.txt file not working with cmake version 2.6
Michael Wild
themiwi at gmail.com
Thu Dec 24 04:06:54 EST 2009
On 24. Dec, 2009, at 9:26 , Mahendra Ladhe wrote:
> Hi,
> shown below is a simplified and relevant part of my CMakeLists.txt file.
>
> add_custom_command (
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sample.bash
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash
> COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash .)
make the last line
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/sample.bash"
"${CMAKE_CURRENT_BINARY_DIR}/sample.bash")
However, if it really is only copying you are interested in, why don't you use CONFIGURE_FILE(... COPYONLY)?
>
> add_custom_target (sample.bash ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sample.bash)
I don't see why you want this... In any case, you need to rename this custom target, because it probably clashes with the custom command.
>
> Basically, I want to copy the 'sample.bash' script from source directory to the
> binary (build) directory when 'make' is run.
> I want this CMakeLists.txt to work on cmake version 2.4 as well as 2.6
>
> On cmake 2.4, this works fine.
> mladhe at linux:~/cmake_expt/bld] make
> [ 0%] Generating sample.bash
> [100%] Built target sample.bash
> mladhe at linux45:~/cmake_expt/bld] ls
> CMakeCache.txt CMakeFiles Makefile cmake_install.cmake sample.bash
>
> However on cmake 2.6, I get the following.
>
> mladhe at linux:~/cmake_expt/bld] make
> Scanning dependencies of target sample.bash
> make[2]: Circular CMakeFiles/sample.bash <- sample.bash dependency dropped.
> Built target sample.bash
> mladhe at linux45:~/cmake_expt/bld] ls
> CMakeCache.txt CMakeFiles Makefile cmake_install.cmake
>
> As can be seen, sample.bash file has not been copied.
>
> How to make this CMakeLists.txt work on both cmake versions ?
>
> Thank you,
> Regards,
> Mahendra Ladhe
>
HTH
Michael
More information about the CMake
mailing list