mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 21:41:03 +00:00
UseSWIG: Rework tests
This commit is contained in:
parent
e42fcb117f
commit
438429d6fe
@ -1431,6 +1431,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
|
||||
add_subdirectory(FindPython)
|
||||
endif()
|
||||
|
||||
if(CMake_TEST_UseSWIG)
|
||||
add_subdirectory(UseSWIG)
|
||||
endif()
|
||||
|
||||
add_subdirectory(FindThreads)
|
||||
|
||||
# Matlab module
|
||||
|
@ -362,11 +362,6 @@ if(CMake_TEST_FindMatlab)
|
||||
add_RunCMake_test(FindMatlab)
|
||||
endif()
|
||||
|
||||
# UseSWIG related tests
|
||||
if(CMake_TEST_UseSWIG)
|
||||
add_RunCMake_test(UseSWIG)
|
||||
endif()
|
||||
|
||||
add_executable(pseudo_emulator pseudo_emulator.c)
|
||||
add_executable(pseudo_emulator_custom_command pseudo_emulator_custom_command.c)
|
||||
add_RunCMake_test(CrosscompilingEmulator
|
||||
|
@ -1,9 +0,0 @@
|
||||
|
||||
set(language "python")
|
||||
|
||||
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"
|
||||
DEPENDS example)
|
@ -1,3 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(${RunCMake_TEST} CXX)
|
||||
include(${RunCMake_TEST}.cmake)
|
@ -1,9 +0,0 @@
|
||||
|
||||
set(language "python")
|
||||
|
||||
include (LegacyConfiguration.cmake)
|
||||
|
||||
add_custom_target (RunTest
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
|
||||
"${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py"
|
||||
DEPENDS ${SWIG_MODULE_example_REAL_NAME})
|
@ -1,30 +0,0 @@
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
find_package(PythonLibs REQUIRED)
|
||||
find_package(PerlLibs REQUIRED)
|
||||
|
||||
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)
|
||||
|
||||
set_property(SOURCE example.i PROPERTY GENERATED_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_PATH})
|
||||
|
||||
swig_add_library(example1
|
||||
LANGUAGE python
|
||||
SOURCES example.i example.cxx)
|
||||
target_link_libraries(example1 PRIVATE ${PYTHON_LIBRARIES})
|
||||
|
||||
# re-use sample interface file for another plugin
|
||||
set_property(SOURCE example.i 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
|
||||
SOURCES example.i example.cxx)
|
||||
target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
|
@ -1,27 +0,0 @@
|
||||
include(RunCMake)
|
||||
|
||||
function(run_SWIG test)
|
||||
cmake_parse_arguments(_SWIG_TEST "" "TARGET" "" ${ARGN})
|
||||
if (_SWIG_TEST_TARGET)
|
||||
list (INSERT _SWIG_TEST_TARGET 0 --target)
|
||||
endif()
|
||||
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
|
||||
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} --config Release ${_SWIG_TEST_TARGET})
|
||||
endfunction()
|
||||
|
||||
run_SWIG(LegacyPython TARGET RunTest)
|
||||
run_SWIG(LegacyPerl TARGET RunTest)
|
||||
|
||||
run_SWIG(BasicPython TARGET RunTest)
|
||||
run_SWIG(BasicPerl TARGET RunTest)
|
||||
|
||||
run_SWIG(MultipleModules)
|
||||
run_SWIG(MultiplePython)
|
@ -52,16 +52,21 @@ 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)
|
||||
set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY CPLUSPLUS ON)
|
||||
set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY COMPILE_OPTIONS -includeall)
|
||||
|
||||
set_property(SOURCE example.i PROPERTY GENERATED_INCLUDE_DIRECTORIES ${SWIG_LANG_INCLUDE_DIRECTORIES})
|
||||
set_property(SOURCE example.i PROPERTY GENERATED_COMPILE_DEFINITIONS ${SWIG_LANG_DEFINITIONS})
|
||||
set_property(SOURCE example.i PROPERTY GENERATED_COMPILE_OPTIONS ${SWIG_LANG_OPTIONS})
|
||||
set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
|
||||
PROPERTY GENERATED_INCLUDE_DIRECTORIES ${SWIG_LANG_INCLUDE_DIRECTORIES}
|
||||
"${CMAKE_CURRENT_LIST_DIR}")
|
||||
set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
|
||||
PROPERTY GENERATED_COMPILE_DEFINITIONS ${SWIG_LANG_DEFINITIONS})
|
||||
set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
|
||||
PROPERTY GENERATED_COMPILE_OPTIONS ${SWIG_LANG_OPTIONS})
|
||||
|
||||
|
||||
SWIG_ADD_LIBRARY(example
|
||||
LANGUAGE "${language}"
|
||||
${SWIG_LANG_TYPE}
|
||||
SOURCES example.i example.cxx)
|
||||
SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/example.cxx")
|
||||
TARGET_LINK_LIBRARIES(example PRIVATE ${SWIG_LANG_LIBRARIES})
|
@ -1,7 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestBasicPerl CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
set(language "perl")
|
||||
|
||||
include (BasicConfiguration.cmake)
|
||||
include (../BasicConfiguration.cmake)
|
||||
|
||||
if (WIN32)
|
||||
file (TO_CMAKE_PATH "$ENV{PATH}" perl_path)
|
||||
@ -11,8 +16,7 @@ else()
|
||||
set (perl_env "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:example>")
|
||||
endif()
|
||||
|
||||
add_custom_target (RunTest
|
||||
add_test (NAME BasicPerl
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}"
|
||||
"${PERL_EXECUTABLE}" "-I$<TARGET_FILE_DIR:example>"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/runme.pl"
|
||||
DEPENDS example)
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
|
13
Tests/UseSWIG/BasicPython/CMakeLists.txt
Normal file
13
Tests/UseSWIG/BasicPython/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestBasicPython CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
set(language "python")
|
||||
|
||||
include (../BasicConfiguration.cmake)
|
||||
|
||||
add_test (NAME BasicPython
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:example>"
|
||||
"${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
|
62
Tests/UseSWIG/CMakeLists.txt
Normal file
62
Tests/UseSWIG/CMakeLists.txt
Normal file
@ -0,0 +1,62 @@
|
||||
add_test(NAME UseSWIG.LegacyPython COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPython"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPython"
|
||||
${build_generator_args}
|
||||
--build-project TestLegacyPython
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
add_test(NAME UseSWIG.LegacyPerl COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPerl"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPerl"
|
||||
${build_generator_args}
|
||||
--build-project TestLegacyPerl
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
|
||||
add_test(NAME UseSWIG.BasicPython COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPython"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython"
|
||||
${build_generator_args}
|
||||
--build-project TestBasicPython
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
add_test(NAME UseSWIG.BasicPerl COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl"
|
||||
${build_generator_args}
|
||||
--build-project TestBasicPerl
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
|
||||
add_test(NAME UseSWIG.MultipleModules COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleModules"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleModules"
|
||||
${build_generator_args}
|
||||
--build-project TestMultipleModules
|
||||
--build-options ${build_options}
|
||||
)
|
||||
add_test(NAME UseSWIG.MultiplePython COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython"
|
||||
"${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython"
|
||||
${build_generator_args}
|
||||
--build-project TestMultiplePython
|
||||
--build-options ${build_options}
|
||||
)
|
@ -51,10 +51,11 @@ unset(CMAKE_SWIG_FLAGS)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
set_source_files_properties(example.i PROPERTIES CPLUSPLUS ON)
|
||||
set_source_files_properties(example.i PROPERTIES SWIG_FLAGS "-includeall")
|
||||
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES CPLUSPLUS ON)
|
||||
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES SWIG_FLAGS "-includeall")
|
||||
SWIG_ADD_LIBRARY(example
|
||||
LANGUAGE "${language}"
|
||||
${SWIG_LANG_TYPE}
|
||||
SOURCES example.i example.cxx)
|
||||
SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/example.cxx")
|
||||
SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES})
|
@ -1,7 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestLegacyPerl CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
set(language "perl")
|
||||
|
||||
include (LegacyConfiguration.cmake)
|
||||
include (../LegacyConfiguration.cmake)
|
||||
|
||||
if (WIN32)
|
||||
file (TO_CMAKE_PATH "$ENV{PATH}" perl_path)
|
||||
@ -11,8 +16,7 @@ else()
|
||||
set (perl_env "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>")
|
||||
endif()
|
||||
|
||||
add_custom_target (RunTest
|
||||
add_test (NAME LegacyPerl
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "${perl_env}"
|
||||
"${PERL_EXECUTABLE}" "-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/runme.pl"
|
||||
DEPENDS ${SWIG_MODULE_example_REAL_NAME})
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
|
13
Tests/UseSWIG/LegacyPython/CMakeLists.txt
Normal file
13
Tests/UseSWIG/LegacyPython/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestLegacyPython CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
set(language "python")
|
||||
|
||||
include (../LegacyConfiguration.cmake)
|
||||
|
||||
add_test (NAME LegacyPython
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
|
||||
"${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
|
38
Tests/UseSWIG/MultipleModules/CMakeLists.txt
Normal file
38
Tests/UseSWIG/MultipleModules/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestMultipleModules CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
find_package(Python REQUIRED COMPONENTS Development)
|
||||
|
||||
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)
|
||||
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)
|
||||
target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
|
@ -1,3 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestMultiplePython CXX)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
@ -7,20 +12,21 @@ 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)
|
||||
|
||||
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}/Python2"
|
||||
SOURCES example.i example.cxx)
|
||||
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)
|
||||
SOURCES ../example.i ../example.cxx)
|
||||
target_link_libraries(example2 PRIVATE Python3::Python)
|
Loading…
Reference in New Issue
Block a user