diff options
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/UseSWIG/BasicConfiguration.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/UseSWIG/BasicPython.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/UseSWIG/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/UseSWIG/MultiplePython.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/UseSWIG/RunCMakeTest.cmake | 6 |
5 files changed, 36 insertions, 7 deletions
diff --git a/Tests/RunCMake/UseSWIG/BasicConfiguration.cmake b/Tests/RunCMake/UseSWIG/BasicConfiguration.cmake index 94d8dd3..2f46d63 100644 --- a/Tests/RunCMake/UseSWIG/BasicConfiguration.cmake +++ b/Tests/RunCMake/UseSWIG/BasicConfiguration.cmake @@ -9,10 +9,9 @@ unset(SWIG_LANG_OPTIONS) unset(SWIG_LANG_LIBRARIES) if(${language} MATCHES python) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - set(SWIG_LANG_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_PATH}) - set(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES}) + find_package(Python REQUIRED COMPONENTS Interpreter Development) + set(SWIG_LANG_INCLUDE_DIRECTORIES ${Python_INCLUDE_DIRS}) + set(SWIG_LANG_LIBRARIES ${Python_LIBRARIES}) endif() if(${language} MATCHES perl) find_package(Perl REQUIRED) diff --git a/Tests/RunCMake/UseSWIG/BasicPython.cmake b/Tests/RunCMake/UseSWIG/BasicPython.cmake index 0d8c824..873dbe9 100644 --- a/Tests/RunCMake/UseSWIG/BasicPython.cmake +++ b/Tests/RunCMake/UseSWIG/BasicPython.cmake @@ -5,5 +5,5 @@ include (BasicConfiguration.cmake) add_custom_target (RunTest COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example>" - "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py" + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py" DEPENDS example) diff --git a/Tests/RunCMake/UseSWIG/CMakeLists.txt b/Tests/RunCMake/UseSWIG/CMakeLists.txt index f452db1..2d75985 100644 --- a/Tests/RunCMake/UseSWIG/CMakeLists.txt +++ b/Tests/RunCMake/UseSWIG/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.1) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/UseSWIG/MultiplePython.cmake b/Tests/RunCMake/UseSWIG/MultiplePython.cmake new file mode 100644 index 0000000..3804bdd --- /dev/null +++ b/Tests/RunCMake/UseSWIG/MultiplePython.cmake @@ -0,0 +1,26 @@ + +find_package(SWIG REQUIRED) +include(${SWIG_USE_FILE}) + +find_package(Python2 REQUIRED COMPONENTS Development) +find_package(Python3 REQUIRED COMPONENTS Development) + +unset(CMAKE_SWIG_FLAGS) + +set (CMAKE_INCLUDE_CURRENT_DIR ON) + +set_property(SOURCE example.i PROPERTY CPLUSPLUS ON) +set_property(SOURCE example.i PROPERTY COMPILE_OPTIONS -includeall) + +swig_add_library(example1 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python2" + SOURCES example.i example.cxx) +target_link_libraries(example1 PRIVATE Python2::Python) + +# re-use sample interface file for another plugin +swig_add_library(example2 + LANGUAGE python + OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python3" + SOURCES example.i example.cxx) +target_link_libraries(example2 PRIVATE Python3::Python) diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake index c63ff2e..cded22f 100644 --- a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake @@ -10,8 +10,11 @@ function(run_SWIG test) set(RunCMake_TEST_NO_CLEAN 1) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set (RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() run_cmake(${test}) - run_cmake_command(${test}-test ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} ${_SWIG_TEST_TARGET}) + run_cmake_command(${test}-test ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Release ${_SWIG_TEST_TARGET}) endfunction() run_SWIG(LegacyPython TARGET RunTest) @@ -21,3 +24,4 @@ run_SWIG(BasicPython TARGET RunTest) run_SWIG(BasicPerl TARGET RunTest) run_SWIG(MultipleModules) +run_SWIG(MultiplePython) |