mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 03:11:08 -06:00
Since commit 5537ccd814 (FindPython: Tests optimizations, 2020-10-01)
some FindPython tests fail because the Development component cannot be
found without knowing `CMAKE_LIBRARY_ARCHITECTURE`. Enable at least one
language in each of these test cases to get that value. This is
consistent with use in practice because the Development component does
not make much sense without a language to compile sources anyway.
Fixes: #21277
23 lines
1021 B
CMake
23 lines
1021 B
CMake
cmake_minimum_required(VERSION 3.1)
|
|
|
|
project(TestNumPy LANGUAGES C)
|
|
|
|
find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy)
|
|
find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
|
|
|
|
Python2_add_library (arraytest2 MODULE arraytest.c)
|
|
target_compile_definitions (arraytest2 PRIVATE PYTHON2)
|
|
target_link_libraries (arraytest2 PRIVATE Python2::NumPy)
|
|
|
|
Python3_add_library (arraytest3 MODULE arraytest.c)
|
|
target_compile_definitions (arraytest3 PRIVATE PYTHON3)
|
|
target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
|
|
|
|
add_test (NAME python2_arraytest
|
|
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>"
|
|
"${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
|
|
|
|
add_test (NAME python3_arraytest
|
|
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>"
|
|
"${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
|