[cmake-developers] [CMake 0015345]: FindRuby: Problem with "find_package(Ruby 2.0)"

Mantis Bug Tracker mantis at public.kitware.com
Mon Jan 12 07:43:41 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15345 
====================================================================== 
Reported By:                David Coppa
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15345
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-01-12 07:43 EST
Last Modified:              2015-01-12 07:43 EST
====================================================================== 
Summary:                    FindRuby: Problem with "find_package(Ruby 2.0)"
Description: 
OS is OpenBSD, but I think this also applies to Linux or other Unix-like OSes.
Both ruby-2.0.0 and ruby-2.1.5 are installed on the system:

$ ls -1 /usr/local/bin/ruby*
/usr/local/bin/ruby20
/usr/local/bin/ruby21

Using "find_package(Ruby 2.1)" works as expected:

-- ATTENTION -> Ruby_FIND_VERSION_MINOR == 1
-- ATTENTION -> setting Ruby_FIND_VERSION_SHORT_NODOT...
-- --------FindRuby.cmake debug------------
-- _RUBY_POSSIBLE_EXECUTABLE_NAMES:
ruby2.1;ruby21;ruby;ruby2.0;ruby20;ruby1.9;ruby19;ruby1.8;ruby18
-- _RUBY_POSSIBLE_LIB_NAMES: ruby;ruby-static;ruby2.1;ruby21;ruby-2.1;ruby-2.1.0
-- RUBY_ARCH_DIR: /usr/local/lib/ruby/2.1/x86_64-openbsd
-- RUBY_HDR_DIR: /usr/local/include/ruby-2.1
-- RUBY_POSSIBLE_LIB_DIR: /usr/local/lib
-- Found RUBY_VERSION: "2.1.0" , short: "2.1", nodot: "21"
-- _RUBY_REQUIRED_VARS:
RUBY_EXECUTABLE;RUBY_INCLUDE_DIR;RUBY_LIBRARY;RUBY_CONFIG_INCLUDE_DIR
-- RUBY_EXECUTABLE: /usr/local/bin/ruby21
-- RUBY_LIBRARY: /usr/local/lib/libruby21.so.1.0
-- RUBY_INCLUDE_DIR: /usr/local/include/ruby-2.1
-- RUBY_CONFIG_INCLUDE_DIR: /usr/local/include/ruby-2.1/x86_64-openbsd
-- --------------------
-- Found Ruby: /usr/local/bin/ruby21 (found suitable version "2.1.0", minimum
required is "2.1")

** NOTE: I've added some messages to help understand the problem and set
_RUBY_DEBUG_OUTPUT to true.

While "find_package(Ruby 2.0)" is broken:

-- ATTENTION -> Ruby_FIND_VERSION_MINOR == 0
-- --------FindRuby.cmake debug------------
-- _RUBY_POSSIBLE_EXECUTABLE_NAMES:
ruby;ruby2.1;ruby21;ruby2.0;ruby20;ruby1.9;ruby19;ruby1.8;ruby18
-- _RUBY_POSSIBLE_LIB_NAMES: ruby;ruby-static;ruby2.1;ruby21;ruby-2.1;ruby-2.1.0
-- RUBY_ARCH_DIR: /usr/local/lib/ruby/2.1/x86_64-openbsd
-- RUBY_HDR_DIR: /usr/local/include/ruby-2.1
-- RUBY_POSSIBLE_LIB_DIR: /usr/local/lib
-- Found RUBY_VERSION: "2.1.0" , short: "2.1", nodot: "21"
-- _RUBY_REQUIRED_VARS:
RUBY_EXECUTABLE;RUBY_INCLUDE_DIR;RUBY_LIBRARY;RUBY_CONFIG_INCLUDE_DIR
-- RUBY_EXECUTABLE: /usr/local/bin/ruby21
-- RUBY_LIBRARY: /usr/local/lib/libruby21.so.1.0
-- RUBY_INCLUDE_DIR: /usr/local/include/ruby-2.1
-- RUBY_CONFIG_INCLUDE_DIR: /usr/local/include/ruby-2.1/x86_64-openbsd
-- --------------------
-- Found Ruby: /usr/local/bin/ruby21 (found suitable version "2.1.0", minimum
required is "2.0")

This is because, when "Ruby_FIND_VERSION_MINOR" is 0, the
"if(Ruby_FIND_VERSION_MAJOR  AND  Ruby_FIND_VERSION_MINOR)" check at line 61
evaluates to false.

Changing line 61 to:

"if(DEFINED Ruby_FIND_VERSION_MAJOR AND DEFINED Ruby_FIND_VERSION_MINOR)"

works around the issue for me:

-- ATTENTION -> Ruby_FIND_VERSION_MINOR == 0
-- ATTENTION -> setting Ruby_FIND_VERSION_SHORT_NODOT ...
-- --------FindRuby.cmake debug------------
-- _RUBY_POSSIBLE_EXECUTABLE_NAMES:
ruby2.0;ruby20;ruby;ruby2.1;ruby21;ruby1.9;ruby19;ruby1.8;ruby18
-- _RUBY_POSSIBLE_LIB_NAMES: ruby;ruby-static;ruby2.0;ruby20;ruby-2.0;ruby-2.0.0
-- RUBY_ARCH_DIR: /usr/local/lib/ruby/2.0/x86_64-openbsd
-- RUBY_HDR_DIR: /usr/local/include/ruby-2.0
-- RUBY_POSSIBLE_LIB_DIR: /usr/local/lib
-- Found RUBY_VERSION: "2.0.0" , short: "2.0", nodot: "20"
-- _RUBY_REQUIRED_VARS:
RUBY_EXECUTABLE;RUBY_INCLUDE_DIR;RUBY_LIBRARY;RUBY_CONFIG_INCLUDE_DIR
-- RUBY_EXECUTABLE: /usr/local/bin/ruby20
-- RUBY_LIBRARY: /usr/local/lib/libruby20.so.1.0
-- RUBY_INCLUDE_DIR: /usr/local/include/ruby-2.0
-- RUBY_CONFIG_INCLUDE_DIR: /usr/local/include/ruby-2.0/x86_64-openbsd
-- --------------------
-- Found Ruby: /usr/local/bin/ruby20 (found suitable version "2.0.0", minimum
required is "2.0")



Steps to Reproduce: 
Use "find_package(Ruby 2.0)" or "find_package(Ruby 2.0 EXACT)"

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-01-12 07:43 David Coppa    New Issue                                    
======================================================================



More information about the cmake-developers mailing list