|
1 | 1 | cmake_minimum_required(VERSION 3.12) |
2 | 2 | project(python3-test) |
3 | 3 |
|
4 | | -set(Python_ARTIFACTS_PREFIX "_MEOW") |
5 | | - |
6 | | -# We need to opt-out of CMP0148 to be able to test the pre-CMake 3.12 Python |
7 | | -# find modules. The old policy is deprecated, so, at some point, this aspect |
8 | | -# of the test will have to go away. |
9 | | -if(POLICY CMP0148) |
10 | | - cmake_policy(SET CMP0148 OLD) |
11 | | -endif() |
| 4 | +if("${CMAKE_VERSION}" VERSION_LESS "4.0") |
| 5 | + # We need to opt-out of CMP0148 to be able to test the pre-CMake 3.12 Python |
| 6 | + # find modules. The old policy is deprecated, so, at some point, this aspect |
| 7 | + # of the test will have to go away. |
| 8 | + if(POLICY CMP0148) |
| 9 | + cmake_policy(SET CMP0148 OLD) |
| 10 | + endif() |
12 | 11 |
|
13 | | -# The purpose of this test is to ensure that we get the expected values |
14 | | -# from the finders, not crosscompiling. So, let's not even go there. |
15 | | -# These find_package() calls aren't required because FindPythonInterp |
16 | | -# seems to not return a result in CI. Probably because FindPythonInterp |
17 | | -# prefers the system Python instead of the executable from the python3 |
18 | | -# port. |
19 | | -if(NOT CMAKE_CROSSCOMPILING) |
20 | | - find_package(PythonInterp) |
21 | | -endif() |
22 | | -find_package(PythonLibs) |
| 12 | + # The purpose of this test is to ensure that we get the expected values |
| 13 | + # from the finders, not crosscompiling. So, let's not even go there. |
| 14 | + # These find_package() calls aren't required because FindPythonInterp |
| 15 | + # seems to not return a result in CI. Probably because FindPythonInterp |
| 16 | + # prefers the system Python instead of the executable from the python3 |
| 17 | + # port. |
| 18 | + if(NOT CMAKE_CROSSCOMPILING) |
| 19 | + find_package(PythonInterp) |
| 20 | + endif() |
| 21 | + find_package(PythonLibs) |
23 | 22 |
|
24 | | -# The old find modules should NOT be prefixed. |
25 | | -if(DEFINED PythonInterp_MEOW_FOUND OR DEFINED PYTHON_MEOW_EXECUTABLE) |
26 | | - message(FATAL_ERROR "FindPythonInterp prefixed the result variables") |
27 | | -endif() |
28 | | -if(DEFINED PythonLibs_MEOW_FOUND OR DEFINED PYTHON_MEOW_LIBRARIES) |
29 | | - message(FATAL_ERROR "FindPythonLibs prefixed the result variables") |
| 23 | + # The old find modules should NOT be prefixed. |
| 24 | + if(DEFINED PythonInterp_MEOW_FOUND OR DEFINED PYTHON_MEOW_EXECUTABLE) |
| 25 | + message(FATAL_ERROR "FindPythonInterp prefixed the result variables") |
| 26 | + endif() |
| 27 | + if(DEFINED PythonLibs_MEOW_FOUND OR DEFINED PYTHON_MEOW_LIBRARIES) |
| 28 | + message(FATAL_ERROR "FindPythonLibs prefixed the result variables") |
| 29 | + endif() |
30 | 30 | endif() |
31 | 31 |
|
32 | 32 | function(test_result NAME TYPE EXPECTED UNEXPECTED) |
@@ -55,13 +55,8 @@ endif() |
55 | 55 |
|
56 | 56 | # The new find modules should be prefixed if CMake is 4.0+ |
57 | 57 | find_package(Python REQUIRED COMPONENTS ${_INTERPRETER} Development) |
58 | | -if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.0) |
59 | | - set(EXPECTED_PYTHON Python_MEOW) |
60 | | - set(UNEXPECTED_PYTHON Python) |
61 | | -else() |
62 | | - set(EXPECTED_PYTHON Python) |
63 | | - set(UNEXPECTED_PYTHON Python_MEOW) |
64 | | -endif() |
| 58 | +set(EXPECTED_PYTHON Python) |
| 59 | +set(UNEXPECTED_PYTHON Python_MEOW) |
65 | 60 | test_new_finder(${EXPECTED_PYTHON} ${UNEXPECTED_PYTHON}) |
66 | 61 |
|
67 | 62 | # Also test non-prefixed. Use Python3:: to avoid conflicts with Python_MEOW:: |
|
0 commit comments