Changeset: 26462780501d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=26462780501d Added Files: cmake/Modules/FindNumPy.cmake Modified Files: CMakeLists.txt cmake/monetdb-findpackages.cmake cmake/monetdb-functions.cmake cmake/monetdb-options.cmake sql/backends/monet5/UDF/pyapi3/CMakeLists.txt Branch: mbedded Log Message:
add numpy detection for older cmake diffs (187 lines): diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ project(MonetDB VERSION "${MONETDB_VERSI set(C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 99) -if(NOT WIN32) +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0") cmake_policy(SET CMP0076 OLD) endif() @@ -416,3 +416,7 @@ include(monetdb-packages) include(CTest) add_subdirectory(ctest) + +if(CMAKE_SUMMARY) + monetdb_cmake_summary() +endif() diff --git a/cmake/Modules/FindNumPy.cmake b/cmake/Modules/FindNumPy.cmake new file mode 100644 --- /dev/null +++ b/cmake/Modules/FindNumPy.cmake @@ -0,0 +1,89 @@ +# - Find the NumPy libraries +# This module finds if NumPy is installed, and sets the following variables +# indicating where it is. +# +# TODO: Update to provide the libraries and paths for linking npymath lib. +# +# NUMPY_FOUND - was NumPy found +# NUMPY_VERSION - the version of NumPy found as a string +# NUMPY_VERSION_MAJOR - the major version number of NumPy +# NUMPY_VERSION_MINOR - the minor version number of NumPy +# NUMPY_VERSION_PATCH - the patch version number of NumPy +# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 +# NUMPY_INCLUDE_DIRS - path to the NumPy include files + +#============================================================================ +# Copyright 2012 Continuum Analytics, Inc. +# +# MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +#============================================================================ + +# Finding NumPy involves calling the Python interpreter +if(NumPy_FIND_REQUIRED) + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +else() + find_package(Python3 COMPONENTS Interpreter Development) +endif() + +if(NOT PYTHONINTERP_FOUND) + set(NUMPY_FOUND FALSE) +endif() + +execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" + "import numpy as n; print(n.__version__); print(n.get_include());" + RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS + OUTPUT_VARIABLE _NUMPY_VALUES + ERROR_VARIABLE _NUMPY_ERROR_VALUE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) + if(NumPy_FIND_REQUIRED) + message(FATAL_ERROR + "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") + endif() + set(NUMPY_FOUND FALSE) +endif() + +# Convert the process output into a list +string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES}) +string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) +list(GET _NUMPY_VALUES 0 NUMPY_VERSION) +list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) + +# Make sure all directory separators are '/' +string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) + +# Get the major and minor version numbers +string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) +list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) +list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) +list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) +string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) +math(EXPR NUMPY_VERSION_DECIMAL + "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") + +find_package_message(NUMPY + "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" + "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") + +set(NUMPY_FOUND TRUE) diff --git a/cmake/monetdb-findpackages.cmake b/cmake/monetdb-findpackages.cmake --- a/cmake/monetdb-findpackages.cmake +++ b/cmake/monetdb-findpackages.cmake @@ -7,10 +7,18 @@ #]] find_package(BISON REQUIRED) -find_package(Python3 COMPONENTS Interpreter Development NumPy) -if(Python3_Interpreter_FOUND) - set(Python_EXECUTABLE "${Python3_EXECUTABLE}") -endif(Python3_Interpreter_FOUND) +if(${CMAKE_VERSION} VERSION_LESS "3.14.0") + find_package(Python3 COMPONENTS Interpreter Development) + find_package(NumPy) + if(Python3_Interpreter_FOUND) + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + endif(Python3_Interpreter_FOUND) +else() + find_package(Python3 COMPONENTS Interpreter Development NumPy) + if(Python3_Interpreter_FOUND) + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + endif(Python3_Interpreter_FOUND) +endif() if(PY3INTEGRATION) set(HAVE_LIBPY3 "${Python3_FOUND}") endif(PY3INTEGRATION) diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake --- a/cmake/monetdb-functions.cmake +++ b/cmake/monetdb-functions.cmake @@ -77,3 +77,14 @@ function(create_include_object) PARENT_SCOPE) endif() endfunction() + +function(monetdb_cmake_summary) + message("Summary of cmake configuration of MonetDB") + message("-----------------------------------------") + if(${CMAKE_VERSION} VERSION_LESS "3.14.0") + message("NumPy include dirs: ${NUMPY_INCLUDE_DIRS}") + else() + message("Numpy target: ") + endif() + message("-----------------------------------------") +endfunction() diff --git a/cmake/monetdb-options.cmake b/cmake/monetdb-options.cmake --- a/cmake/monetdb-options.cmake +++ b/cmake/monetdb-options.cmake @@ -136,3 +136,7 @@ option(WITH_VALGRIND option(WITH_ZLIB "Include zlib support" ON) + +option(CMAKE_SUMMARY + "Show a summary of the cmake configuration (for debug purposes)" + OFF) diff --git a/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt b/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt --- a/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt +++ b/sql/backends/monet5/UDF/pyapi3/CMakeLists.txt @@ -48,12 +48,13 @@ if(PY3INTEGRATION) $<TARGET_PROPERTY:malmodules,INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:sql,INCLUDE_DIRECTORIES> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<$<VERSION_LESS:${CMAKE_VERSION},3.14.0>:${NUMPY_INCLUDE_DIRS}> $<INSTALL_INTERFACE:${INCLUDEDIR}/monetdb>) target_link_libraries(pyapi3 PRIVATE Python3::Python - Python3::NumPy + $<$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.14.0>:Python3::NumPy> mutils stream gdk _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list