summaryrefslogtreecommitdiff
path: root/Tests/UseSWIG
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2020-03-19 01:04:30 +0900
committerbiao716.wang <biao716.wang@samsung.com>2020-03-19 01:04:30 +0900
commit1d6613f4446f69f63beddf2d97c201154fb35e33 (patch)
treef32eae75900a0df14ab8fa1e2bd436af159ef91d /Tests/UseSWIG
parentaabcd8e66e3268a232efe2e416635d5b6bf84ad5 (diff)
downloadcmake-1d6613f4446f69f63beddf2d97c201154fb35e33.tar.gz
cmake-1d6613f4446f69f63beddf2d97c201154fb35e33.tar.bz2
cmake-1d6613f4446f69f63beddf2d97c201154fb35e33.zip
Imported Upstream version 3.16.4upstream/3.16.4
Change-Id: Ic5262ea6c0872b353ea2dc35fe1e944063ae8409 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
Diffstat (limited to 'Tests/UseSWIG')
-rw-r--r--Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt35
-rw-r--r--Tests/UseSWIG/BasicConfiguration.cmake83
-rw-r--r--Tests/UseSWIG/BasicCsharp/CMakeLists.txt21
-rw-r--r--Tests/UseSWIG/BasicPerl/CMakeLists.txt14
-rw-r--r--Tests/UseSWIG/BasicPython/CMakeLists.txt13
-rw-r--r--Tests/UseSWIG/CMakeLists.txt137
-rw-r--r--Tests/UseSWIG/LegacyConfiguration.cmake68
-rw-r--r--Tests/UseSWIG/LegacyPerl/CMakeLists.txt14
-rw-r--r--Tests/UseSWIG/LegacyPython/CMakeLists.txt13
-rw-r--r--Tests/UseSWIG/ModuleName/CMakeLists.txt42
-rw-r--r--Tests/UseSWIG/ModuleName/example.i9
-rw-r--r--Tests/UseSWIG/ModuleName/runme.py52
-rw-r--r--Tests/UseSWIG/ModuleVersion2/CMakeLists.txt56
-rw-r--r--Tests/UseSWIG/MultipleModules/CMakeLists.txt68
-rw-r--r--Tests/UseSWIG/MultiplePython/CMakeLists.txt59
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt28
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/my_add.i9
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg9
-rwxr-xr-xTests/UseSWIG/SwigSrcFileExtension/runme.py24
-rw-r--r--Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt45
-rw-r--r--Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i9
-rw-r--r--Tests/UseSWIG/example.cxx33
-rw-r--r--Tests/UseSWIG/example.h37
-rw-r--r--Tests/UseSWIG/example.i9
-rw-r--r--Tests/UseSWIG/runme.cs54
-rw-r--r--Tests/UseSWIG/runme.php458
-rw-r--r--Tests/UseSWIG/runme.pike53
-rw-r--r--Tests/UseSWIG/runme.pl56
-rw-r--r--Tests/UseSWIG/runme.py52
-rw-r--r--Tests/UseSWIG/runme.rb49
-rw-r--r--Tests/UseSWIG/runme.tcl49
-rw-r--r--Tests/UseSWIG/runme2.tcl69
32 files changed, 1327 insertions, 0 deletions
diff --git a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt
new file mode 100644
index 000000000..a2c239cbd
--- /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/BasicConfiguration.cmake b/Tests/UseSWIG/BasicConfiguration.cmake
new file mode 100644
index 000000000..fd3ac4031
--- /dev/null
+++ b/Tests/UseSWIG/BasicConfiguration.cmake
@@ -0,0 +1,83 @@
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(SWIG_LANG_TYPE)
+unset(SWIG_LANG_INCLUDE_DIRECTORIES)
+unset(SWIG_LANG_DEFINITIONS)
+unset(SWIG_LANG_OPTIONS)
+unset(SWIG_LANG_LIBRARIES)
+
+if(${language} MATCHES csharp)
+ set(SWIG_LANG_TYPE TYPE SHARED)
+endif()
+if(${language} MATCHES python)
+ find_package(Python REQUIRED COMPONENTS Interpreter Development)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${Python_INCLUDE_DIRS})
+ set(SWIG_LANG_LIBRARIES ${Python_LIBRARIES})
+endif()
+if(${language} MATCHES perl)
+ find_package(Perl REQUIRED)
+ find_package(PerlLibs REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH})
+ separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+ set(SWIG_LANG_OPTIONS ${c_flags})
+ set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY})
+endif()
+if(${language} MATCHES tcl)
+ find_package(TCL REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${TCL_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY})
+endif()
+if(${language} MATCHES ruby)
+ find_package(Ruby REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${RUBY_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY})
+endif()
+if(${language} MATCHES php4)
+ find_package(PHP4 REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PHP4_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY})
+endif()
+if(${language} MATCHES pike)
+ find_package(Pike REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PIKE_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY})
+endif()
+if(${language} MATCHES lua)
+ find_package(Lua REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR})
+ set(SWIG_LANG_TYPE TYPE SHARED)
+ set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES})
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set (CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES ${SWIG_LANG_INCLUDE_DIRECTORIES}
+ "${CMAKE_CURRENT_LIST_DIR}")
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_COMPILE_DEFINITIONS ${SWIG_LANG_DEFINITIONS})
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_COMPILE_OPTIONS ${SWIG_LANG_OPTIONS})
+
+
+SWIG_ADD_LIBRARY(example
+ LANGUAGE "${language}"
+ ${SWIG_LANG_TYPE}
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ "${CMAKE_CURRENT_LIST_DIR}/example.cxx")
+TARGET_INCLUDE_DIRECTORIES(example PUBLIC ${CMAKE_CURRENT_LIST_DIR})
+TARGET_LINK_LIBRARIES(example PRIVATE ${SWIG_LANG_LIBRARIES})
diff --git a/Tests/UseSWIG/BasicCsharp/CMakeLists.txt b/Tests/UseSWIG/BasicCsharp/CMakeLists.txt
new file mode 100644
index 000000000..1a6c763b5
--- /dev/null
+++ b/Tests/UseSWIG/BasicCsharp/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.12...3.13)
+
+project(TestBasicCsharp CXX CSharp)
+
+include(CTest)
+
+set(language "csharp")
+
+include (../BasicConfiguration.cmake)
+
+set_source_files_properties(Square.cs Circle.cs Shape.cs PROPERTIES GENERATED 1)
+add_library(example_cs SHARED $<TARGET_PROPERTY:example,SWIG_SUPPORT_FILES> Square.cs Circle.cs Shape.cs)
+set_target_properties(example_cs PROPERTIES LINKER_LANGUAGE CSharp)
+target_link_libraries(example_cs example)
+
+add_executable(runme ${CMAKE_CURRENT_SOURCE_DIR}/../runme.cs)
+target_link_libraries(runme example_cs)
+set_target_properties(runme PROPERTIES LINKER_LANGUAGE CSharp)
+
+add_test (NAME BasicCsharp
+ COMMAND $<TARGET_FILE:runme>)
diff --git a/Tests/UseSWIG/BasicPerl/CMakeLists.txt b/Tests/UseSWIG/BasicPerl/CMakeLists.txt
new file mode 100644
index 000000000..cf02de7de
--- /dev/null
+++ b/Tests/UseSWIG/BasicPerl/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestBasicPerl CXX)
+
+include(CTest)
+
+set(language "perl")
+
+include (../BasicConfiguration.cmake)
+
+add_test (NAME BasicPerl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
+ "-I$<TARGET_FILE_DIR:example>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/BasicPython/CMakeLists.txt b/Tests/UseSWIG/BasicPython/CMakeLists.txt
new file mode 100644
index 000000000..8bbd1cbe8
--- /dev/null
+++ b/Tests/UseSWIG/BasicPython/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestBasicPython CXX)
+
+include(CTest)
+
+set(language "python")
+
+include (../BasicConfiguration.cmake)
+
+add_test (NAME BasicPython
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example>"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
new file mode 100644
index 000000000..3cc910fec
--- /dev/null
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -0,0 +1,137 @@
+add_test(NAME UseSWIG.LegacyPython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPython"
+ ${build_generator_args}
+ --build-project TestLegacyPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.LegacyPerl COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPerl"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPerl"
+ ${build_generator_args}
+ --build-project TestLegacyPerl
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+include(CheckLanguage)
+check_language(CSharp)
+if (CMAKE_CSharp_COMPILER)
+ add_test(NAME UseSWIG.BasicCsharp COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicCsharp"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicCsharp"
+ ${build_generator_args}
+ --build-project TestBasicCsharp
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+endif()
+
+add_test(NAME UseSWIG.BasicPython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython"
+ ${build_generator_args}
+ --build-project TestBasicPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.BasicPerl COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl"
+ ${build_generator_args}
+ --build-project TestBasicPerl
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.MultipleModules COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleModules"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleModules"
+ ${build_generator_args}
+ --build-project TestMultipleModules
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.MultiplePython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython"
+ ${build_generator_args}
+ --build-project TestMultiplePython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.ModuleVersion2 COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleVersion2"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleVersion2"
+ ${build_generator_args}
+ --build-project TestModuleVersion2
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.UseTargetINCLUDE_DIRECTORIES COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
+ ${build_generator_args}
+ --build-project TestUseTargetINCLUDE_DIRECTORIES
+ --build-options ${build_options}
+ )
+
+
+add_test(NAME UseSWIG.ModuleName COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleName"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleName"
+ ${build_generator_args}
+ --build-project TestModuleName
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.SwigSrcFileExtension COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/SwigSrcFileExtension"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/SwigSrcFileExtension"
+ ${build_generator_args}
+ --build-project SwigSrcFileExtension
+ --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>
+ )
diff --git a/Tests/UseSWIG/LegacyConfiguration.cmake b/Tests/UseSWIG/LegacyConfiguration.cmake
new file mode 100644
index 000000000..1acc05a4d
--- /dev/null
+++ b/Tests/UseSWIG/LegacyConfiguration.cmake
@@ -0,0 +1,68 @@
+
+# Prevent deprecated warnings from new UseSWIG module
+set (CMAKE_WARN_DEPRECATED FALSE)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(SWIG_LANG_TYPE)
+if(${language} MATCHES python)
+ find_package(PythonInterp REQUIRED)
+ find_package(PythonLibs REQUIRED)
+ include_directories(${PYTHON_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES})
+endif()
+if(${language} MATCHES perl)
+ find_package(Perl REQUIRED)
+ find_package(PerlLibs REQUIRED)
+ include_directories(${PERL_INCLUDE_PATH})
+ separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+ add_compile_options(${c_flags})
+ set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY})
+endif()
+if(${language} MATCHES tcl)
+ find_package(TCL REQUIRED)
+ include_directories(${TCL_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY})
+endif()
+if(${language} MATCHES ruby)
+ find_package(Ruby REQUIRED)
+ include_directories(${RUBY_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY})
+endif()
+if(${language} MATCHES php4)
+ find_package(PHP4 REQUIRED)
+ include_directories(${PHP4_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY})
+endif()
+if(${language} MATCHES pike)
+ find_package(Pike REQUIRED)
+ include_directories(${PIKE_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY})
+endif()
+if(${language} MATCHES lua)
+ find_package(Lua REQUIRED)
+ include_directories(${LUA_INCLUDE_DIR})
+ set(SWIG_LANG_TYPE TYPE SHARED)
+ set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES})
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+include_directories(${CMAKE_CURRENT_LIST_DIR})
+
+set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES CPLUSPLUS ON)
+set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES SWIG_FLAGS "-includeall")
+SWIG_ADD_LIBRARY(example
+ LANGUAGE "${language}"
+ ${SWIG_LANG_TYPE}
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ "${CMAKE_CURRENT_LIST_DIR}/example.cxx")
+SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES})
diff --git a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt
new file mode 100644
index 000000000..90d92f4eb
--- /dev/null
+++ b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestLegacyPerl CXX)
+
+include(CTest)
+
+set(language "perl")
+
+include (../LegacyConfiguration.cmake)
+
+add_test (NAME LegacyPerl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
+ "-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/LegacyPython/CMakeLists.txt b/Tests/UseSWIG/LegacyPython/CMakeLists.txt
new file mode 100644
index 000000000..03facb19a
--- /dev/null
+++ b/Tests/UseSWIG/LegacyPython/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestLegacyPython CXX)
+
+include(CTest)
+
+set(language "python")
+
+include (../LegacyConfiguration.cmake)
+
+add_test (NAME LegacyPython
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
+ "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/ModuleName/CMakeLists.txt b/Tests/UseSWIG/ModuleName/CMakeLists.txt
new file mode 100644
index 000000000..435b441a4
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.1...3.14)
+
+project(TestModuleName CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+cmake_policy(SET CMP0086 NEW)
+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 "example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall)
+set_property(SOURCE "example.i" PROPERTY SWIG_MODULE_NAME new_example)
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
+ OUTPUT_NAME new_example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+
+add_test (NAME ModuleName.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py")
diff --git a/Tests/UseSWIG/ModuleName/example.i b/Tests/UseSWIG/ModuleName/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/ModuleName/runme.py b/Tests/UseSWIG/ModuleName/runme.py
new file mode 100644
index 000000000..c37e4a736
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import new_example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = new_example.Circle(10)
+print (" Created circle", c)
+s = new_example.Square(10)
+print (" Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", new_example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print (" Circle = (%f, %f)" % (c.x,c.y))
+print (" Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+ print (" ", o)
+ print (" area = ", o.area())
+ print (" perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (new_example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")
diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
new file mode 100644
index 000000000..093e8582c
--- /dev/null
+++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
@@ -0,0 +1,56 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestModuleVersion2 CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+if (WIN32)
+ set (PS $<SEMICOLON>)
+else()
+ set (PS ":")
+endif()
+
+set (UseSWIG_MODULE_VERSION 2)
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+# re-use sample interface file for another plugin
+swig_add_library(example2
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3")
+target_link_libraries(example2 PRIVATE Python3::Module)
+
+
+add_test (NAME ModuleVersion2.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+add_test (NAME ModuleVersion2.example2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>"
+ "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
new file mode 100644
index 000000000..4380080f5
--- /dev/null
+++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
@@ -0,0 +1,68 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestMultipleModules CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python REQUIRED COMPONENTS Interpreter Development)
+
+find_package(Perl REQUIRED)
+find_package(PerlLibs REQUIRED)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python")
+target_link_libraries(example1 PRIVATE Python::Module)
+
+# re-use sample interface file for another plugin
+set_property(SOURCE "../example.i" APPEND PROPERTY
+ GENERATED_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH})
+separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+set_property(SOURCE "../example.i" PROPERTY GENERATED_COMPILE_OPTIONS ${c_flags})
+
+swig_add_library(example2
+ LANGUAGE perl
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl")
+target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
+
+
+
+add_test (NAME MultipleModules.Python
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+
+add_test (NAME MultipleModules.Perl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ "-I$<TARGET_FILE_DIR:example2>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt
new file mode 100644
index 000000000..cf6c80e28
--- /dev/null
+++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestMultiplePython CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+# re-use sample interface file for another plugin
+swig_add_library(example2
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3")
+target_link_libraries(example2 PRIVATE Python3::Module)
+
+
+
+add_test (NAME MultiplePython.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+add_test (NAME MultiplePython.example2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python3${PS}$<TARGET_FILE_DIR:example2>"
+ "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt
new file mode 100644
index 000000000..f70ce491d
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.1...3.14)
+
+project(SwigSrcFileExtension C)
+
+include(CTest)
+find_package(SWIG REQUIRED)
+find_package(Python COMPONENTS Interpreter Development REQUIRED)
+
+include(${SWIG_USE_FILE})
+
+# Use the newer target name preference
+set(UseSWIG_TARGET_NAME_PREFERENCE "STANDARD")
+
+# Set the custom source file extension to both .i and .swg
+set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg")
+
+# Generate a Python module out of `.i`
+swig_add_library(my_add LANGUAGE python SOURCES my_add.i)
+target_link_libraries(my_add Python::Module)
+
+# Generate a Python module out of `.swg`
+swig_add_library(my_sub LANGUAGE python SOURCES my_sub.swg)
+target_link_libraries(my_sub Python::Module)
+
+# Add a test
+add_test(NAME SwigSrcFileExtension
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py")
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/my_add.i b/Tests/UseSWIG/SwigSrcFileExtension/my_add.i
new file mode 100644
index 000000000..d087ab5e2
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/my_add.i
@@ -0,0 +1,9 @@
+%module my_add
+
+%{
+int add(int a, int b) {
+ return a + b;
+}
+%}
+
+int add(int a, int b);
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg b/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg
new file mode 100644
index 000000000..df34b441a
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg
@@ -0,0 +1,9 @@
+%module my_sub
+
+%{
+int sub(int a, int b) {
+ return a - b;
+}
+%}
+
+int sub(int a, int b);
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/runme.py b/Tests/UseSWIG/SwigSrcFileExtension/runme.py
new file mode 100755
index 000000000..290175b08
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/runme.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import random
+
+import my_add
+import my_sub
+
+
+# These can be changed, but make sure not to overflow `int`
+a = random.randint(1, 1024)
+b = random.randint(1, 1024)
+
+if my_add.add(a, b) == a + b:
+ print ("Test 1 Passed for SWIG custom source file extension")
+else:
+ print ("Test 1 FAILED for SWIG custom source file extension")
+ exit(1)
+
+if my_sub.sub(a, b) == a - b:
+ print ("Test 2 Passed for SWIG custom source file extension")
+else:
+ print ("Test 2 FAILED for SWIG custom source file extension")
+ exit(1)
diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt
new file mode 100644
index 000000000..80a2e1650
--- /dev/null
+++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestUseTargetINCLUDE_DIRECTORIES CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
+ OUTPUT_NAME example1
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1")
+target_link_libraries(example1 PRIVATE Python3::Module)
+
+
+# Check that source property override target property
+set_property(SOURCE "example.i" PROPERTY USE_TARGET_INCLUDE_DIRECTORIES TRUE)
+
+swig_add_library(example2
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES FALSE
+ OUTPUT_NAME example2
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2")
+target_link_libraries(example2 PRIVATE Python3::Module)
diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/example.cxx b/Tests/UseSWIG/example.cxx
new file mode 100644
index 000000000..961d6dd9a
--- /dev/null
+++ b/Tests/UseSWIG/example.cxx
@@ -0,0 +1,33 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy)
+{
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void)
+{
+ return M_PI * radius * radius;
+}
+
+double Circle::perimeter(void)
+{
+ return 2 * M_PI * radius;
+}
+
+double Square::area(void)
+{
+ return width * width;
+}
+
+double Square::perimeter(void)
+{
+ return 4 * width;
+}
diff --git a/Tests/UseSWIG/example.h b/Tests/UseSWIG/example.h
new file mode 100644
index 000000000..366deb044
--- /dev/null
+++ b/Tests/UseSWIG/example.h
@@ -0,0 +1,37 @@
+/* File : example.h */
+
+class Shape
+{
+public:
+ Shape() { nshapes++; }
+ virtual ~Shape() { nshapes--; };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape
+{
+private:
+ double radius;
+
+public:
+ Circle(double r)
+ : radius(r){};
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape
+{
+private:
+ double width;
+
+public:
+ Square(double w)
+ : width(w){};
+ virtual double area(void);
+ virtual double perimeter(void);
+};
diff --git a/Tests/UseSWIG/example.i b/Tests/UseSWIG/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/runme.cs b/Tests/UseSWIG/runme.cs
new file mode 100644
index 000000000..f0c1bd220
--- /dev/null
+++ b/Tests/UseSWIG/runme.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+
+public class runme
+{
+ static void Main()
+ {
+ // ----- Object creation -----
+
+ Console.WriteLine("Creating some objects:");
+ Circle c = new Circle(10);
+ Console.WriteLine(" Created " + c);
+ Square s = new Square(10);
+ Console.WriteLine(" Created " + s);
+
+ // ----- Access a static member -----
+
+ Console.WriteLine("\nA total of " + Shape.nshapes + " shapes were created");
+
+ // ----- Member data access -----
+
+ // Set the location of the object
+
+ c.x = 20;
+ c.y = 30;
+
+ s.x = -10;
+ s.y = 5;
+
+ Console.WriteLine("\nHere is their current position:");
+ Console.WriteLine(" Circle = ({0}, {1})", c.x,c.y);
+ Console.WriteLine(" Square = ({0}, {1})", s.x,s.y);
+
+ // ----- Call some methods -----
+
+ Console.WriteLine("\nHere are some properties of the shapes:");
+ List <Shape> shapeList = new List <Shape> { c,s };
+ foreach(var o in shapeList){
+ Console.WriteLine(" " + o);
+ Console.WriteLine(" area = " + o.area());
+ Console.WriteLine(" perimeter = " + o.perimeter());
+ }
+
+ Console.WriteLine("\nGuess I'll clean up now");
+
+ // Note: this invokes the virtual destructor
+ c.Dispose();
+ s.Dispose();
+
+ s = new Square(10);;
+ Console.WriteLine(Shape.nshapes + " shapes remain");
+ Console.WriteLine("Goodbye");
+ }
+}
diff --git a/Tests/UseSWIG/runme.php4 b/Tests/UseSWIG/runme.php4
new file mode 100644
index 000000000..653ced256
--- /dev/null
+++ b/Tests/UseSWIG/runme.php4
@@ -0,0 +1,58 @@
+<?php
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+require("example.php");
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = new_Circle(10);
+print " Created circle $c\n";
+$s = new_Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of " . nshapes() . " shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+Shape_x_set($c, 20);
+Shape_y_set($c, 30);
+Shape_x_set($s,-10);
+Shape_y_set($s,5);
+
+print "\nHere is their current position:\n";
+print " Circle = (" . Shape_x_get($c) . "," . Shape_y_get($c) . ")\n";
+print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach (array($c,$s) as $o) {
+ print " $o\n";
+ print " area = " . Shape_area($o) . "\n";
+ print " perimeter = " . Shape_perimeter($o) . "\n";
+ }
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+delete_Shape($c);
+delete_Shape($s);
+
+print nshapes() . " shapes remain\n";
+print "Goodbye\n";
+
+?>
diff --git a/Tests/UseSWIG/runme.pike b/Tests/UseSWIG/runme.pike
new file mode 100644
index 000000000..ec28dd70e
--- /dev/null
+++ b/Tests/UseSWIG/runme.pike
@@ -0,0 +1,53 @@
+import .example;
+
+int main()
+{
+ // ----- Object creation -----
+
+ write("Creating some objects:\n");
+ Circle c = Circle(10.0);
+ write(" Created circle.\n");
+ Square s = Square(10.0);
+ write(" Created square.\n");
+
+ // ----- Access a static member -----
+
+ write("\nA total of " + Shape_nshapes_get() + " shapes were created\n");
+
+ // ----- Member data access -----
+
+ // Set the location of the object
+
+ c->x_set(20.0);
+ c->y_set(30.0);
+
+ s->x_set(-10.0);
+ s->y_set(5.0);
+
+ write("\nHere is their current position:\n");
+ write(" Circle = (%f, %f)\n", c->x_get(), c->y_get());
+ write(" Square = (%f, %f)\n", s->x_get(), s->y_get());
+
+ // ----- Call some methods -----
+
+ write("\nHere are some properties of the shapes:\n");
+ write(" The circle:\n");
+ write(" area = %f.\n", c->area());
+ write(" perimeter = %f.\n", c->perimeter());
+ write(" The square:\n");
+ write(" area = %f.\n", s->area());
+ write(" perimeter = %f.\n", s->perimeter());
+
+ write("\nGuess I'll clean up now\n");
+
+ /* See if we can force 's' to be garbage-collected */
+ s = 0;
+
+ /* Now we should be down to only 1 shape */
+ write("%d shapes remain\n", Shape_nshapes_get());
+
+ /* Done */
+ write("Goodbye\n");
+
+ return 0;
+}
diff --git a/Tests/UseSWIG/runme.pl b/Tests/UseSWIG/runme.pl
new file mode 100644
index 000000000..965e06382
--- /dev/null
+++ b/Tests/UseSWIG/runme.pl
@@ -0,0 +1,56 @@
+# file: runme.pl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+use example;
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = examplec::new_Circle(10);
+print " Created circle $c\n";
+$s = examplec::new_Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of $examplec::Shape_nshapes shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+examplec::Shape_x_set($c, 20);
+examplec::Shape_y_set($c, 30);
+examplec::Shape_x_set($s,-10);
+examplec::Shape_y_set($s,5);
+
+print "\nHere is their current position:\n";
+print " Circle = (",examplec::Shape_x_get($c),",", examplec::Shape_y_get($c),")\n";
+print " Square = (",examplec::Shape_x_get($s),",", examplec::Shape_y_get($s),")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach $o ($c,$s) {
+ print " $o\n";
+ print " area = ", examplec::Shape_area($o), "\n";
+ print " perimeter = ", examplec::Shape_perimeter($o), "\n";
+ }
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+examplec::delete_Shape($c);
+examplec::delete_Shape($s);
+
+print $examplec::Shape_nshapes," shapes remain\n";
+print "Goodbye\n";
diff --git a/Tests/UseSWIG/runme.py b/Tests/UseSWIG/runme.py
new file mode 100644
index 000000000..af5e07dc2
--- /dev/null
+++ b/Tests/UseSWIG/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = example.Circle(10)
+print (" Created circle", c)
+s = example.Square(10)
+print (" Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print (" Circle = (%f, %f)" % (c.x,c.y))
+print (" Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+ print (" ", o)
+ print (" area = ", o.area())
+ print (" perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")
diff --git a/Tests/UseSWIG/runme.rb b/Tests/UseSWIG/runme.rb
new file mode 100644
index 000000000..de73bcd46
--- /dev/null
+++ b/Tests/UseSWIG/runme.rb
@@ -0,0 +1,49 @@
+# file: runme.rb
+
+# This file illustrates the C++ interface created by SWIG.
+# All of our C++ classes get converted into Ruby classes.
+
+require 'example'
+
+# ----- Object creation -----
+
+print "Creating some objects:\n"
+c = Example::Circle.new(10)
+print " Created circle #{c}\n"
+s = Example::Square.new(10)
+print " Created square #{s}\n"
+
+# ----- Access a static member -----
+
+print "\nA total of #{Example::Shape.nshapes} shapes were created\n"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+# Notice how we can do this using functions specific to
+# the 'Circle' class.
+c.x = 20
+c.y = 30
+
+# Now use the same functions in the base class
+s.x = -10
+s.y = 5
+
+print "\nHere is their current position:\n"
+print " Circle = (", c.x, ",", c.y, ")\n"
+print " Square = (", s.x, ",", s.y, ")\n"
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n"
+for o in [c, s]
+ print " #{o}\n"
+ print " area = ", o.area, "\n"
+ print " perimeter = ", o.perimeter, "\n"
+end
+# Notice how the Shape#area() and Shape#perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+print "\n", Example::Shape.nshapes," shapes remain\n"
+print "Goodbye\n"
diff --git a/Tests/UseSWIG/runme.tcl b/Tests/UseSWIG/runme.tcl
new file mode 100644
index 000000000..6055cf619
--- /dev/null
+++ b/Tests/UseSWIG/runme.tcl
@@ -0,0 +1,49 @@
+# file: runme.tcl
+
+# This file illustrates the high level C++ interface.
+# In this case C++ classes work kind of like Tk widgets
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+Circle c 10
+puts " Created circle [c cget -this]"
+Square s 10
+puts " Created square [s cget -this]"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c configure -x 20 -y 30
+s configure -x -10 -y 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([c cget -x], [c cget -y])"
+puts " Square = ([s cget -x], [s cget -y])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "c s" {
+ puts " [$o cget -this]"
+ puts " area = [$o area]"
+ puts " perimeter = [$o perimeter]"
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+rename c ""
+rename s ""
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"
diff --git a/Tests/UseSWIG/runme2.tcl b/Tests/UseSWIG/runme2.tcl
new file mode 100644
index 000000000..d0b5c219e
--- /dev/null
+++ b/Tests/UseSWIG/runme2.tcl
@@ -0,0 +1,69 @@
+# file: runme2.tcl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+set c [new_Circle 10]
+puts " Created circle $c"
+set s [new_Square 10]
+puts " Created square $s"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+# Note: the base class must be used since that's where x and y
+# were declared.
+
+Shape_x_set $c 20
+Shape_y_set $c 30
+Shape_x_set $s -10
+Shape_y_set $s 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])"
+puts " Square = ([Shape_x_get $s], [Shape_y_get $s])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "$c $s" {
+ puts " $o"
+ puts " area = [Shape_area $o]"
+ puts " perimeter = [Shape_perimeter $o]"
+}
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Try to cause a type error -----
+
+puts "\nI'm going to try and break the type system"
+
+if { [catch {
+ # Bad script!
+ Square_area $c # Try to invoke Square method on a Circle
+ puts " Bad bad SWIG!"
+
+}]} {
+ puts " Well, it didn't work. Good SWIG."
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+delete_Shape $c
+delete_Shape $s
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"