[CMake] Using CMake with SWIG and Ruby

Dev Guy devguy.ca at gmail.com
Tue Apr 10 21:52:57 EDT 2012


Hi Guy, with all my searching and reading I've have not been able to
find a way to build a Ruby extension using SWIG with CMake. Here is my
CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(RUBY_WRAPPER)

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(Ruby)

INCLUDE_DIRECTORIES(${RUBY_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

SET(CMAKE_SWIG_FLAGS "-c++")

SET_SOURCE_FILES_PROPERTIES(person.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(person.i PROPERTIES SWIG_FLAGS "-includeall")

SWIG_ADD_MODULE(person ruby person.i person.cpp)
SWIG_LINK_LIBRARIES(person ${RUBY_LIBRARY})

When I type make, I get the following error:

[ 33%] Swig source
/home/yadav/dev/cpp/swig_example/person.h:19: Error: Unable to find
'string'
make[2]: *** [personRUBY_wrap.cxx] Error 1
make[1]: *** [CMakeFiles/person.dir/all] Error 2
make: *** [all] Error 2

-- 
Kind Regards,
Rajinder Yadav

SafetyNet Test Driven Development
http://safetynet.devmentor.org


More information about the CMake mailing list