mruby/mruby — pull request #192 by mitchblank (2012-05-24 07:12:07+00:00)
Title: cmake updates to support older versions

The original version of the CMakeLists.txt files only worked with the very
latest version of cmake (2.8.8) On the systems I work on there is a mix
of cmake 2.4.6 and cmake 2.6.4, and for various reasons it's not easy for
me to update. Therefore I thought I'd make them a little more portable

* Compute a ${CMAKE_VER} string which is in the form "002006004" for 2.6.4,
so we can easily use STRLESS/STRGREATER to compare them. Newer cmake has
a VERSION_LESS comparison predicate but that isn't portable to these older
versions

* Use the horrid if()/else()/endif() syntax where you repeat the stanza
in each item. For example, instead of:
if(foo)
...
else()
...
endif()
You have to say:
if(foo)
...
else(foo)
...
endif(foo)

It's ugly, but only a minor annoyance.

* add_library(...OBJECT...) is only available in the very newest cmake (2.8.8)
It's very handy though since it avoids having to recompile all of the .c
files to put them into two separate libraries. If we're using an older
cmake just work around this by making two separate STATIC libraries which
is a little slower but works fine.

* Avoid add_library(...STATIC EXCLUDE_FROM_ALL...) on 2.4.6 to workaround
a bug

* cmake older than 2.6 doesn't support cross-compiling, so make sure
it's off

* don't use INSTALL(DIRECTORY ... FILES_MATCHING PATTERN ...)

* For add_custom_command(), cmake prior to 2.6 needed you to specify
the exact path to the binary (which you can get from get_target_property)
Starting in 2.6, this pattern was deprecated so when using the
newer tools still have cmake figure it out for itself