[CMake] add_custom_command vs add_subdirectory

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri Feb 19 10:24:26 EST 2010


add_dependencies() seems to be working with add_subdirectory()

sorry for the noise
-Mathieu

On Fri, Feb 19, 2010 at 3:46 PM, Mathieu Malaterre
<mathieu.malaterre at gmail.com> wrote:
> Hi,
>
>  I am trying to find a solution with add_custom_command that can only
> depends on file generated within the same directory as where it is
> defined. What would I need to change here to make this small example
> work:
>
> $ cat CMakeLists.txt
> project(d12)
> cmake_minimum_required(VERSION 2.8)
>
> add_custom_command(
>  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bla.txt
>  COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/bla.txt
>  DEPENDS ${d12_BINARY_DIR}/sub/foo.txt
>  )
> add_custom_target(bla ALL
>  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bla.txt
>  )
> add_subdirectory(sub)
>
> and
>
> $ cat sub/CMakeLists.txt
> add_custom_command(
>  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.txt
>  COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/foo.txt
>  )
>
>
> Ref:
> svn co https://gdcm.svn.sourceforge.net/svnroot/gdcm/Sandbox/CMakeBug/12
>
> Thanks for suggestions,
> --
> Mathieu
>



-- 
Mathieu


More information about the CMake mailing list