summaryrefslogtreecommitdiffstats
path: root/Tests/UseSWIG
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-08-31 10:33:57 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-08-31 10:33:57 (GMT)
commitd264685bee6a0d0598d46f5bc3e81f7231aa0c53 (patch)
tree96fef579c2708cc333b059f4f199722e648dfd0f /Tests/UseSWIG
parentf2a22ecda9b21a8a26c99d201d6f542e78d4f414 (diff)
downloadCMake-d264685bee6a0d0598d46f5bc3e81f7231aa0c53.zip
CMake-d264685bee6a0d0598d46f5bc3e81f7231aa0c53.tar.gz
CMake-d264685bee6a0d0598d46f5bc3e81f7231aa0c53.tar.bz2
UseSWIG: Update option -interface usage
Option -interface must not be used if multiple SWIG files are part of the same library. Fixes: #21134
Diffstat (limited to 'Tests/UseSWIG')
-rw-r--r--Tests/UseSWIG/CMakeLists.txt9
-rw-r--r--Tests/UseSWIG/MultipleFiles/CMakeLists.txt30
-rw-r--r--Tests/UseSWIG/MultipleFiles/add.cxx6
-rw-r--r--Tests/UseSWIG/MultipleFiles/add.h1
-rw-r--r--Tests/UseSWIG/MultipleFiles/add.i4
-rw-r--r--Tests/UseSWIG/MultipleFiles/sub.cxx6
-rw-r--r--Tests/UseSWIG/MultipleFiles/sub.h1
-rw-r--r--Tests/UseSWIG/MultipleFiles/sub.i5
8 files changed, 62 insertions, 0 deletions
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
index d102846..cd04a4a 100644
--- a/Tests/UseSWIG/CMakeLists.txt
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -91,6 +91,15 @@ add_test(NAME UseSWIG.MultiplePython COMMAND
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+add_test(NAME UseSWIG.MultipleFiles COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleFiles"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleFiles"
+ ${build_generator_args}
+ --build-project TestMultipleFiles
+ --build-options ${build_options}
+ )
add_test(NAME UseSWIG.ModuleVersion2 COMMAND
diff --git a/Tests/UseSWIG/MultipleFiles/CMakeLists.txt b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt
new file mode 100644
index 0000000..bf3d946
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.18)
+
+project(TestMultipleFiles CXX)
+
+find_package(SWIG REQUIRED)
+include(UseSWIG)
+
+unset(SWIG_LANG_TYPE)
+unset(SWIG_LANG_INCLUDE_DIRECTORIES)
+unset(SWIG_LANG_DEFINITIONS)
+unset(SWIG_LANG_OPTIONS)
+unset(SWIG_LANG_LIBRARIES)
+
+find_package(Python3 REQUIRED COMPONENTS Development)
+
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/add.i" PROPERTY SWIG_MODULE_NAME _add)
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sub.i" PROPERTY SWIG_MODULE_NAME _sub)
+
+
+swig_add_library(example
+ LANGUAGE python
+ TYPE MODULE
+ SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/add.i"
+ "${CMAKE_CURRENT_SOURCE_DIR}/sub.i"
+ "${CMAKE_CURRENT_SOURCE_DIR}/add.cxx"
+ "${CMAKE_CURRENT_SOURCE_DIR}/sub.cxx")
+target_include_directories(example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
+target_link_libraries(example PRIVATE Python3::Module)
diff --git a/Tests/UseSWIG/MultipleFiles/add.cxx b/Tests/UseSWIG/MultipleFiles/add.cxx
new file mode 100644
index 0000000..a4dcca3
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/add.cxx
@@ -0,0 +1,6 @@
+#include "add.h"
+
+int add(int a, int b)
+{
+ return a + b;
+}
diff --git a/Tests/UseSWIG/MultipleFiles/add.h b/Tests/UseSWIG/MultipleFiles/add.h
new file mode 100644
index 0000000..6295ab9
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/add.h
@@ -0,0 +1 @@
+int add(int a, int b);
diff --git a/Tests/UseSWIG/MultipleFiles/add.i b/Tests/UseSWIG/MultipleFiles/add.i
new file mode 100644
index 0000000..2046397
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/add.i
@@ -0,0 +1,4 @@
+%{
+#include "add.h"
+%}
+%include "add.h"
diff --git a/Tests/UseSWIG/MultipleFiles/sub.cxx b/Tests/UseSWIG/MultipleFiles/sub.cxx
new file mode 100644
index 0000000..d6874ef
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/sub.cxx
@@ -0,0 +1,6 @@
+#include "sub.h"
+
+int sub(int a, int b)
+{
+ return a - b;
+}
diff --git a/Tests/UseSWIG/MultipleFiles/sub.h b/Tests/UseSWIG/MultipleFiles/sub.h
new file mode 100644
index 0000000..de77111
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/sub.h
@@ -0,0 +1 @@
+int sub(int a, int b);
diff --git a/Tests/UseSWIG/MultipleFiles/sub.i b/Tests/UseSWIG/MultipleFiles/sub.i
new file mode 100644
index 0000000..fc70f10
--- /dev/null
+++ b/Tests/UseSWIG/MultipleFiles/sub.i
@@ -0,0 +1,5 @@
+%{
+#include "sub.h"
+%}
+
+%include "sub.h"