Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified cmake target name for Ruby interfaces #285

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/ruby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,35 @@ if (RUBY_FOUND)

# Turn on c++
set_source_files_properties(${swig_i_files} ruby.i PROPERTIES CPLUSPLUS ON)
set(SWIG_RB_LIB rbmath)
set(SWIG_RB_LIB_OUTPUT math)

# Create the ruby library

set(CMAKE_SWIG_OUTDIR "${CMAKE_BINARY_DIR}/lib/ruby")
if(CMAKE_VERSION VERSION_GREATER 3.8.0)
SWIG_ADD_LIBRARY(math LANGUAGE ruby SOURCES ruby.i ${swig_i_files})
SWIG_ADD_LIBRARY(${SWIG_RB_LIB} LANGUAGE ruby SOURCES ruby.i ${swig_i_files})
else()
SWIG_ADD_MODULE(math ruby ruby.i ${swig_i_files})
SWIG_ADD_MODULE(${SWIG_RB_LIB} ruby ruby.i ${swig_i_files})
endif()

# Suppress warnings on SWIG-generated files
target_compile_options(math PRIVATE
target_compile_options(${SWIG_RB_LIB} PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wno-pedantic -Wno-shadow -Wno-maybe-uninitialized -Wno-unused-parameter>
$<$<CXX_COMPILER_ID:Clang>:-Wno-shadow -Wno-maybe-uninitialized -Wno-unused-parameter>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-shadow -Wno-maybe-uninitialized -Wno-unused-parameter>
)
target_include_directories(math SYSTEM PUBLIC ${RUBY_INCLUDE_DIRS})
target_include_directories(${SWIG_RB_LIB} SYSTEM PUBLIC ${RUBY_INCLUDE_DIRS})

SWIG_LINK_LIBRARIES(math
SWIG_LINK_LIBRARIES(${SWIG_RB_LIB}
${RUBY_LIBRARY}
ignition-math${PROJECT_VERSION_MAJOR}
)
target_compile_features(math PUBLIC ${IGN_CXX_${c++standard}_FEATURES})
target_compile_features(${SWIG_RB_LIB} PUBLIC ${IGN_CXX_${c++standard}_FEATURES})

set_target_properties(${SWIG_RB_LIB}
PROPERTIES
OUTPUT_NAME ${SWIG_RB_LIB_OUTPUT}
)

if(USE_SYSTEM_PATHS_FOR_RUBY_INSTALLATION)
execute_process(
Expand All @@ -72,12 +78,16 @@ if (RUBY_FOUND)
set(IGN_RUBY_INSTALL_PATH ${IGN_LIB_INSTALL_DIR}/ruby)
endif()
set(IGN_RUBY_INSTALL_PATH "${IGN_RUBY_INSTALL_PATH}/ignition")
install(TARGETS math DESTINATION ${IGN_RUBY_INSTALL_PATH})
install(TARGETS ${SWIG_RB_LIB} DESTINATION ${IGN_RUBY_INSTALL_PATH})

# Add the ruby tests
set(_env_vars)
list(APPEND _env_vars "LD_LIBRARY_PATH=${FAKE_INSTALL_PREFIX}/lib:$ENV{LD_LIBRARY_PATH}")
foreach (test ${ruby_tests})
add_test(NAME ${test}.rb COMMAND
ruby -I${CMAKE_BINARY_DIR}/lib ${CMAKE_SOURCE_DIR}/src/ruby/${test}.rb
ruby -I${FAKE_INSTALL_PREFIX}/lib/ruby/ignition ${CMAKE_SOURCE_DIR}/src/ruby/${test}.rb
--gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/${test}rb.xml)
set_tests_properties(${test}.rb PROPERTIES
ENVIRONMENT "${_env_vars}")
endforeach()
endif()