From eeb63039709f6c46bce734f70e76063576260b2e Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Mon, 22 Jan 2024 10:02:15 +0100 Subject: [PATCH] python: add FIND_SCIPY --- python.cmake | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/python.cmake b/python.cmake index baaabd4a4..8b4441e55 100644 --- a/python.cmake +++ b/python.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2021 LAAS-CNRS, JRL AIST-CNRS, INRIA. +# Copyright (C) 2008-2024 LAAS-CNRS, JRL AIST-CNRS, INRIA. # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -529,4 +529,30 @@ macro(FIND_NUMPY) endif() endmacro() +# .rst: .. command:: FIND_SCIPY() +# +# Detect scipy module. +# +macro(FIND_SCIPY) + # Detect numpy. + message(STATUS "Checking for SciPy") + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" "-c" "import scipy; print (True)" + OUTPUT_VARIABLE IS_SCIPY + ERROR_QUIET) + + if(NOT IS_SCIPY) + message(FATAL_ERROR "Failed to detect scipy") + else() + # Retrive SCIPY_VERSION + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" "-c" + "import scipy; print (scipy.__version__)" + OUTPUT_VARIABLE SCIPY_VERSION + ERROR_QUIET) + string(REGEX REPLACE "\n$" "" SCIPY_VERSION "${SCIPY_VERSION}") + message(STATUS " SCIPY_VERSION=${SCIPY_VERSION}") + endif() +endmacro() + include(${CMAKE_CURRENT_LIST_DIR}/python-helpers.cmake)