cmake parallel make problem.

Richard Shaw hobbes1069 at gmail.com
Wed Jan 18 16:34:35 UTC 2012


On Mon, Jan 16, 2012 at 5:35 PM, Petr Machata <pmachata at redhat.com> wrote:
> I didn't look into your problem, but what you say would mean that cmake
> is not generating all necessary dependencies for make.  Having a rule
> like "X: Y Z" is not enough.  If Z depends on Y, you need additionally
> "Z: Y", otherwise make will parallelize Y and Z.

Thanks! That's just the hint I needed. I didn't realize that cmake
doesn't "look at the whole picture" before writing the config files.
That's exactly what happened.

Here's my patch:
+# For parallel building.
+if(USE_SHARED)
+    add_dependencies(GeneratedSaxParser_shared ${CMAKE_REQUIRED_LIBRARIES})
+endif()
+if(USE_STATIC)
+    add_dependencies(GeneratedSaxParser_static ${CMAKE_REQUIRED_LIBRARIES})
+endif()
+

This may be overkill as the macro that adds each library appends to
CMAKE_REQUIRED_LIBRARIES. Even though it completed, the build time was
not noticeably reduced over a single threaded build. I think I'm "over
serializing" the build with this method.

I'll try adding only the dependent library and see if I run into any
other issues.

Thanks,
Richard


More information about the devel mailing list