summaryrefslogtreecommitdiff
path: root/Tests/UseSWIG
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-04-17 12:23:15 +0200
committerMarc Chevrier <marc.chevrier@gmail.com>2019-05-03 18:20:17 +0200
commite3919bae17d3442e18b5ec1f4a1ae994c87c455b (patch)
tree466c72ae4938936780a97c37d8234123f4fa2767 /Tests/UseSWIG
parent186ca170da51d64a50bb15bfd067ca9b4c987327 (diff)
downloadcmake-e3919bae17d3442e18b5ec1f4a1ae994c87c455b.tar.gz
UseSWIG: Manage alternate library name
Manage alternate library name by passing -interface <library_name> for python language or -dllimport <library_name> for CSharp language to the SWIG compiler. Fixes: #18771
Diffstat (limited to 'Tests/UseSWIG')
-rw-r--r--Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt35
-rw-r--r--Tests/UseSWIG/CMakeLists.txt12
2 files changed, 47 insertions, 0 deletions
diff --git a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt
new file mode 100644
index 0000000000..a2c239cbde
--- /dev/null
+++ b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 3.14...3.15)
+
+project(TestAlternateLibraryName CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+swig_add_library(example_python
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example_python PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
+target_link_libraries(example_python PRIVATE Python2::Python)
+
+
+add_test (NAME AlternateLibraryName.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example_python>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
index 434895e1b8..3cc910fecf 100644
--- a/Tests/UseSWIG/CMakeLists.txt
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -123,3 +123,15 @@ add_test(NAME UseSWIG.SwigSrcFileExtension COMMAND
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+
+
+add_test(NAME UseSWIG.AlternateLibraryName COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/AlternateLibraryName"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/AlternateLibraryName"
+ ${build_generator_args}
+ --build-project TestAlternateLibraryName
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )