kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

[patch] fix for CMakeLists.txt to correctly support shared and static library with all targets #87

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Attached is a patch that will correct the CMakeLists.txt for trunk to...
a) correctly create makefiles for shared and static libraries
b) help users that use GCC before 3.4 to get rid of "-Wextra" a little bit 
easier.

I could build DLL and static library via CMake in VS2005 just fine.

Kind regards
Maddes

P.S.:
Yes, I still have to use GCC 3.2 for a project where we want to add YAML 
support.

Original issue reported on code.google.com by matthias...@gmail.com on 3 Jan 2011 at 8:05

GoogleCodeExporter commented 8 years ago
yaml-cpp 0.2.5 compiled as static library incl. tools with VC++ 2005 and 2008 
in conjunction with the patched CMakeLists.txt from trunk.
Older VC++ do not compile and give errors.

Original comment by matthias...@gmail.com on 3 Jan 2011 at 9:31

GoogleCodeExporter commented 8 years ago
The commands I used inside the yaml-cpp-0.2.5 folder:
* mkdir bin\vc2005
* cd bin\vc2005
* del /s /q * & rmdir /s /q .
* cmake -DBUILD_SHARED_LIBS=OFF -G "Visual Studio 8 2005" ..\..

* mkdir bin\vc2008
* cd bin\vc2008
* del /s /q * & rmdir /s /q .
* cmake -DBUILD_SHARED_LIBS=OFF -G "Visual Studio 9 2008" ..\..

Original comment by matthias...@gmail.com on 3 Jan 2011 at 9:32

GoogleCodeExporter commented 8 years ago
Updated patch to include format fixes and an additional conditionally set 
definition (as preparation for correct Windows DLL compilation).

Original comment by matthias...@gmail.com on 7 Jan 2011 at 10:33

GoogleCodeExporter commented 8 years ago
I also had the need to link against shared runtime libraries in MSVC (/MT).
Attached is a completely overhauled CMakeLists.txt that supports all possible 
types of MSVC runtime libraries.

Would be great to get comments on it.

Original comment by matthias...@gmail.com on 9 Jan 2011 at 3:13

GoogleCodeExporter commented 8 years ago
Thanks for these! I'm away from my main dev machines now, so I won't be able to 
look at it for a little.

Original comment by jbe...@gmail.com on 10 Jan 2011 at 5:24

GoogleCodeExporter commented 8 years ago
Re-worked the CMakeLists.txt to make it cleaner and easier to re-use and 
understand.

Original comment by matthias...@gmail.com on 11 Jan 2011 at 10:26

GoogleCodeExporter commented 8 years ago
Worked on another project with lots of build environments: Windows MinGW and 
MSVC, Linux GCC and Mac OSX GCC. Plus building static and shared libraries (DLL 
on Windows).
All new knowledge went into a new CMakeLists.txt, that provides several options 
to configure the project file creation.

Original comment by matthias...@gmail.com on 17 Jan 2011 at 8:27

GoogleCodeExporter commented 8 years ago
Enhanced CMakeLists.txt even further to check for "-Wextra" support itself. 
Works 100% withotu any option.

Original comment by matthias...@gmail.com on 8 Feb 2011 at 10:45

Attachments:

GoogleCodeExporter commented 8 years ago
Finally got around to merging this. Works great!

Original comment by jbe...@gmail.com on 2 Mar 2011 at 4:41

GoogleCodeExporter commented 8 years ago
I should mention, r432.

Original comment by jbe...@gmail.com on 2 Mar 2011 at 4:41

GoogleCodeExporter commented 8 years ago
Also, I just merged two changes from another contributor, Richard (from 
branches/debuggable and branches/graphbuilder-api) in r434.

Both include small changes to the CMakeLists.txt file - in the graphbuilder 
case, we just make the file globbing recursive, and in the debuggable case, he 
wanted targets so he could write

make debuggable

or

make releasable

and it would switch between -O2 and -g options in gcc. I tried to emulate your 
CMake style - could you take a peek and see if it looks OK?

Thanks so much for this!

Original comment by jbe...@gmail.com on 2 Mar 2011 at 5:04

GoogleCodeExporter commented 8 years ago
I think r434 looks ok, but will do some tests next weekend.

Just some comments:
* No flags for "MinSizeRel" (don't if this target makes any sense for yaml-cpp)
* Formatting: place "set(GCC_EXTRA_OPTIONS "")" below the code for 
target-dependent CMAKE_CXX_FLAGS_<config>
  It got splitted away from the rest.

And many thanks from Gerry and me, this will help us to keep YAML-CPP 
up-to-date in the PinMAME project.

Original comment by matthias...@gmail.com on 2 Mar 2011 at 7:10

GoogleCodeExporter commented 8 years ago
OK, I fixed the formatting; with respect to the MinSizeRel, should I set it 
with the "-Os" flag? Or just not set it at all?

Original comment by jbe...@gmail.com on 2 Mar 2011 at 9:10

GoogleCodeExporter commented 8 years ago
I think the "-Os" flag would be a good setting for MinSizeRel.

Original comment by matthias...@gmail.com on 3 Mar 2011 at 7:37

GoogleCodeExporter commented 8 years ago
Tested with MinGW 2 (gcc 3.2.3) and MinGW 5 (gcc 4.5.0).

Library builds fine with both.
Tools only build with MinGW 5 (gcc 4.5.0). This was also the case before, so no 
issue.

But I found one new warning, a missing newline in the contrib source.
Patch is attached.

Original comment by matthias...@gmail.com on 6 Mar 2011 at 10:50

Attachments: