summaryrefslogtreecommitdiffstats
path: root/Tests/UseSWIG
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/UseSWIG')
-rw-r--r--Tests/UseSWIG/CMakeLists.txt12
-rw-r--r--Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt2
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt61
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake17
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp15
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i8
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp29
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp15
-rw-r--r--Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i8
9 files changed, 166 insertions, 1 deletions
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
index aee3338..e150223 100644
--- a/Tests/UseSWIG/CMakeLists.txt
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -169,3 +169,15 @@ add_test(NAME UseSWIG.AlternateLibraryName COMMAND
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+
+
+add_test(NAME UseSWIG.SwigSrcOUTPUT_DIR COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/SwigSrcOUTPUT_DIR"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/SwigSrcOUTPUT_DIR"
+ ${build_generator_args}
+ --build-project TestSwigSrcOUTPUT_DIR
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt
index 39566a8..51ec1b2 100644
--- a/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt
+++ b/Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12...3.13)
-project(TestNamsespaceCsharp CXX)
+project(TestNamespaceCsharp CXX)
include(CTest)
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt
new file mode 100644
index 0000000..fc0cf8d
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/CMakeLists.txt
@@ -0,0 +1,61 @@
+cmake_minimum_required(VERSION 3.12...3.19)
+
+project(TestSwigSrcOUTPUT_DIR CXX)
+
+include(CTest)
+
+
+set(CMAKE_CXX_STANDARD 11)
+
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+set(UseSWIG_MODULE_VERSION 2)
+
+
+file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/Foo"
+ "${CMAKE_CURRENT_BINARY_DIR}/FooSupport"
+ "${CMAKE_CURRENT_BINARY_DIR}/FooFile"
+ "${CMAKE_CURRENT_BINARY_DIR}/Bar"
+ "${CMAKE_CURRENT_BINARY_DIR}/BarSupport"
+ "${CMAKE_CURRENT_BINARY_DIR}/BarFile")
+
+
+set_property (SOURCE foo.i PROPERTY COMPILE_OPTIONS -namespace Foo)
+set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Foo")
+set_property (SOURCE foo.i PROPERTY CPLUSPLUS ON)
+
+set_property (SOURCE bar.i PROPERTY COMPILE_OPTIONS -namespace Bar)
+set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Bar")
+set_property (SOURCE bar.i PROPERTY CPLUSPLUS ON)
+
+swig_add_library(outdir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1"
+ OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2")
+target_include_directories(outdir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
+set_property(TARGET outdir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON)
+
+
+get_target_property(SUPPORT_FILES_DIRS outdir_test SWIG_SUPPORT_FILES_DIRECTORY)
+
+add_test(NAME SwigSrcOUTPUT_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake")
+
+
+
+set_property (SOURCE foo.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooSupport")
+set_property (SOURCE foo.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/FooFile")
+
+set_property (SOURCE bar.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarSupport")
+set_property (SOURCE bar.i PROPERTY OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/BarFile")
+
+swig_add_library(outfiledir_test LANGUAGE csharp SOURCES foo.i bar.i cs.cpp
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed1"
+ OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}/NotUsed2")
+target_include_directories(outfiledir_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
+set_property(TARGET outfiledir_test PROPERTY USE_TARGET_INCLUDE_DIRECTORIES ON)
+
+
+get_target_property(SUPPORT_FILES_DIRS outfiledir_test SWIG_SUPPORT_FILES_DIRECTORY)
+
+add_test(NAME SwigSrcOUTFILE_DIR COMMAND "${CMAKE_COMMAND}" "-DBASE_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}" "-DSUPPORT_FILES_DIRECTORY=${SUPPORT_FILES_DIRS}" -DOUTFILE_DIR=ON -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake")
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake
new file mode 100644
index 0000000..20240ed
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/ValidateSupportFiles.cmake
@@ -0,0 +1,17 @@
+
+foreach (support_dir IN LISTS SUPPORT_FILES_DIRECTORY)
+ file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${BASE_DIRECTORY}" "${support_dir}/*")
+ list (APPEND support_files ${files})
+endforeach()
+
+list(SORT support_files)
+
+if (OUTFILE_DIR)
+ set (expected_files "BarSupport/Bar.cs;BarSupport/BarPINVOKE.cs;BarSupport/Math.cs;FooSupport/Foo.cs;FooSupport/FooPINVOKE.cs;FooSupport/Math.cs")
+else()
+ set (expected_files "Bar/Bar.cs;Bar/BarPINVOKE.cs;Bar/Math.cs;Bar/barCSHARP_wrap.cxx;Foo/Foo.cs;Foo/FooPINVOKE.cs;Foo/Math.cs;Foo/fooCSHARP_wrap.cxx")
+endif()
+
+if (NOT support_files STREQUAL expected_files)
+ message (FATAL_ERROR "Support files not correctly collected.")
+endif()
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp
new file mode 100644
index 0000000..26b707f
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace Bar {
+
+class Math
+{
+public:
+ void add(int value);
+ int get_sum() const;
+
+private:
+ int sum_ = 0;
+};
+
+} // namespace cs
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i
new file mode 100644
index 0000000..539f32a
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/bar.i
@@ -0,0 +1,8 @@
+%module Bar
+
+%{
+#include <bar.hpp>
+%}
+
+// %nspace cs::my_class_in_namespace;
+%include <bar.hpp>
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp
new file mode 100644
index 0000000..e4aa562
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/cs.cpp
@@ -0,0 +1,29 @@
+#include <bar.hpp>
+#include <foo.hpp>
+
+namespace Foo {
+
+void Math::add(int value)
+{
+ sum_ += value;
+}
+
+int Math::get_sum() const
+{
+ return sum_;
+}
+}
+
+namespace Bar {
+
+void Math::add(int value)
+{
+ sum_ += value;
+}
+
+int Math::get_sum() const
+{
+ return sum_;
+}
+
+} // namespace cs
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp
new file mode 100644
index 0000000..b227463
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+namespace Foo {
+
+class Math
+{
+public:
+ void add(int value);
+ int get_sum() const;
+
+private:
+ int sum_ = 0;
+};
+
+} // namespace cs
diff --git a/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i
new file mode 100644
index 0000000..5e14b04
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcOUTPUT_DIR/foo.i
@@ -0,0 +1,8 @@
+%module Foo
+
+%{
+#include <foo.hpp>
+%}
+
+// %nspace cs::my_class_in_namespace;
+%include <foo.hpp>