[CMake] Problems with auto-generated sources

Gregor Jasny gjasny at googlemail.com
Tue Oct 1 07:38:33 EDT 2013


Hello,

On 9/30/13 7:19 PM, Williams, Norman K wrote:
> ========================================================================
> cmake_minimum_required(VERSION 2.8)
> project(Test)
>
> add_custom_command(OUTPUT file.c
>      COMMAND echo "GENERATING FILE"
>      COMMAND ${CMAKE_COMMAND} -E remove file.c
>      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/org.c
> file.c
>      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.c
>    )
> add_library(LibFile file.c)
>
> add_executable(test1 test.c)
> target_link_libraries(test1 LibFile)
>
> add_executable(test2 test.c)
> target_link_libraries(test2 LibFile)
>
>
> ========================================================================

Please try to add these two lines:

add_dependencies(test1 LibFile)
add_dependencies(test2 LibFile)

This helped to solve my dependencies problem.

Thanks,
Gregor



More information about the CMake mailing list