From da05ceb1e3d1129fd66b8c840bdf28c41f9149ca Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Wed, 30 Aug 2023 08:34:50 +0200 Subject: [PATCH] swig: Fix linking targets to dependencies - perl5: add missing linking against `${PERL_LIBRARY}` - ruby: fix linking, replace `${RUBY_LIBRARIES}` with `${RUBY_LIBRARY}` `${RUBY_LIBRARY}` and `${Ruby_LIBRARIES}` can be used - same meaning. - use `target_link_libraries` instead of deprecated `swig_link_libraries` `swig_link_libraries` has been deprecated since cmake 3.13 --- bindings/go/CMakeLists.txt | 2 +- bindings/perl5/CMakeLists.txt | 3 ++- bindings/python3/CMakeLists.txt | 4 ++-- bindings/ruby/CMakeLists.txt | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/go/CMakeLists.txt b/bindings/go/CMakeLists.txt index ac4800b13..c2e98eb7b 100644 --- a/bindings/go/CMakeLists.txt +++ b/bindings/go/CMakeLists.txt @@ -17,7 +17,7 @@ function(add_go_module LIBRARY_NAME MODULE_NAME) target_compile_options(${TARGET_NAME} PUBLIC ${SWIG_COMPILE_OPTIONS}) string(REPLACE "_" "-" C_LIBRARY_NAME ${LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${C_LIBRARY_NAME}) + target_link_libraries(${TARGET_NAME} PRIVATE ${C_LIBRARY_NAME}) endfunction() diff --git a/bindings/perl5/CMakeLists.txt b/bindings/perl5/CMakeLists.txt index af8c8fbcf..1419b1848 100644 --- a/bindings/perl5/CMakeLists.txt +++ b/bindings/perl5/CMakeLists.txt @@ -74,7 +74,8 @@ function(add_perl5_module LIBRARY_NAME MODULE_NAME) target_compile_options(${TARGET_NAME} PUBLIC ${SWIG_COMPILE_OPTIONS}) string(REPLACE "_" "-" C_LIBRARY_NAME ${LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${C_LIBRARY_NAME}) + target_link_libraries(${TARGET_NAME} PRIVATE ${C_LIBRARY_NAME}) + target_link_libraries(${TARGET_NAME} PRIVATE ${PERL_LIBRARY}) install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION "${PERL_INSTALL_PATH}/auto/${LIBRARY_NAME}/${MODULE_NAME}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}.pm" DESTINATION "${PERL_INSTALL_PATH}/${LIBRARY_NAME}") diff --git a/bindings/python3/CMakeLists.txt b/bindings/python3/CMakeLists.txt index a874cf853..b45f47ad8 100644 --- a/bindings/python3/CMakeLists.txt +++ b/bindings/python3/CMakeLists.txt @@ -41,8 +41,8 @@ function(add_python3_module LIBRARY_NAME MODULE_NAME) target_compile_options(${TARGET_NAME} PUBLIC ${SWIG_COMPILE_OPTIONS}) string(REPLACE "_" "-" C_LIBRARY_NAME ${LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${C_LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${Python3_LIBRARIES}) + target_link_libraries(${TARGET_NAME} PRIVATE ${C_LIBRARY_NAME}) + target_link_libraries(${TARGET_NAME} PRIVATE ${Python3_LIBRARIES}) # generate a dist-info for the library (redundantly created for multi-module packages, oh well...) set(DISTINFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}-${CMAKE_PROJECT_VERSION}.dist-info") diff --git a/bindings/ruby/CMakeLists.txt b/bindings/ruby/CMakeLists.txt index 9776f55f5..6d99ebc0d 100644 --- a/bindings/ruby/CMakeLists.txt +++ b/bindings/ruby/CMakeLists.txt @@ -22,8 +22,8 @@ function(add_ruby_module LIBRARY_NAME MODULE_NAME) target_compile_options(${TARGET_NAME} PUBLIC ${SWIG_COMPILE_OPTIONS}) string(REPLACE "_" "-" C_LIBRARY_NAME ${LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${C_LIBRARY_NAME}) - swig_link_libraries(${TARGET_NAME} ${RUBY_LIBRARIES}) + target_link_libraries(${TARGET_NAME} PRIVATE ${C_LIBRARY_NAME}) + target_link_libraries(${TARGET_NAME} PRIVATE ${RUBY_LIBRARY}) install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION "${RUBY_VENDORARCH_DIR}/${LIBRARY_NAME}") endfunction()