OpenXcom Forum

Contributions => Programming => Topic started by: SupSuper on October 16, 2011, 07:45:23 pm

Title: The yaml-cpp include dilemma
Post by: SupSuper on October 16, 2011, 07:45:23 pm
There's a long-standing dilemma on how OpenXcom should include yaml-cpp, either through:
Code: [Select]
#include "yaml.h"Or:
Code: [Select]
#include "yaml-cpp/yaml.h"
Each approach has their own pros/cons. Currently OpenXcom uses the former because of this issue with Mac builds (https://openxcom.org/forum/index.php/topic,143.0.html). However, in the latest version of yaml-cpp 0.2.7, the pkconfig file has been changed to only support the latter option (https://code.google.com/p/yaml-cpp/issues/detail?id=122), which breaks our Linux builds without manual modifications.

So I was hoping you platform porters could come to an agreement?
Title: Re: The yaml-cpp include dilemma
Post by: gchevallereau on October 16, 2011, 08:01:50 pm
As I have said on the IRC channel, I'm waiting to get my hands on a mac. Once done, I will try to check if the second option can be used.

apart from possible name clashes, it also make more difficult to openxcom. For example i have to add the following to get it built with makefile
Code: [Select]
CXXFLAGS=-I/usr/local/include/yaml-cpp make
or autotools:
Code: [Select]
YAML_CFLAGS=-I/usr/local/include/yaml-cpp ./configure
Title: Re: The yaml-cpp include dilemma
Post by: luciderous on October 16, 2011, 09:30:27 pm
Well, if we stick with the subdir option, we'll have to find some way around to build it with Xcode. Right now, I have no idea how to do that, and won't be able to look deeper into the matter until I get some spare time - something that I currently lack  :(
Title: Re: The yaml-cpp include dilemma
Post by: winterheart on October 25, 2011, 01:25:37 pm
You could use macros on the code like this

#ifdef DARWIN
#include yaml.h
#else
#include "yaml-cpp/yaml.h"
#endif

And define -DDARWIN definition on  build-system

Another way is switch to CMake buildsystem and write own module for yaml-cpp.cmake.
Title: Re: The yaml-cpp include dilemma
Post by: sir_nacnud on November 29, 2011, 06:34:57 am
Have you tried using angle brackets instead of quotes?  This is generally the approach when including system libraries.

Code: [Select]
#include <yaml-cpp/yaml.h>

See the distinction between angle bracket form and quoted form here: https://msdn.microsoft.com/en-us/library/36k2cdd4(v=vs.80).aspx
Title: Re: The yaml-cpp include dilemma
Post by: gchevallereau on December 05, 2011, 11:12:06 pm
I had access to a mac this weekend and manage to build openxcom with the yaml-cpp sub directory.

The fixed YAML framework can be obtained here: https://gchevallereau.net/guillaume/openxcom/YAML.framework.tar.bz2

I have a branch with all yaml.h include transformed to yaml-cpp/yaml.h here : https://github.com/gchevallereau/OpenXcom/tree/yaml_fix
Title: Re: The yaml-cpp include dilemma
Post by: luciderous on December 08, 2011, 09:02:14 am
Nice! I'll check it out when I get a free minute. Thanks!
Title: Re: The yaml-cpp include dilemma
Post by: SupSuper on March 04, 2012, 11:08:44 pm
Some people still contact me about this issue, so I'd like to get a clear agreement on this: Is it OK to change the include to <yaml-cpp/yaml.h> along all platforms without people coming to my house with torches and pitchforks? :P
Title: Re: The yaml-cpp include dilemma
Post by: luciderous on March 05, 2012, 08:51:23 am
Since, unfortunately, I am rather dormant in terms of active OSX build management - I will concur to whatever decision you stick to :)
However, this doesn't mean we won't go back to this issue later, if it turns out problematic, but for now the actual development should take top priority.