[CMake] Inter-target dependencies on autogenerated headers
Roger Leigh
rleigh at codelibre.net
Thu Dec 19 08:19:27 EST 2013
On Wed, Dec 18, 2013 at 11:54:15PM +0000, Roger Leigh wrote:
> set(a_static_headers …)
> set(b_static_sources …)
> add_custom_command(OUTPUT ${a_generated_headers}
> ${a_generated_sources} COMMAND ${custom_tool} DEPENDS
> ${tool_dependencies)
> set(a_headers ${a_generated_headers} ${a_static_headers})
> set(a_sources ${a_generated_sources} ${a_static_sources})
> add_library(a SHARED ${a_sources} ${a_headers})
>
> Module b:
> set(b_headers …)
> set(b_sources …)
> add_library(b SHARED ${b_sources} ${b_headers})
> target_link_libraries(b a)
>
> The code generation, compiling and linking of module a works fine,
> and the code is regenerated if the dependencies are touched. This
> works building serially or in parallel.
>
> The compiling and linking of module b works fine only if building
> serially. If building in parallel, the ${b_sources} which include
> any headers from module a's ${a_generated_headers} will fail if they
> are built before header generation in module a occurs. This is
> inherently racy.
Sorry for the noise, I found that I did in fact have some missing
target_link_libraries in some autogenerated tests (too much
autogeneration going on...). Adding target_link_libraries for
everything fixes the dependencies and parallel building then
works just fine.
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800
More information about the CMake
mailing list