From 38dcdd76413c012a569eccb67c195f1d6840e2b8 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 5 Apr 2018 12:09:53 +0200 Subject: UseSWIG: Ensure tests are usable in multi-config mode. Fixes: #17875 --- Tests/UseSWIG/BasicConfiguration.cmake | 7 +++++++ Tests/UseSWIG/BasicPerl/CMakeLists.txt | 12 ++---------- Tests/UseSWIG/BasicPython/CMakeLists.txt | 2 +- Tests/UseSWIG/LegacyConfiguration.cmake | 7 +++++++ Tests/UseSWIG/LegacyPerl/CMakeLists.txt | 12 ++---------- Tests/UseSWIG/LegacyPython/CMakeLists.txt | 2 +- Tests/UseSWIG/ModuleVersion2/CMakeLists.txt | 12 ++++++------ Tests/UseSWIG/MultipleModules/CMakeLists.txt | 21 ++++++++++----------- Tests/UseSWIG/MultiplePython/CMakeLists.txt | 11 +++++++++-- 9 files changed, 45 insertions(+), 41 deletions(-) diff --git a/Tests/UseSWIG/BasicConfiguration.cmake b/Tests/UseSWIG/BasicConfiguration.cmake index 73298567..d025d2a 100644 --- a/Tests/UseSWIG/BasicConfiguration.cmake +++ b/Tests/UseSWIG/BasicConfiguration.cmake @@ -2,6 +2,13 @@ find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) +# Path separator +if (WIN32) + set (PS "$") +else() + set (PS ":") +endif() + unset(SWIG_LANG_TYPE) unset(SWIG_LANG_INCLUDE_DIRECTORIES) unset(SWIG_LANG_DEFINITIONS) diff --git a/Tests/UseSWIG/BasicPerl/CMakeLists.txt b/Tests/UseSWIG/BasicPerl/CMakeLists.txt index 10c1cd8..476ef0e 100644 --- a/Tests/UseSWIG/BasicPerl/CMakeLists.txt +++ b/Tests/UseSWIG/BasicPerl/CMakeLists.txt @@ -8,15 +8,7 @@ set(language "perl") include (../BasicConfiguration.cmake) -if (WIN32) - file (TO_CMAKE_PATH "$ENV{PATH}" perl_path) - string (REPLACE ";" "$" perl_path "${perl_path}") - set (perl_env "PATH=$$${perl_path}") -else() - set (perl_env "LD_LIBRARY_PATH=$") -endif() - add_test (NAME BasicPerl - COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}" - "${PERL_EXECUTABLE}" "-I$" + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}" + "-I$" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/BasicPython/CMakeLists.txt b/Tests/UseSWIG/BasicPython/CMakeLists.txt index 1ca4e25..cf1d821 100644 --- a/Tests/UseSWIG/BasicPython/CMakeLists.txt +++ b/Tests/UseSWIG/BasicPython/CMakeLists.txt @@ -9,5 +9,5 @@ set(language "python") include (../BasicConfiguration.cmake) add_test (NAME BasicPython - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$" "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/LegacyConfiguration.cmake b/Tests/UseSWIG/LegacyConfiguration.cmake index 640c713..1acc05a 100644 --- a/Tests/UseSWIG/LegacyConfiguration.cmake +++ b/Tests/UseSWIG/LegacyConfiguration.cmake @@ -5,6 +5,13 @@ set (CMAKE_WARN_DEPRECATED FALSE) find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) +# Path separator +if (WIN32) + set (PS "$") +else() + set (PS ":") +endif() + unset(SWIG_LANG_TYPE) if(${language} MATCHES python) find_package(PythonInterp REQUIRED) diff --git a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt index 0def5f5..90d92f4 100644 --- a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt +++ b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt @@ -8,15 +8,7 @@ set(language "perl") include (../LegacyConfiguration.cmake) -if (WIN32) - file (TO_CMAKE_PATH "$ENV{PATH}" perl_path) - string (REPLACE ";" "$" perl_path "${perl_path}") - set (perl_env "PATH=$$${perl_path}") -else() - set (perl_env "LD_LIBRARY_PATH=$") -endif() - add_test (NAME LegacyPerl - COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}" - "${PERL_EXECUTABLE}" "-I$" + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}" + "-I$" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/LegacyPython/CMakeLists.txt b/Tests/UseSWIG/LegacyPython/CMakeLists.txt index 11a0d28..03facb1 100644 --- a/Tests/UseSWIG/LegacyPython/CMakeLists.txt +++ b/Tests/UseSWIG/LegacyPython/CMakeLists.txt @@ -9,5 +9,5 @@ set(language "python") include (../LegacyConfiguration.cmake) add_test (NAME LegacyPython - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$" "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt index 92cbcd3..3f9d363 100644 --- a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -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 $) +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 $) -else() - set (PS ":") -endif() - add_test (NAME ModuleVersion2.example1 COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$${PS}$" "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt index d495007..578825f 100644 --- a/Tests/UseSWIG/MultipleModules/CMakeLists.txt +++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt @@ -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 "$") +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=$" + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python${PS}$" "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") -if (WIN32) - file (TO_CMAKE_PATH "$ENV{PATH}" perl_path) - string (REPLACE ";" "$" perl_path "${perl_path}") - set (perl_env "PATH=$$${perl_path}") -else() - set (perl_env "LD_LIBRARY_PATH=$") -endif() - add_test (NAME MultipleModules.Perl - COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}" - "${PERL_EXECUTABLE}" "-I$" + COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}/Perl" + "-I$" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl") diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt index 260a382..a5e3eed 100644 --- a/Tests/UseSWIG/MultiplePython/CMakeLists.txt +++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt @@ -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 "$") +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=$" + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$" "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") add_test (NAME MultiplePython.example2 - COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$" + COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python3${PS}$" "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py") -- cgit v0.12