-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GMock: fix dependency declarations #135
GMock: fix dependency declarations #135
Conversation
This is exactly what I tried to achieve with #109 but I'm not as good with CMake as you :) If this is merged I'll close my PR. |
Yeah CMake is not the easiest to get started with. There's a lot of bad tutorials out there and CMake's own documentation is more of a reference manual than a guide. Anyway thanks for your vote of confidence! |
I believe this assumes that Ninja requires a superset of what is required for Make (given that we are not going to compile with Make anymore). Am I correct? Also it's unfortunate that Ninja is not enabled on AppVeyor given how slow NMake is (I believe this has an example of how to install it). We'll wait for #130 to be merged and this rebased as you said. |
If you would use Make with the I've got experience with using Ninja on Linux and OSX (OSX only through CI systems at work and Travis), I have none for Windows. So I think it's smart to perform experiments for using it on Windows separately from this PR. |
#130 merged now :) |
Hmm, apparently |
This can be merged. |
Tried it with "make -j5" and it failed but with "make" it works (see gist https://gist.github.com/paoloambrosio/787377fe5229e286bb742bafcefb4e68). GNU Make 4.1 on Ubuntu 16.04. Any idea why? |
Could you show the content of This is succeeding for me btw. |
I will do it later when I have access to that machine. The same thing happens on OSX with GNU Make 3.81.
Can you confirm that |
My full set of commands, that work with c67dbe4: rm -rf build
mkdir build
cmake -E chdir build cmake \
-DCUKE_ENABLE_EXAMPLES=ON \
-DCUKE_DISABLE_BOOST_TEST=OFF \
-DGMOCK_VER=$x \
-G Unix\ Makefiles ..
make -C build -j5 Where x=1.6.0, x=1.7.0 and x=1.8.0. I am running this on a Debian Stretch laptop with only two cores though, so the diminished concurrency may be why this doesn't trigger for me. |
I've updated the gist, but there isn't much information in those logs. |
Hmm, just a warning, that's indeed not much. What CMake version are you using? I'm running 3.7.1, maybe an older version contains some bug or something (although they generally try to be backwards compatible even with bugs...). |
Okay this is strange. I do suspect a bug in CMake now, because for Ninja it properly generates a build rule for Do you still see this problem now? |
I've tried with Ninja as well and it doesn't work either. Not sure if you pushed changes (I'm at commit 0578f67). From the Ninja output it is clear that it tries to compile GTestDriver.cpp before it has downloaded GoogleTest:
Versions: CMake 3.7.2 and Ninja 1.7.2. |
The problem you see is definitely caused by a missing dependency of the |
Okay, so apparently that's not improving things. I'm a bit rushed right now, busy with work stuff, so it may be that I'll only be able to look at this again on Monday. |
I have had similar issue and resolved it by adding:
at the end of |
Right, so these kind of Somehow the Makefile generator still doesn't produce the correct dependency though. This seems to be related to this sentence from CMake's documentation on
That's relevant because we're dealing with an imported target. Except that it's not clear what they mean: adding a dependency on an imported target or a dependency of an imported target on something else. @konserw: your approach produces no differences at all in the produced makefiles for me. Unlike these For reference this is the diff between not having the diff -Nur build.orig/CMakeFiles/Makefile2 build/CMakeFiles/Makefile2
--- build.orig/CMakeFiles/Makefile2 2017-01-30 14:56:22.021991467 +0100
+++ build/CMakeFiles/Makefile2 2017-01-30 15:00:54.778795893 +0100
@@ -132,6 +132,7 @@
# Target rules for target CMakeFiles/e2e-steps.dir
# All Build rule for target.
+CMakeFiles/e2e-steps.dir/all: CMakeFiles/gmock.dir/all
CMakeFiles/e2e-steps.dir/all: src/CMakeFiles/cucumber-cpp.dir/all
$(MAKE) -f CMakeFiles/e2e-steps.dir/build.make CMakeFiles/e2e-steps.dir/depend
$(MAKE) -f CMakeFiles/e2e-steps.dir/build.make CMakeFiles/e2e-steps.dir/build
@@ -248,7 +249,7 @@
# Target rules for target src/CMakeFiles/cucumber-cpp-nomain.dir
# All Build rule for target.
-src/CMakeFiles/cucumber-cpp-nomain.dir/all:
+src/CMakeFiles/cucumber-cpp-nomain.dir/all: CMakeFiles/gmock.dir/all
$(MAKE) -f src/CMakeFiles/cucumber-cpp-nomain.dir/build.make src/CMakeFiles/cucumber-cpp-nomain.dir/depend
$(MAKE) -f src/CMakeFiles/cucumber-cpp-nomain.dir/build.make src/CMakeFiles/cucumber-cpp-nomain.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/giel/git/cucumber-cpp/build/CMakeFiles --progress-num=53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69 "Built target cucumber-cpp-nomain" Full diff here, but it's just more of the same: http://pastebin.com/YxtqCSz1 As I see it exactly those dependencies (of build cmake_order_depends_target_cucumber-cpp-nomain: phony || gmock
build src/CMakeFiles/cucumber-cpp-nomain.dir/drivers/GTestDriver.cpp.o: CXX_COMPILER__cucumber-cpp-nomain ../src/drivers/GTestDriver.cpp || cmake_order_depends_target_cucumber-cpp-nomain So maybe that's necessary there: the object file dependencies, in which case we're possibly dealing with a bug in CMake's Makefile generator. PS I know about a CMake bug related to object file dependencies, but that's related to generating them too eagerly and that's in the Ninja generator. Although they talk about things being done there "because the Makefile generator does it that way": https://gitlab.kitware.com/cmake/cmake/issues/15555 |
I downloaded the generated Apparently #130 contained a minor typo (with not-so-minor consequences): it used Of course I only see that when about to give up ;-) So it was apparently completely unrelated to dependency ordering: just the include path that didn't get expanded properly. As for why it did work on my systems, apparently on all (3) of them I've got @paoloambrosio do you still see problems after my latest push? |
Because _DIRS is an output variable that doesn't (yet) exist.
I haven't tried this before, but now (at 8a9a61a ) I'm able to compile using both |
This prevents attempting to include things from /usr/src/gmock/include/gmock/gmock.h, which in Ubuntu Trusty's google-mock package doesn't exist at that location.
This gives CMake the information it needs to figure out the dependencies _properly_ by itself. As a result fully parallel builds now actually work.
Had to fix a remaining merge problem. (Use of |
It still fails, and now I've created a Docker container to run those builds to verify that it's not my project setup: https://github.com/paoloambrosio/cucumber-cpp-build Now this PR doesn't solve the problem of parallel builds in general (it still doesn't work for me), but reduces the likelihood of failures (it works for you two). We are stalled as you cannot reproduce the issue and I don't have time to work on it. I suggest we merge this PR anyway and keep working on other issues. What are your thoughts? |
@paoloambrosio I think that may be the best approach. FYI: I can sometimes get a build failure with your docker container (1 in 3 times or so). It seems like every time that does happen the configure step starts before the download step finishes. |
execute_process(COMMAND sh -c "ls -lA /usr/src/cucumber-cpp/build/gmock/src/gtest > /dev/tty")
Apparently I didn't account for the separation between the GTest and GMock external projects that are used for 1.6/1.7. In that case the GMock project should not be configured before GTest is downloaded. That's very simple to fix luckily, a single |
This way other properties such as the list of libraries to link to transitively and what header files to use get handled automatically by CMake.
Because after making fully parallel builds possible we'd better start using them to keep testing them.
YES! YES! YES! GREAT JOB! |
Fixes parallel builds (including Ninja)
Thanks for your dockerfile and readme. I'm not sure I would have been able to reproduce and fix this problem without the accompanying readme. |
This ensures CMake knows how to build the library files, so that if they're used as dependencies it knows how to order the build chain, even on fully parallelized builds. Additionally this switches Travis over to use Ninja for a build system instead of Make, which makes use of those parallel builds.
This partially replaces what PR #109 does and unlike that PR it's mergeable with master. It will also have a merge conflict with #130, but I've been careful to do as few changes as possible to keep that conflict as small as possible. At this time I'm most interested in getting this reviewed. If it's more convenient I'm happy to rebase this after merging #130.
Logically this change does one thing only (inside
FindGMock.cmake
): declare the produced libraries as being produced by theExternalProject_Add
declarations. (There's also the fix of a small typo in thelibgmock
import declaration which rendered that target completely useless).