build_python
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Fri, 26 Oct 2018 03:45:58 +0000 (11:45 +0800)
committerDrew Parsons <dparsons@debian.org>
Fri, 26 Oct 2018 03:45:58 +0000 (11:45 +0800)
===================================================================

Gbp-Pq: Name build_python.patch

python/CMakeLists.txt
python/cmake/Findmshr.cmake [new file with mode: 0644]
python/setup.py

index 54754e0686d2ebd22d5cd06d32e8c02f6ff97a1c..4edf5664902f22ec7ef67302e0ed700eb7c88616 100644 (file)
@@ -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 (file)
index 0000000..21737fd
--- /dev/null
@@ -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)
index 819951f20eca295afd8693c947a99c54203bbb57..2ac5df7cf305106471fb3e326639e4dd460fb33c 100644 (file)
@@ -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)