[CMake] Generated file and parallel build.
Brad King
brad.king at kitware.com
Mon Sep 22 09:21:03 EDT 2008
Óscar Fuentes wrote:
> Several libraries depends on a generared header file. For enabling
> parallel builds I need to state that dependency, and I do it with
> set_source_files_properties. This happens inside a macro:
>
> macro(add_llvm_library name)
> if( LLVM_SOURCE_COMMON_DEPENDS )
> set_source_files_properties( ${ARGN}
> PROPERTIES OBJECT_DEPENDS ${LLVM_SOURCE_COMMON_DEPENDS}
> )
> endif( LLVM_SOURCE_COMMON_DEPENDS )
> add_library( ${name} ${ARGN} )
> ....
>
> where LLVM_SOURCE_COMMON_DEPENDS contains the name of the custom target
> that is used to trigger the custom command that generates the file:
You're mixing up file-level dependencies with target-level dependencies.
The OBJECT_DEPENDS property only specifies file-level dependencies. I
see its documentation is lacking. I'll commit improved documentation
for it. The add_dependencies command is used to create extra
inter-target dependencies:
macro(add_llvm_library name)
add_library(${name} ${ARGN})
add_dependencies(${name} ${LLVM_SOURCE_COMMON_DEPENDS})
....
endmacro()
Just make sure the LLVM_SOURCE_COMMON_DEPENDS variable contains only
target names and not files.
> add_custom_command(OUTPUT ${path_to_intrinsics_gen}
> COMMAND tblgen -gen-intrinsic ... -o ${path_to_intrinsics_gen}
> DEPENDS tblgen
> COMMENT "Building intrinsics.gen...")
>
> add_custom_target(intrinsics_gen ALL
> DEPENDS ${path_to_intrinsics_gen})
>
> set(LLVM_SOURCE_COMMON_DEPENDS ${LLVM_SOURCE_COMMON_DEPENDS} intrinsics_gen )
This is correct.
-Brad
More information about the CMake
mailing list