From: Debian Science Team Date: Fri, 26 Oct 2018 03:45:58 +0000 (+0800) Subject: build_python X-Git-Tag: archive/raspbian/2019.2.0_git20200924.c27eb18+dfsg1-10+rpi1~1^2^2^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=541ce2a6bcd6c5a457051acd6d967a724a1fbb9a;p=mshr.git build_python =================================================================== Gbp-Pq: Name build_python.patch --- diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 54754e0..4edf566 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -7,6 +7,8 @@ cmake_minimum_required(VERSION 3.5.0) PROJECT(mshr_pybind11_config) +# Add cmake directory to mshr module path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") # pybind11_FOUND - true if pybind11 and all required components found on the system # pybind11_VERSION - pybind11 version in format Major.Minor.Release @@ -23,7 +25,7 @@ find_package(pybind11 CONFIG HINTS ${PYBIND11_DIR} ${PYBIND11_ROOT} find_package(DOLFIN) -find_package(mshr) +find_package(mshr MODULE) configure_file("config.json.in" "config.json") diff --git a/python/cmake/Findmshr.cmake b/python/cmake/Findmshr.cmake new file mode 100644 index 0000000..21737fd --- /dev/null +++ b/python/cmake/Findmshr.cmake @@ -0,0 +1,51 @@ +#.rst: +# Findmshr +# -------- +# +# Find mshr library +# +# Find the mshr includes and library. This module defines +# +# :: +# +# mshr_INCLUDE_DIRS, where to find mshr.h. +# mshr_LIBRARIES, libraries to link against to use mshr +# mshr_FOUND, If false (0), do not try to use mshr. +# +# +# +# +# +#============================================================================= +find_path(mshr_INCLUDE_DIR mshr.h + DOC "The mshr include directory") + +set(mshr_NAMES ${mshr_NAMES} libmshr mshr) +find_library(mshr_LIBRARY NAMES ${mshr_NAMES} + DOC "The mshr library") + +# handle the QUIETLY and REQUIRED arguments and set mshr_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(mshr + REQUIRED_VARS mshr_LIBRARY + mshr_INCLUDE_DIR + VERSION_VAR mshr_VERSION_STRING) + +if(mshr_FOUND) + # FIND_PACKAGE_HANDLE_STANDARD_ARGS sets mshr_FOUND to TRUE not 1 + # which interferes with the json in config.json (must be true not TRUE) + # So set to 1 (following find_package(DOLFIN) ) + set( mshr_FOUND 1 ) + # use by setuptools.Extension, mshr_LIBRARIES must be in a form that appends to -l + # i.e. mshr not libmshr.so + set( mshr_LIBRARIES "mshr" ) + get_filename_component( mshr_LIBRARIES_DIRS ${mshr_LIBRARY} DIRECTORY ) + set( mshr_INCLUDE_DIRS ${mshr_INCLUDE_DIR} ) +else() + set( mshr_FOUND 0) + set( mshr_LIBRARIES_DIRS "." ) + set( mshr_INCLUDE_DIRS "." ) +endif() + +mark_as_advanced(mshr_INCLUDE_DIR mshr_LIBRARY) diff --git a/python/setup.py b/python/setup.py index 819951f..2ac5df7 100644 --- a/python/setup.py +++ b/python/setup.py @@ -9,7 +9,10 @@ from setuptools import setup, Extension if not os.path.isfile(os.path.join("build", "config.json")) : if not os.path.exists("build") : os.mkdir("build") - subprocess.check_call(["cmake", os.getcwd()], cwd=os.path.abspath("build")) + cmake_command=["cmake", os.getcwd()] + if os.environ.get('CMAKE_PREFIX_PATH'): + cmake_command.extend(['-DCMAKE_PREFIX_PATH={}'.format(os.environ['CMAKE_PREFIX_PATH'])]) + subprocess.check_call(cmake_command, cwd=os.path.abspath("build")) with open(os.path.join("build", "config.json"), 'r') as infile : config = json.load(infile)