summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-06-29 13:11:12 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2023-06-29 15:07:56 (GMT)
commit9b45210b052c7c81ab84313c4a3b537e66c2a7b7 (patch)
tree91a232e58d2f8cdb52c7ed8c81c6ae49e861b8fa
parentc24be2ffe726f876a5b4c235848b24bc3fe5f5e2 (diff)
downloadCMake-9b45210b052c7c81ab84313c4a3b537e66c2a7b7.zip
CMake-9b45210b052c7c81ab84313c4a3b537e66c2a7b7.tar.gz
CMake-9b45210b052c7c81ab84313c4a3b537e66c2a7b7.tar.bz2
FindPython: Add tests for IronPython v3
-rw-r--r--Modules/FindPython/Support.cmake4
-rw-r--r--Tests/CMakeLists.txt6
-rw-r--r--Tests/FindPython/CMakeLists.txt141
-rw-r--r--Tests/FindPython/IronPython3/CMakeLists.txt31
4 files changed, 154 insertions, 28 deletions
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 76d4a9b..0f0e2af 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -981,7 +981,7 @@ function (_PYTHON_VALIDATE_COMPILER)
# retrieve python environment version from compiler
set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
- file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))\n")
+ file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]])); sys.stdout.flush()\n")
execute_process (COMMAND ${launcher} "${_${_PYTHON_PREFIX}_COMPILER}"
${_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS}
/target:exe /embed "${working_dir}/version.py"
@@ -2520,7 +2520,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
# retrieve python environment version from compiler
_python_get_launcher (_${_PYTHON_PREFIX}_COMPILER_LAUNCHER COMPILER)
set (_${_PYTHON_PREFIX}_VERSION_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
- file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))\n")
+ file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]])); sys.stdout.flush()\n")
execute_process (COMMAND ${_${_PYTHON_PREFIX}_COMPILER_LAUNCHER} "${_${_PYTHON_PREFIX}_COMPILER}"
${_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS}
/target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py"
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 914ebce..2a7c839 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1557,15 +1557,17 @@ if(BUILD_TESTING)
endif()
if(CMake_TEST_FindPython_IronPython)
set(CMake_TEST_FindPython2_IronPython TRUE)
+ set(CMake_TEST_FindPython3_IronPython TRUE)
endif()
if(CMake_TEST_FindPython_PyPy)
set(CMake_TEST_FindPython2_PyPy TRUE)
set(CMake_TEST_FindPython3_PyPy TRUE)
endif()
- if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython2
+ if(CMake_TEST_FindPython2 OR CMake_TEST_FindPython3
OR CMake_TEST_FindPython2_SABIModule OR CMake_TEST_FindPython3_SABIModule
OR CMake_TEST_FindPython2_NumPy OR CMake_TEST_FindPython3_NumPy
- OR CMake_TEST_FindPython3_Conda OR CMake_TEST_FindPython2_IronPython
+ OR CMake_TEST_FindPython3_Conda
+ OR CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython
OR CMake_TEST_FindPython2_PyPy OR CMake_TEST_FindPython3_PyPy)
if (CMake_TEST_FindPython2 AND CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
set(CMake_TEST_FindPython2_SABIModule TRUE)
diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt
index 3e1993e..bb9bef0 100644
--- a/Tests/FindPython/CMakeLists.txt
+++ b/Tests/FindPython/CMakeLists.txt
@@ -557,21 +557,21 @@ if(CMake_TEST_FindPython3_Conda)
endif()
if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython)
- add_test(NAME FindPython.Implementation.CPython COMMAND
+ add_test(NAME FindPython.Implementation.CPython2 COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Implementation"
- "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython2"
${build_generator_args}
--build-project TestImplementationCPython
--build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATIONS=CPython
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.Implementation.IronPython COMMAND
+ add_test(NAME FindPython.Implementation.IronPython2 COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindPython/Implementation"
- "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython2"
${build_generator_args}
--build-project TestImplementationIronPython
--build-options ${build_options} -DPython_REQUESTED_VERSION=2 -DPython_REQUESTED_IMPLEMENTATION=IronPython
@@ -579,6 +579,29 @@ if (CMake_TEST_FindPython2 AND CMake_TEST_FindPython2_IronPython)
)
endif()
+if (CMake_TEST_FindPython3 AND CMake_TEST_FindPython3_IronPython)
+ add_test(NAME FindPython.Implementation.CPython3 COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.CPython3"
+ ${build_generator_args}
+ --build-project TestImplementationCPython
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATIONS=CPython
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.Implementation.IronPython3 COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Implementation"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Implementation.IronPython3"
+ ${build_generator_args}
+ --build-project TestImplementationIronPython
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_REQUESTED_IMPLEMENTATION=IronPython
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+endif()
+
if(CMake_TEST_FindPython2_IronPython)
add_test(NAME FindPython.IronPython2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
@@ -601,26 +624,6 @@ if(CMake_TEST_FindPython2_IronPython)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
- add_test(NAME FindPython.IronPython.LOCATION COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
- "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION"
- ${build_generator_args}
- --build-project TestIronPython
- --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
- add_test(NAME FindPython.IronPython.VERSION COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
- "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION"
- ${build_generator_args}
- --build-project TestIronPython
- --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
add_test(NAME FindPython.IronPython.V2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -666,6 +669,96 @@ if(CMake_TEST_FindPython2_IronPython)
)
endif()
+if(CMake_TEST_FindPython3_IronPython)
+ add_test(NAME FindPython.IronPython3.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.LOCATION"
+ ${build_generator_args}
+ --build-project TestIronPython3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.IronPython3.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VERSION"
+ ${build_generator_args}
+ --build-project TestIronPython3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.IronPython.V3.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.LOCATION"
+ ${build_generator_args}
+ --build-project TestIronPython
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=LOCATION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.IronPython.V3.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.V3.VERSION"
+ ${build_generator_args}
+ --build-project TestIronPython
+ --build-options ${build_options} -DPython_REQUESTED_VERSION=3 -DPython_FIND_STRATEGY=VERSION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.IronPython3.VersionRange.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.LOCATION"
+ ${build_generator_args}
+ --build-project TestVersionRange
+ --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3
+ -DPython3_FIND_IMPLEMENTATIONS=IronPython
+ -DPython3_FIND_STRATEGY=LOCATION
+ )
+ add_test(NAME FindPython.IronPython3.VersionRange.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/VersionRange"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython3.VersionRange.VERSION"
+ ${build_generator_args}
+ --build-project TestVersionRange
+ --build-options ${build_options} -DPython=Python3 -DPython_REQUESTED_VERSION=3
+ -DPython3_FIND_IMPLEMENTATIONS=IronPython
+ -DPython3_FIND_STRATEGY=VERSION
+ )
+endif()
+
+if(CMake_TEST_FindPython2_IronPython OR CMake_TEST_FindPython3_IronPython)
+ add_test(NAME FindPython.IronPython.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.LOCATION"
+ ${build_generator_args}
+ --build-project TestIronPython
+ --build-options ${build_options} -DPython_FIND_STRATEGY=LOCATION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.IronPython.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/IronPython"
+ "${CMake_BINARY_DIR}/Tests/FindPython/IronPython.VERSION"
+ ${build_generator_args}
+ --build-project TestIronPython
+ --build-options ${build_options} -DPython_FIND_STRATEGY=VERSION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+endif()
+
if(CMake_TEST_FindPython2_PyPy)
add_test(NAME FindPython.PyPy2.LOCATION COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
diff --git a/Tests/FindPython/IronPython3/CMakeLists.txt b/Tests/FindPython/IronPython3/CMakeLists.txt
new file mode 100644
index 0000000..b09097a
--- /dev/null
+++ b/Tests/FindPython/IronPython3/CMakeLists.txt
@@ -0,0 +1,31 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(TestIronPython3 LANGUAGES NONE)
+
+set (Python3_FIND_IMPLEMENTATIONS "IronPython")
+
+find_package(Python3 COMPONENTS Interpreter Compiler)
+if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3")
+endif()
+
+if (NOT Python3_Interpreter_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3 Interpreter")
+endif()
+if (NOT Python3_INTERPRETER_ID STREQUAL "IronPython")
+ message (FATAL_ERROR "Erroneous interpreter ID (${Python3_INTERPRETER_ID})")
+endif()
+
+if (NOT Python3_Compiler_FOUND)
+ message (FATAL_ERROR "Failed to find Python 3 Compiler")
+endif()
+if (NOT Python3_COMPILER_ID STREQUAL "IronPython")
+ message (FATAL_ERROR "Erroneous compiler ID (${Python3_COMPILER_ID})")
+endif()
+
+if(NOT TARGET Python3::Interpreter)
+ message(SEND_ERROR "Python3::Interpreter not found")
+endif()
+if(NOT TARGET Python3::Compiler)
+ message(SEND_ERROR "Python3::Compiler not found")
+endif()