Add DOWNLOAD_RUBY option to Ruby plugin cmake, defaulting to ON

If DOWNLOAD_RUBY is set to OFF, the build will not attempt to download
a prebuilt libruby.so and not fire a warning that one is not present.
This may be desired if one wants to link dfhack against a newer system
libruby.so, now that dfhack supports ruby 2.x and also supports linking
against system libruby (at least, on Linux), as per the following commit:

df9b5bca73

This also allows the dfhack build to proceed without network access
(once all submodules have been fetched), which at least some Linux
distributions, like Fedora, require.

By default DOWNLOAD_RUBY is set to ON, so this should not change
the behavior of default builds.

I tested that when DOWNLOAD_RUBY is set to OFF, dfhack still launches
and that the Ruby plugin still functions, e.g. by running
```rb_eval puts('Hello world.')``` in the dfhack console.
develop
Ben Rosser 2017-01-20 17:16:19 -05:00
parent e2fc7d3e00
commit f0d4a1f563
1 changed files with 56 additions and 48 deletions

@ -1,3 +1,8 @@
# Allow build system to turn off downloading of libruby.so.
OPTION(DOWNLOAD_RUBY "Download prebuilt libruby.so for ruby plugin." ON)
IF (DOWNLOAD_RUBY)
IF (APPLE)
SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib)
SET(RUBYLIB_INSTALL_NAME "libruby.dylib")
@ -49,6 +54,8 @@ ELSE()
ENDIF()
ENDIF()
ENDIF()
IF (APPLE OR UNIX)
SET(RUBYAUTOGEN ruby-autogen-gcc.rb)
ELSE (APPLE OR UNIX)
@ -73,7 +80,8 @@ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
IF(EXISTS ${RUBYLIB})
INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME})
ELSE()
IF(NOT(APPLE AND ${DFHACK_BUILD_ARCH} STREQUAL 64))
# Only fire this warning if DOWNLOAD_RUBY was set.
IF(NOT(APPLE AND ${DFHACK_BUILD_ARCH} STREQUAL 64) AND DOWNLOAD_RUBY)
MESSAGE(WARNING "Ruby library not found at ${RUBYLIB} - will not be installed")
ENDIF()
ENDIF()