Commit 38dcdd76 authored by Marc Chevrier's avatar Marc Chevrier

UseSWIG: Ensure tests are usable in multi-config mode.

Fixes: #17875
parent 3201e4c1
......@@ -2,6 +2,13 @@
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
# Path separator
if (WIN32)
set (PS "$<SEMICOLON>")
else()
set (PS ":")
endif()
unset(SWIG_LANG_TYPE)
unset(SWIG_LANG_INCLUDE_DIRECTORIES)
unset(SWIG_LANG_DEFINITIONS)
......
......@@ -8,15 +8,7 @@ set(language "perl")
include (../BasicConfiguration.cmake)
if (WIN32)
file (TO_CMAKE_PATH "$ENV{PATH}" perl_path)
string (REPLACE ";" "$<SEMICOLON>" perl_path "${perl_path}")
set (perl_env "PATH=$<TARGET_FILE_DIR:example>$<SEMICOLON>${perl_path}")
else()
set (perl_env "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:example>")
endif()
add_test (NAME BasicPerl
COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}"
"${PERL_EXECUTABLE}" "-I$<TARGET_FILE_DIR:example>"
COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
"-I$<TARGET_FILE_DIR:example>"
"${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
......@@ -9,5 +9,5 @@ set(language "python")
include (../BasicConfiguration.cmake)
add_test (NAME BasicPython
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example>"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example>"
"${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
......@@ -5,6 +5,13 @@ set (CMAKE_WARN_DEPRECATED FALSE)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
# Path separator
if (WIN32)
set (PS "$<SEMICOLON>")
else()
set (PS ":")
endif()
unset(SWIG_LANG_TYPE)
if(${language} MATCHES python)
find_package(PythonInterp REQUIRED)
......
......@@ -8,15 +8,7 @@ set(language "perl")
include (../LegacyConfiguration.cmake)
if (WIN32)
file (TO_CMAKE_PATH "$ENV{PATH}" perl_path)
string (REPLACE ";" "$<SEMICOLON>" perl_path "${perl_path}")
set (perl_env "PATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>$<SEMICOLON>${perl_path}")
else()
set (perl_env "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>")
endif()
add_test (NAME LegacyPerl
COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}"
"${PERL_EXECUTABLE}" "-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
"-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
"${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
......@@ -9,5 +9,5 @@ set(language "python")
include (../LegacyConfiguration.cmake)
add_test (NAME LegacyPython
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
"${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
......@@ -10,6 +10,12 @@ include(${SWIG_USE_FILE})
find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
if (WIN32)
set (PS $<SEMICOLON>)
else()
set (PS ":")
endif()
set (UseSWIG_MODULE_VERSION 2)
unset(CMAKE_SWIG_FLAGS)
......@@ -41,12 +47,6 @@ set_target_properties (example2 PROPERTIES
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")
......
......@@ -12,6 +12,13 @@ find_package(Python REQUIRED COMPONENTS Interpreter Development)
find_package(Perl REQUIRED)
find_package(PerlLibs REQUIRED)
# Path separator
if (WIN32)
set (PS "$<SEMICOLON>")
else()
set (PS ":")
endif()
unset(CMAKE_SWIG_FLAGS)
set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
......@@ -51,19 +58,11 @@ target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
add_test (NAME MultipleModules.Python
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example1>"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python${PS}$<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>"
COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}/Perl"
"-I$<TARGET_FILE_DIR:example2>"
"${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
......@@ -10,6 +10,13 @@ include(${SWIG_USE_FILE})
find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
# Path separator
if (WIN32)
set (PS "$<SEMICOLON>")
else()
set (PS ":")
endif()
unset(CMAKE_SWIG_FLAGS)
set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
......@@ -44,9 +51,9 @@ target_link_libraries(example2 PRIVATE Python3::Python)
add_test (NAME MultiplePython.example1
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example1>"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
"${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
add_test (NAME MultiplePython.example2
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example2>"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python3${PS}$<TARGET_FILE_DIR:example2>"
"${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment