You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
885 B

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")