diff options
Diffstat (limited to 'Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt')
-rw-r--r-- | Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt new file mode 100644 index 0000000..7eb73d4 --- /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::Python) + +# Generate a Python module out of `.swg` +swig_add_library(my_sub LANGUAGE python SOURCES my_sub.swg) +target_link_libraries(my_sub Python::Python) + +# 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") |