The primary build system we use for gtest and gmock is autotools,
which is hard-to-maintain and slow. It's also not cross-platform, so
we have to maintain xcode and Visual Studio projects separately.
It has been suggested several times, by different people, that we
switch to a more sane build system. Many of them pointed to CMake
(http://www.cmake.org/).
I just started to read up on CMake, and found this encouraging article
(it's a nice and short read, so I suggest you to read it too if you
haven't):
Why the KDE project switched to CMake -- and how
http://lwn.net/Articles/188693/
(Interesting that they first tried SCons and had to give up.)
With CMake, I hope we can:
- have build scripts that more people can understand and maintain (no
more waiting for rescue by the tiny number of autotools experts on
the list),
- generate xcode and VS projects automatically,
- speed up the build process,
- speed most time on actually improving gtest/gmock instead of fixing
the build system.
I'll spend more time getting familiar with CMake, and want to get the
discussion going while I do that.
Thoughts? Thanks,
--
Zhanyong
Having tried Scons, Ant, Autotools, and finally CMake... I totally
agree. You might even want to check this out: https://svn.boost.org/trac/boost/wiki/CMake
.
Cheers,
Hady
Envoyé de mon iPhone
Le 19 déc. 2009 à 00:30, Zhanyong Wan (λx.x x) <w...@google.com> a
écrit :
One thing I like about CMake is that it has very light dependencies.
You can download pre-built CMake binaries from
http://www.cmake.org/cmake/resources/software.html, or if your
platform isn't on the list, you can compile CMake yourself using a
standard C++ compiler, which you must already have. :-)
It looks like that GYP was specifically designed for Chromium, so I
don't expect its maintainers to put our needs before Chromium's when
there's conflict of interest. It also depends on Python, which we'd
want to avoid since it doesn't come installed on all platforms.
Waf shares many design goals with CMake, but it has the problem of
depending on Python too. Also it doesn't seem to be used by really
complex projects, where CMake is used by KDE.
Ant's dependency on Java makes it a poor choice for many of our users.
I read more about CMake today and started to put together build
scripts for gtest. Now I can build the gtest library itself, all
samples, and most of the tests. The build is much much faster than
the autotools version! The last 20% of the work is always the
hardest, but my experience so far gives me confidence.
Cheers,
2009/12/18 Zhanyong Wan (λx.x x) <w...@google.com>:
--
Zhanyong
It's really great that we move to something more advanced than
autotools/automake/etc because sometimes it's much easier to just hack
and build the sources manually rather than struggling with
auto*-scripts.
CMake looks very mature and portable. Personally I like Python based
build managers like SCons due to its almost unlimited flexibility but
it benefits until you haven't Python somewhere or its version is
wrong. Though SCons can work on quite old versions of Python but
frankly having Python dependency to build isn't great for portability
at all regardless to my love to this language. ;-)
Alexander
2009/12/22 Zhanyong Wan (λx.x x) <w...@google.com>:
gtest and gmock already have SCons scripts. We use them for testing
gtest/gmock on various platforms. It works mostly fine, but is not
quite easy to maintain (although better than autotools in this
regard). There's always bugs in it that we aren't quite sure how to
properly fix.
CMake looks quite a bit simpler, and seems much faster than SCons in
my experiments (I don't have hard numbers yet - yet a subjective
impression). It also claims to generate native VS and Xcode projects.
SCons generates poor VS projects (basically wrappers for a batch
script that lack true integration with the IDE) and cannot generate
Xcode projects at all.
--
Zhanyong
In fact, the tests run so much faster in CMake (as it hides the test
output by default) that I at first thought I screwed up the build
script and the testing was a no-op. :-) I verified that CMake indeed
ran the tests by making one of them intentionally fail.
--
Zhanyong
I just committed an experimental CMake build script for gtest to the
SVN trunk, r359. (Thanks to Chandler for the code reviews!) You are
welcome to try it and send me feedback/improvements. You can download
CMake at http://www.cmake.org/cmake/resources/software.html
For your convenience, here's the link to the build script:
http://code.google.com/p/googletest/source/browse/trunk/CMakeLists.txt
Hopefully it's self-documenting. It helps if you already know CMake.
In case you don't, it shouldn't be hard to guess what the script is
doing as the syntax is reasonably intuitive. Of course, you should
check the CMake documentation when in doubt:
http://www.cmake.org/cmake/help/cmake-2-8-docs.html
You can safely skip the parts for building the samples and tests if
you aren't interested in them. Thanks,
2009/12/18 Zhanyong Wan (λx.x x) <w...@google.com>:
--
Zhanyong
Thanks,
Gavin
On Dec 29 2009, 7:53 pm, Zhanyong Wan (λx.x x) <w...@google.com>
wrote:
> Hi all,
>
> I just committed an experimental CMake build script for gtest to the
> SVN trunk, r359. (Thanks to Chandler for the code reviews!) You are
> welcome to try it and send me feedback/improvements. You can download
> CMake athttp://www.cmake.org/cmake/resources/software.html
On Mon, Jan 4, 2010 at 2:13 AM, Gavin Heavyside
<gavin.h...@gmail.com> wrote:
> Are you using any CMake 2.8 features that aren't in 2.6 (you specify
> cmake_minimum_required(VERSION 2.8))?
I'm not sure. I'm new to CMake and 2.8 is the only version I've used.
> Centos 5 has v2.6 available in
> rpmforge, and I'd rather not have to upgrade systems manually unless
> there is specific functionality not available in an earlier version.
FYI, you don't have to upgrade your system. Just download the CMake
2.8 source distribution, build it, and put the built executables in
your PATH. I use it this way.
Could you please try to change 2.8 to 2.6 in the script and see if it
still works? If you do that, please share your result with us.
Thanks,
--
Zhanyong
FYI, you don't have to upgrade your system. Just download the CMake
2.8 source distribution, build it, and put the built executables in
your PATH. I use it this way.
Could you please try to change 2.8 to 2.6 in the script and see if it
still works? If you do that, please share your result with us.
--
Zhanyong
2010/1/5 Zhanyong Wan (λx.x x) <w...@google.com>:
--
Zhanyong
Cheers,
/Manuel
--
Manuel Klimek (http://go/klimek)
2010/1/5 Manuel Klimek <kli...@google.com>:
--
Zhanyong
--
Zhanyong
On Jan 6, 1:06 pm, Zhanyong Wan (λx.x x) <w...@google.com> wrote:
> Manuel's patch that fixes the problem on Windows has been committed in
> r363. Cheers,
>
> 2010/1/5 Zhanyong Wan (λx.x x) <w...@google.com>:
>
>
>
> > Update: I committed r361 to make the script compatible with both cmake
> > 2.6.4 and 2.8.0 (thanks to Manuel for the review). There's still the
> > target path problem that prevents the Python tests to run correctly on
> > Windows. Manuel is working on that. Thanks,
>
> > 2010/1/5 Manuel Klimek <kli...@google.com>:
> >> One of the problems is that apparently the add_test signature changed.
> >> Especially the only way I found to correctly transport the target path
> >> into the test works only on 2.8.
> >> I found a script that apparently multiple projects use to keep
> >> backwards compatibility, though:
>
> >>http://code.google.com/p/libarchive/source/browse/trunk/build/cmake/A...
No. Would you like to work on it?
--
Zhanyong
On Jan 6, 1:28 pm, Zhanyong Wan (λx.x x) <w...@google.com> wrote:
I can give it a try (I'll fix the tests on Windows first, though :-),
if I get a pointer to the .def file...
Regarding the .def file: do we think it's not worth to add exporting
only a subset of symbols via macros (gcc supports this, too, and in
C++ land it's by now a good practice to do so, because of the high
runtime cost unused symbols generate). On the other hand, gtest is not
really big, so the runtime cost is probably not a big problem... Just
thinking out loud :-)
Cheers,
/Manuel
The .def file is checked in, under the msvc/ directory.
> Regarding the .def file: do we think it's not worth to add exporting
> only a subset of symbols via macros (gcc supports this, too, and in
> C++ land it's by now a good practice to do so, because of the high
> runtime cost unused symbols generate). On the other hand, gtest is not
> really big, so the runtime cost is probably not a big problem... Just
> thinking out loud :-)
We only export the symbols that are actually needed by a user.
--
Zhanyong
Ah, thx.
>> Regarding the .def file: do we think it's not worth to add exporting
>> only a subset of symbols via macros (gcc supports this, too, and in
>> C++ land it's by now a good practice to do so, because of the high
>> runtime cost unused symbols generate). On the other hand, gtest is not
>> really big, so the runtime cost is probably not a big problem... Just
>> thinking out loud :-)
>
> We only export the symbols that are actually needed by a user.
In linux via a shared object file without macros? How so?
Cheers,
/Manuel
On Jan 7, 5:04 am, Manuel Klimek <kli...@google.com> wrote:
> 2010/1/6 Zhanyong Wan (λx.x x) <w...@google.com>:
>
> > On Wed, Jan 6, 2010 at 12:57 PM, Manuel Klimek <kli...@google.com> wrote:
--
Zhanyong
/Manuel
2010/1/15 Zhanyong Wan (λx.x x) <w...@google.com>:
So Lenny, I could just add a SHARED target for MSVC builds to the
CMakeLists.txt, but we'd not have a clue how many tests would be
supported and you'd have to maintain the .def file...
I'd strongly vote for adding the macros, but of course it's Zhanyong's
call, so if you can't convince him, it's not going to happen :-(
Cheers,
/Manuel
2010/1/28 Manuel Klimek <kli...@google.com>:
2010/1/28 Manuel Klimek <kli...@google.com>:
> Update: it's fairly simple to get a gtest dll from cmake, adding the
> .def to the sources of the library and specifying SHARED instead of
> STATIC is enough.
> But...
> - I tried to compile / run the gtest tests with SHARED, but the
> problem is that there are so many different compile options and each
> needs to export different symbols, thus we'd need multiple .def files
Good point.
> - I get segfaults when running some tests; no idea whether this is a
> gtest problem with shared libraries and static objects (they behave
> different in MSVC than in gcc), but that would be my guess; I don't
> want to waste time looking into this if we don't come to some
> maintainable solution here
Good thinking. :)
> So Lenny, I could just add a SHARED target for MSVC builds to the
> CMakeLists.txt, but we'd not have a clue how many tests would be
> supported and you'd have to maintain the .def file...
>
> I'd strongly vote for adding the macros, but of course it's Zhanyong's
> call, so if you can't convince him, it's not going to happen :-(
I'm open to revisiting this decision. It was experimental. What do
you think, Vlad? Thanks,
--
Zhanyong
Thanks for looking into this, Manuel!
> Update: it's fairly simple to get a gtest dll from cmake, adding theGood point.
> .def to the sources of the library and specifying SHARED instead of
> STATIC is enough.
> But...
> - I tried to compile / run the gtest tests with SHARED, but the
> problem is that there are so many different compile options and each
> needs to export different symbols, thus we'd need multiple .def files
Good thinking. :)
> - I get segfaults when running some tests; no idea whether this is a
> gtest problem with shared libraries and static objects (they behave
> different in MSVC than in gcc), but that would be my guess; I don't
> want to waste time looking into this if we don't come to some
> maintainable solution here
I'm open to revisiting this decision. It was experimental. What do
> So Lenny, I could just add a SHARED target for MSVC builds to the
> CMakeLists.txt, but we'd not have a clue how many tests would be
> supported and you'd have to maintain the .def file...
>
> I'd strongly vote for adding the macros, but of course it's Zhanyong's
> call, so if you can't convince him, it's not going to happen :-(
you think, Vlad? Thanks,
Ignore what I wrote yesterday, I was stupid. Got everything to compile
with shared libs now...
Will investigate some more wrt the test failures...
Cheers,
/Manuel
Oh my god: git5 sync'ed, had to add 43 new symbols to the .def file...
since there's no way to test that on linux, who'll maintain the .def
file?
Cheers,
/Manuel
To sum it up: the best way forward seems to be to add the macros for
symbol exporting - that way we can support the gcc visibility stuff,
too (see http://gcc.gnu.org/wiki/Visibility).
Thoughts?
/Manuel
Outcome from the investigation:
Some tests access global variables from the gtest dll directly (for
example FLAGSgtest_filter from gtest_environment_test.cc). The problem
is that the compiler creates a new global symbol in the executable
when the flag is not declared with __declspec(dllimport), thus causing
segfaults. To solve this, we need to annotate the variables with
__declspec(dllimport) when the declaration is used outside of the
gtest dll compilation. Since we need a macro for that, we can use the
same macro to __declspec(dllexport). Now we're half way to export
symbols anyway, and Zahnyong says he's not opposed to the macro idea.
To sum it up: the best way forward seems to be to add the macros for
symbol exporting - that way we can support the gcc visibility stuff,
too (see http://gcc.gnu.org/wiki/Visibility).
Thoughts?
Lenny, do you have the patch against the current head version lying
around somewhere?
Cheers,
/Manuel
2010/1/29 Manuel Klimek <kli...@google.com>:
The only patch from Lenny I could find is the one attached here:
http://code.google.com/p/googletest/issues/detail?id=214
It's against 1.3.0, but perhaps it's close enough for the head. Thanks,
>
> Cheers,
> /Manuel
>
--
Zhanyong
Unfortunately it doesn't apply cleanly. And I'm quite surprised why we
wouldn't export some classes completely instead of selecting singular
methods... I'll do some more work on it next week...
Cheers,
/Manuel
>
>>
>> Cheers,
>> /Manuel
Thanks for looking into this, Manuel! That patch was never reviewed,
so use it as you see fit or do it from scratch if that's easier.
Cheers,
>
> Cheers,
> /Manuel
>
>>
>>>
>>> Cheers,
>>> /Manuel
>>>
>>
>>
>>
>> --
>> Zhanyong
>>
>
>
>
> --
> Manuel Klimek (http://go/klimek)
>
--
Zhanyong
Have you found time for this yet? :) No problem if you are busy, just
let us know if you'd rather Vlad or I work on it. Thanks!
2010/2/5 Manuel Klimek <kli...@google.com>:
--
Zhanyong
2010/2/23 Vlad Losev <vl...@google.com>:
> Hi Zhanyong,
>
> I exchanged emails with Michael and it looked like he had no immediate
s/Michael/Manuel/ ?
--
Zhanyong
Sorry I haven't been around for a while.
Let me know if this works.
On Feb 4, 3:16 pm, Zhanyong Wan (λx.x x) <w...@google.com> wrote:
> Hi Manuel,
>
> 2010/1/29 Manuel Klimek <kli...@google.com>:
>
>
>
> > 2010/1/29 Vlad Losev <vl...@google.com>:
>
> >> 2010/1/29 Manuel Klimek <kli...@google.com>
>
> >>> Outcome from the investigation:
> >>> Some tests access global variables from the gtest dll directly (for
> >>> example FLAGSgtest_filter from gtest_environment_test.cc). The problem
> >>> is that the compiler creates a new global symbol in the executable
> >>> when the flag is not declared with __declspec(dllimport), thus causing
> >>> segfaults. To solve this, we need to annotate the variables with
> >>> __declspec(dllimport) when the declaration is used outside of the
> >>> gtest dll compilation. Since we need a macro for that, we can use the
> >>> same macro to __declspec(dllexport). Now we're half way to export
> >>> symbols anyway, and Zahnyong says he's not opposed to the macro idea.
>
> >>> To sum it up: the best way forward seems to be to add the macros for
> >>> symbol exporting - that way we can support the gcc visibility stuff,
> >>> too (seehttp://gcc.gnu.org/wiki/Visibility).