diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-03-27 14:49:58 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2018-04-03 10:44:55 (GMT) |
commit | 8ab4e38373352c43fcedf4ac91b41114d8e31dc0 (patch) | |
tree | c9ce6c7a240d903dc08c0b77eb80fbc1dff6c8d5 /Tests/UseSWIG/ModuleVersion2 | |
parent | 438429d6fe04164b7ed70bda872e291d0df1a9e3 (diff) | |
download | CMake-8ab4e38373352c43fcedf4ac91b41114d8e31dc0.zip CMake-8ab4e38373352c43fcedf4ac91b41114d8e31dc0.tar.gz CMake-8ab4e38373352c43fcedf4ac91b41114d8e31dc0.tar.bz2 |
UseSWIG: Add new behavior for better support files management
fixes: #17840
Diffstat (limited to 'Tests/UseSWIG/ModuleVersion2')
-rw-r--r-- | Tests/UseSWIG/ModuleVersion2/CMakeLists.txt | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt new file mode 100644 index 0000000..92cbcd3 --- /dev/null +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestModuleVersion2 CXX) + +include(CTest) + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + +set (UseSWIG_MODULE_VERSION 2) +unset(CMAKE_SWIG_FLAGS) + +set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) +set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall) + +set_property(SOURCE "../example.i" + PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..") + +swig_add_library(example1 + LANGUAGE python + SOURCES ../example.i ../example.cxx) +set_target_properties (example1 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2") +target_link_libraries(example1 PRIVATE Python2::Python) + +# re-use sample interface file for another plugin +swig_add_library(example2 + LANGUAGE python + SOURCES ../example.i ../example.cxx) +set_target_properties (example2 PROPERTIES + OUTPUT_NAME example + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3") +target_link_libraries(example2 PRIVATE Python3::Python) + + +if (WIN32) + set (PS $<SEMICOLON>) +else() + set (PS ":") +endif() + +add_test (NAME ModuleVersion2.example1 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>" + "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") + +add_test (NAME ModuleVersion2.example2 + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>" + "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") |