summaryrefslogtreecommitdiffstats
path: root/Tests/UseSWIG/MultipleModules/CMakeLists.txt
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2018-04-04 14:23:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-04-04 14:24:07 (GMT)
commit74005a136ca0f6ffa1619982d2a4c947335d7254 (patch)
tree3ca5a999f7862b841cf6e8ea77e152be8e1580e2 /Tests/UseSWIG/MultipleModules/CMakeLists.txt
parentc468b9a2314a67f9d697d27c12f9c39e1301f1aa (diff)
parent8ab4e38373352c43fcedf4ac91b41114d8e31dc0 (diff)
downloadCMake-74005a136ca0f6ffa1619982d2a4c947335d7254.zip
CMake-74005a136ca0f6ffa1619982d2a4c947335d7254.tar.gz
CMake-74005a136ca0f6ffa1619982d2a4c947335d7254.tar.bz2
Merge topic 'UseSWIG-add-new-behavior'
8ab4e38373 UseSWIG: Add new behavior for better support files management 438429d6fe UseSWIG: Rework tests Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1891
Diffstat (limited to 'Tests/UseSWIG/MultipleModules/CMakeLists.txt')
-rw-r--r--Tests/UseSWIG/MultipleModules/CMakeLists.txt69
1 files changed, 69 insertions, 0 deletions
diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
new file mode 100644
index 0000000..d495007
--- /dev/null
+++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
@@ -0,0 +1,69 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestMultipleModules CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python REQUIRED COMPONENTS Interpreter Development)
+
+find_package(Perl REQUIRED)
+find_package(PerlLibs REQUIRED)
+
+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
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python")
+target_link_libraries(example1 PRIVATE Python::Python)
+
+# re-use sample interface file for another plugin
+set_property(SOURCE "../example.i" APPEND PROPERTY
+ GENERATED_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH})
+separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+set_property(SOURCE "../example.i" PROPERTY GENERATED_COMPILE_OPTIONS ${c_flags})
+
+swig_add_library(example2
+ LANGUAGE perl
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl")
+target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
+
+
+
+add_test (NAME MultipleModules.Python
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example1>"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+
+if (WIN32)
+ file (TO_CMAKE_PATH "$ENV{PATH}" perl_path)
+ string (REPLACE ";" "$<SEMICOLON>" perl_path "${perl_path}")
+ set (perl_env "PATH=$<TARGET_FILE_DIR:example2>$<SEMICOLON>${perl_path}")
+else()
+ set (perl_env "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:example2>")
+endif()
+
+add_test (NAME MultipleModules.Perl
+ COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}"
+ "${PERL_EXECUTABLE}" "-I$<TARGET_FILE_DIR:example2>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")