mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
if (ACTION STREQUAL "CLEAN")
|
if (ACTION STREQUAL "CLEAN")
|
||||||
# Collect current list of generated files
|
# Collect current list of generated files
|
||||||
file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
|
file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
|
||||||
|
|
||||||
if (files)
|
if (files)
|
||||||
# clean-up the output directory
|
# clean-up the output directory
|
||||||
@@ -22,7 +22,7 @@ endif()
|
|||||||
|
|
||||||
if (ACTION STREQUAL "COPY")
|
if (ACTION STREQUAL "COPY")
|
||||||
# Collect current list of generated files
|
# Collect current list of generated files
|
||||||
file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
|
file (GLOB files LIST_DIRECTORIES TRUE "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
|
||||||
|
|
||||||
if (files)
|
if (files)
|
||||||
# copy files to the output directory
|
# copy files to the output directory
|
||||||
|
@@ -33,6 +33,16 @@ if (CMAKE_CSharp_COMPILER)
|
|||||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
add_test(NAME UseSWIG.NamespaceCsharp COMMAND
|
||||||
|
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||||
|
--build-and-test
|
||||||
|
"${CMake_SOURCE_DIR}/Tests/UseSWIG/NamespaceCsharp"
|
||||||
|
"${CMake_BINARY_DIR}/Tests/UseSWIG/NamespaceCsharp"
|
||||||
|
${build_generator_args}
|
||||||
|
--build-project TestNamespaceCsharp
|
||||||
|
--build-options ${build_options}
|
||||||
|
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||||
|
)
|
||||||
|
|
||||||
add_test(NAME UseSWIG.BasicPython COMMAND
|
add_test(NAME UseSWIG.BasicPython COMMAND
|
||||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||||
|
25
Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt
Normal file
25
Tests/UseSWIG/NamespaceCsharp/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.12...3.13)
|
||||||
|
|
||||||
|
project(TestNamsespaceCsharp CXX)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
|
find_package(SWIG REQUIRED)
|
||||||
|
include(${SWIG_USE_FILE})
|
||||||
|
|
||||||
|
set(UseSWIG_MODULE_VERSION 2)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(ns_example STATIC ns_example.cpp)
|
||||||
|
target_include_directories(ns_example PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
set_property(SOURCE ns_example.i PROPERTY CPLUSPLUS ON)
|
||||||
|
|
||||||
|
swig_add_library(ns_csharp TYPE SHARED LANGUAGE csharp SOURCES ns_example.i)
|
||||||
|
set_target_properties(ns_csharp PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
|
||||||
|
|
||||||
|
target_link_libraries(ns_csharp PRIVATE ns_example)
|
||||||
|
|
||||||
|
get_target_property(NS_CSHARP_SUPPORT_FILES_DIR ns_csharp SWIG_SUPPORT_FILES_DIRECTORY)
|
||||||
|
|
||||||
|
add_test(NAME NamespaceCsharp COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_DIRECTORY=${NS_CSHARP_SUPPORT_FILES_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/ValidateSupportFiles.cmake")
|
8
Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake
Normal file
8
Tests/UseSWIG/NamespaceCsharp/ValidateSupportFiles.cmake
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
file (GLOB_RECURSE files LIST_DIRECTORIES TRUE RELATIVE "${SUPPORT_FILES_DIRECTORY}" "${SUPPORT_FILES_DIRECTORY}/*")
|
||||||
|
|
||||||
|
list(SORT files)
|
||||||
|
|
||||||
|
if (NOT files STREQUAL "NSExample.cs;NSExamplePINVOKE.cs;ns;ns/my_class_in_namespace.cs")
|
||||||
|
message (FATAL_ERROR "Support files not correctly collected.")
|
||||||
|
endif()
|
14
Tests/UseSWIG/NamespaceCsharp/ns_example.cpp
Normal file
14
Tests/UseSWIG/NamespaceCsharp/ns_example.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "ns_example.hpp"
|
||||||
|
|
||||||
|
namespace ns {
|
||||||
|
|
||||||
|
void my_class_in_namespace::add(int value)
|
||||||
|
{
|
||||||
|
Sum += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int my_class_in_namespace::get_sum() const
|
||||||
|
{
|
||||||
|
return Sum;
|
||||||
|
}
|
||||||
|
}
|
19
Tests/UseSWIG/NamespaceCsharp/ns_example.hpp
Normal file
19
Tests/UseSWIG/NamespaceCsharp/ns_example.hpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace ns {
|
||||||
|
|
||||||
|
class my_class_in_namespace
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
my_class_in_namespace()
|
||||||
|
: Sum(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void add(int value);
|
||||||
|
int get_sum() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int Sum;
|
||||||
|
};
|
||||||
|
}
|
8
Tests/UseSWIG/NamespaceCsharp/ns_example.i
Normal file
8
Tests/UseSWIG/NamespaceCsharp/ns_example.i
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
%module NSExample
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "ns_example.hpp"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%nspace ns::my_class_in_namespace;
|
||||||
|
%include "ns_example.hpp"
|
Reference in New Issue
Block a user