[mlpack] 43/58: A first draft of a smarter FindArmadillo script, which takes into account whether or not ARMA_USE_WRAPPER is being used.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Tue Sep 9 13:19:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit dfda3cbf02313b1416ddffe501795f56ff3e181f
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Fri Aug 22 20:55:17 2014 +0000

    A first draft of a smarter FindArmadillo script, which takes into account
    whether or not ARMA_USE_WRAPPER is being used.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17099 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 CMake/ARMA_FindACML.cmake     |  37 ++++++++
 CMake/ARMA_FindACMLMP.cmake   |  37 ++++++++
 CMake/ARMA_FindARPACK.cmake   |  39 ++++++++
 CMake/ARMA_FindBLAS.cmake     |  37 ++++++++
 CMake/ARMA_FindCBLAS.cmake    |  47 ++++++++++
 CMake/ARMA_FindCLAPACK.cmake  |  48 ++++++++++
 CMake/ARMA_FindLAPACK.cmake   |  37 ++++++++
 CMake/ARMA_FindMKL.cmake      |  49 ++++++++++
 CMake/ARMA_FindOpenBLAS.cmake |  37 ++++++++
 CMake/FindArmadillo.cmake     | 212 +++++++++++++++++++++++++++++++++++++-----
 10 files changed, 555 insertions(+), 25 deletions(-)

diff --git a/CMake/ARMA_FindACML.cmake b/CMake/ARMA_FindACML.cmake
new file mode 100644
index 0000000..784b6d5
--- /dev/null
+++ b/CMake/ARMA_FindACML.cmake
@@ -0,0 +1,37 @@
+# - Find AMD's ACML library (no includes) which provides optimised BLAS and LAPACK functions
+# This module defines
+#  ACML_LIBRARIES, the libraries needed to use ACML.
+#  ACML_FOUND, If false, do not try to use ACML.
+# also defined, but not for general use are
+#  ACML_LIBRARY, where to find the ACML library.
+
+SET(ACML_NAMES ${ACML_NAMES} acml)
+FIND_LIBRARY(ACML_LIBRARY
+  NAMES ${ACML_NAMES}
+  PATHS /usr/lib64 /usr/lib /usr/*/lib64 /usr/*/lib /usr/*/gfortran64/lib/ /usr/*/gfortran32/lib/ /usr/local/lib64 /usr/local/lib /opt/lib64 /opt/lib /opt/*/lib64 /opt/*/lib /opt/*/gfortran64/lib/ /opt/*/gfortran32/lib/
+  )
+
+IF (ACML_LIBRARY)
+  SET(ACML_LIBRARIES ${ACML_LIBRARY})
+  SET(ACML_FOUND "YES")
+ELSE (ACML_LIBRARY)
+  SET(ACML_FOUND "NO")
+ENDIF (ACML_LIBRARY)
+
+
+IF (ACML_FOUND)
+   IF (NOT ACML_FIND_QUIETLY)
+      MESSAGE(STATUS "Found the ACML library: ${ACML_LIBRARIES}")
+   ENDIF (NOT ACML_FIND_QUIETLY)
+ELSE (ACML_FOUND)
+   IF (ACML_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find the ACML library")
+   ENDIF (ACML_FIND_REQUIRED)
+ENDIF (ACML_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_ACML_LIB_PATH ${ACML_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  ACML_LIBRARY
+  )
diff --git a/CMake/ARMA_FindACMLMP.cmake b/CMake/ARMA_FindACMLMP.cmake
new file mode 100644
index 0000000..a075554
--- /dev/null
+++ b/CMake/ARMA_FindACMLMP.cmake
@@ -0,0 +1,37 @@
+# - Find AMD's ACMLMP library (no includes) which provides optimised and parallelised BLAS and LAPACK functions
+# This module defines
+#  ACMLMP_LIBRARIES, the libraries needed to use ACMLMP.
+#  ACMLMP_FOUND, If false, do not try to use ACMLMP.
+# also defined, but not for general use are
+#  ACMLMP_LIBRARY, where to find the ACMLMP library.
+
+SET(ACMLMP_NAMES ${ACMLMP_NAMES} acml_mp)
+FIND_LIBRARY(ACMLMP_LIBRARY
+  NAMES ${ACMLMP_NAMES}
+  PATHS /usr/lib64 /usr/lib /usr/*/lib64 /usr/*/lib /usr/*/gfortran64_mp/lib/ /usr/*/gfortran32_mp/lib/ /usr/local/lib64 /usr/local/lib /opt/lib64 /opt/lib /opt/*/lib64 /opt/*/lib /opt/*/gfortran64_mp/lib/ /opt/*/gfortran32_mp/lib/
+  )
+
+IF (ACMLMP_LIBRARY)
+  SET(ACMLMP_LIBRARIES ${ACMLMP_LIBRARY})
+  SET(ACMLMP_FOUND "YES")
+ELSE (ACMLMP_LIBRARY)
+  SET(ACMLMP_FOUND "NO")
+ENDIF (ACMLMP_LIBRARY)
+
+
+IF (ACMLMP_FOUND)
+   IF (NOT ACMLMP_FIND_QUIETLY)
+      MESSAGE(STATUS "Found the ACMLMP library: ${ACMLMP_LIBRARIES}")
+   ENDIF (NOT ACMLMP_FIND_QUIETLY)
+ELSE (ACMLMP_FOUND)
+   IF (ACMLMP_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find the ACMLMP library")
+   ENDIF (ACMLMP_FIND_REQUIRED)
+ENDIF (ACMLMP_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_ACMLMP_LIB_PATH ${ACMLMP_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  ACMLMP_LIBRARY
+  )
diff --git a/CMake/ARMA_FindARPACK.cmake b/CMake/ARMA_FindARPACK.cmake
new file mode 100644
index 0000000..afd791a
--- /dev/null
+++ b/CMake/ARMA_FindARPACK.cmake
@@ -0,0 +1,39 @@
+# - Try to find ARPACK
+# Once done this will define
+#
+#  ARPACK_FOUND        - system has ARPACK
+#  ARPACK_LIBRARY      - Link this to use ARPACK
+
+
+find_library(ARPACK_LIBRARY
+  NAMES arpack
+  PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
+  )
+
+
+IF (ARPACK_LIBRARY)
+  SET(ARPACK_FOUND YES)
+ELSE ()
+  # Search for PARPACK.
+  find_library(ARPACK_LIBRARY
+    NAMES parpack
+    PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
+  )
+
+  IF (ARPACK_LIBRARY)
+    SET(ARPACK_FOUND YES)
+  ELSE ()
+    SET(ARPACK_FOUND NO)
+  ENDIF ()
+ENDIF ()
+
+
+IF (ARPACK_FOUND)
+  IF (NOT ARPACK_FIND_QUIETLY)
+     MESSAGE(STATUS "Found an ARPACK library: ${ARPACK_LIBRARY}")
+  ENDIF (NOT ARPACK_FIND_QUIETLY)
+ELSE (ARPACK_FOUND)
+  IF (ARPACK_FIND_REQUIRED)
+     MESSAGE(FATAL_ERROR "Could not find an ARPACK library")
+  ENDIF (ARPACK_FIND_REQUIRED)
+ENDIF (ARPACK_FOUND)
diff --git a/CMake/ARMA_FindBLAS.cmake b/CMake/ARMA_FindBLAS.cmake
new file mode 100644
index 0000000..e757ac1
--- /dev/null
+++ b/CMake/ARMA_FindBLAS.cmake
@@ -0,0 +1,37 @@
+# - Find a BLAS library (no includes)
+# This module defines
+#  BLAS_LIBRARIES, the libraries needed to use BLAS.
+#  BLAS_FOUND, If false, do not try to use BLAS.
+# also defined, but not for general use are
+#  BLAS_LIBRARY, where to find the BLAS library.
+
+SET(BLAS_NAMES ${BLAS_NAMES} blas)
+FIND_LIBRARY(BLAS_LIBRARY
+  NAMES ${BLAS_NAMES}
+  PATHS /usr/lib64/atlas /usr/lib/atlas /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
+  )
+
+IF (BLAS_LIBRARY)
+  SET(BLAS_LIBRARIES ${BLAS_LIBRARY})
+  SET(BLAS_FOUND "YES")
+ELSE (BLAS_LIBRARY)
+  SET(BLAS_FOUND "NO")
+ENDIF (BLAS_LIBRARY)
+
+
+IF (BLAS_FOUND)
+   IF (NOT BLAS_FIND_QUIETLY)
+      MESSAGE(STATUS "Found a BLAS library: ${BLAS_LIBRARIES}")
+   ENDIF (NOT BLAS_FIND_QUIETLY)
+ELSE (BLAS_FOUND)
+   IF (BLAS_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find a BLAS library")
+   ENDIF (BLAS_FIND_REQUIRED)
+ENDIF (BLAS_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_BLAS_LIB_PATH ${BLAS_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  BLAS_LIBRARY
+  )
diff --git a/CMake/ARMA_FindCBLAS.cmake b/CMake/ARMA_FindCBLAS.cmake
new file mode 100644
index 0000000..ccd2133
--- /dev/null
+++ b/CMake/ARMA_FindCBLAS.cmake
@@ -0,0 +1,47 @@
+# - Find CBLAS (includes and library)
+# This module defines
+#  CBLAS_INCLUDE_DIR
+#  CBLAS_LIBRARIES
+#  CBLAS_FOUND
+# also defined, but not for general use are
+#  CBLAS_LIBRARY, where to find the library.
+
+FIND_PATH(CBLAS_INCLUDE_DIR cblas.h
+/usr/include/atlas/
+/usr/local/include/atlas/
+/usr/include/
+/usr/local/include/
+)
+
+SET(CBLAS_NAMES ${CBLAS_NAMES} cblas)
+FIND_LIBRARY(CBLAS_LIBRARY
+  NAMES ${CBLAS_NAMES}
+  PATHS /usr/lib64/atlas-sse3 /usr/lib64/atlas /usr/lib64 /usr/local/lib64/atlas /usr/local/lib64 /usr/lib/atlas-sse3 /usr/lib/atlas-sse2 /usr/lib/atlas-sse /usr/lib/atlas-3dnow /usr/lib/atlas /usr/lib /usr/local/lib/atlas /usr/local/lib
+  )
+
+IF (CBLAS_LIBRARY AND CBLAS_INCLUDE_DIR)
+    SET(CBLAS_LIBRARIES ${CBLAS_LIBRARY})
+    SET(CBLAS_FOUND "YES")
+ELSE (CBLAS_LIBRARY AND CBLAS_INCLUDE_DIR)
+  SET(CBLAS_FOUND "NO")
+ENDIF (CBLAS_LIBRARY AND CBLAS_INCLUDE_DIR)
+
+
+IF (CBLAS_FOUND)
+   IF (NOT CBLAS_FIND_QUIETLY)
+      MESSAGE(STATUS "Found a CBLAS library: ${CBLAS_LIBRARIES}")
+   ENDIF (NOT CBLAS_FIND_QUIETLY)
+ELSE (CBLAS_FOUND)
+   IF (CBLAS_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find a CBLAS library")
+   ENDIF (CBLAS_FIND_REQUIRED)
+ENDIF (CBLAS_FOUND)
+
+# Deprecated declarations.
+SET (NATIVE_CBLAS_INCLUDE_PATH ${CBLAS_INCLUDE_DIR} )
+GET_FILENAME_COMPONENT (NATIVE_CBLAS_LIB_PATH ${CBLAS_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  CBLAS_LIBRARY
+  CBLAS_INCLUDE_DIR
+  )
diff --git a/CMake/ARMA_FindCLAPACK.cmake b/CMake/ARMA_FindCLAPACK.cmake
new file mode 100644
index 0000000..99dadae
--- /dev/null
+++ b/CMake/ARMA_FindCLAPACK.cmake
@@ -0,0 +1,48 @@
+# - Find a version of CLAPACK (includes and library)
+# This module defines
+#  CLAPACK_INCLUDE_DIR
+#  CLAPACK_LIBRARIES
+#  CLAPACK_FOUND
+# also defined, but not for general use are
+#  CLAPACK_LIBRARY, where to find the library.
+
+FIND_PATH(CLAPACK_INCLUDE_DIR clapack.h
+/usr/include/atlas/
+/usr/local/include/atlas/
+/usr/include/
+/usr/local/include/
+)
+
+SET(CLAPACK_NAMES ${CLAPACK_NAMES} lapack_atlas)
+SET(CLAPACK_NAMES ${CLAPACK_NAMES} clapack)
+FIND_LIBRARY(CLAPACK_LIBRARY
+  NAMES ${CLAPACK_NAMES}
+  PATHS /usr/lib64/atlas-sse3 /usr/lib64/atlas /usr/lib64 /usr/local/lib64/atlas /usr/local/lib64 /usr/lib/atlas-sse3 /usr/lib/atlas-sse2 /usr/lib/atlas-sse /usr/lib/atlas-3dnow /usr/lib/atlas /usr/lib /usr/local/lib/atlas /usr/local/lib
+  )
+
+IF (CLAPACK_LIBRARY AND CLAPACK_INCLUDE_DIR)
+    SET(CLAPACK_LIBRARIES ${CLAPACK_LIBRARY})
+    SET(CLAPACK_FOUND "YES")
+ELSE (CLAPACK_LIBRARY AND CLAPACK_INCLUDE_DIR)
+  SET(CLAPACK_FOUND "NO")
+ENDIF (CLAPACK_LIBRARY AND CLAPACK_INCLUDE_DIR)
+
+
+IF (CLAPACK_FOUND)
+   IF (NOT CLAPACK_FIND_QUIETLY)
+      MESSAGE(STATUS "Found a CLAPACK library: ${CLAPACK_LIBRARIES}")
+   ENDIF (NOT CLAPACK_FIND_QUIETLY)
+ELSE (CLAPACK_FOUND)
+   IF (CLAPACK_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find a CLAPACK library")
+   ENDIF (CLAPACK_FIND_REQUIRED)
+ENDIF (CLAPACK_FOUND)
+
+# Deprecated declarations.
+SET (NATIVE_CLAPACK_INCLUDE_PATH ${CLAPACK_INCLUDE_DIR} )
+GET_FILENAME_COMPONENT (NATIVE_CLAPACK_LIB_PATH ${CLAPACK_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  CLAPACK_LIBRARY
+  CLAPACK_INCLUDE_DIR
+  )
diff --git a/CMake/ARMA_FindLAPACK.cmake b/CMake/ARMA_FindLAPACK.cmake
new file mode 100644
index 0000000..b8e9342
--- /dev/null
+++ b/CMake/ARMA_FindLAPACK.cmake
@@ -0,0 +1,37 @@
+# - Find a LAPACK library (no includes)
+# This module defines
+#  LAPACK_LIBRARIES, the libraries needed to use LAPACK.
+#  LAPACK_FOUND, If false, do not try to use LAPACK.
+# also defined, but not for general use are
+#  LAPACK_LIBRARY, where to find the LAPACK library.
+
+SET(LAPACK_NAMES ${LAPACK_NAMES} lapack)
+FIND_LIBRARY(LAPACK_LIBRARY
+  NAMES ${LAPACK_NAMES}
+  PATHS /usr/lib64/atlas /usr/lib/atlas /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
+  )
+
+IF (LAPACK_LIBRARY)
+  SET(LAPACK_LIBRARIES ${LAPACK_LIBRARY})
+  SET(LAPACK_FOUND "YES")
+ELSE (LAPACK_LIBRARY)
+  SET(LAPACK_FOUND "NO")
+ENDIF (LAPACK_LIBRARY)
+
+
+IF (LAPACK_FOUND)
+   IF (NOT LAPACK_FIND_QUIETLY)
+      MESSAGE(STATUS "Found a LAPACK library: ${LAPACK_LIBRARIES}")
+   ENDIF (NOT LAPACK_FIND_QUIETLY)
+ELSE (LAPACK_FOUND)
+   IF (LAPACK_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find a LAPACK library")
+   ENDIF (LAPACK_FIND_REQUIRED)
+ENDIF (LAPACK_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_LAPACK_LIB_PATH ${LAPACK_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  LAPACK_LIBRARY
+  )
diff --git a/CMake/ARMA_FindMKL.cmake b/CMake/ARMA_FindMKL.cmake
new file mode 100644
index 0000000..1f8b8eb
--- /dev/null
+++ b/CMake/ARMA_FindMKL.cmake
@@ -0,0 +1,49 @@
+# - Find the MKL libraries (no includes)
+# This module defines
+#  MKL_LIBRARIES, the libraries needed to use Intel's implementation of BLAS & LAPACK.
+#  MKL_FOUND, If false, do not try to use MKL.
+
+SET(MKL_NAMES ${MKL_NAMES} mkl_lapack)
+SET(MKL_NAMES ${MKL_NAMES} mkl_intel_thread)
+SET(MKL_NAMES ${MKL_NAMES} mkl_core)
+SET(MKL_NAMES ${MKL_NAMES} guide)
+SET(MKL_NAMES ${MKL_NAMES} mkl)
+SET(MKL_NAMES ${MKL_NAMES} iomp5)
+#SET(MKL_NAMES ${MKL_NAMES} pthread)
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+  SET(MKL_NAMES ${MKL_NAMES} mkl_intel_lp64)
+ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
+  SET(MKL_NAMES ${MKL_NAMES} mkl_intel)
+ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+
+FOREACH (MKL_NAME ${MKL_NAMES})
+  FIND_LIBRARY(${MKL_NAME}_LIBRARY
+    NAMES ${MKL_NAME}
+    PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/intel/lib/intel64 /opt/intel/lib/ia32 /opt/intel/mkl/lib/lib64 /opt/intel/mkl/lib/intel64 /opt/intel/mkl/lib/ia32 /opt/intel/mkl/lib /opt/intel/*/mkl/lib/intel64 /opt/intel/*/mkl/lib/ia32/ /opt/mkl/*/lib/em64t /opt/mkl/*/lib/32 /opt/intel/mkl/*/lib/em64t /opt/intel/mkl/*/lib/32
+    )
+
+  SET(TMP_LIBRARY ${${MKL_NAME}_LIBRARY})
+
+  IF(TMP_LIBRARY)
+    SET(MKL_LIBRARIES ${MKL_LIBRARIES} ${TMP_LIBRARY})
+  ENDIF(TMP_LIBRARY)
+ENDFOREACH(MKL_NAME)
+
+IF (MKL_LIBRARIES)
+  SET(MKL_FOUND "YES")
+ELSE (MKL_LIBRARIES)
+  SET(MKL_FOUND "NO")
+ENDIF (MKL_LIBRARIES)
+
+IF (MKL_FOUND)
+  IF (NOT MKL_FIND_QUIETLY)
+    MESSAGE(STATUS "Found MKL libraries: ${MKL_LIBRARIES}")
+  ENDIF (NOT MKL_FIND_QUIETLY)
+ELSE (MKL_FOUND)
+  IF (MKL_FIND_REQUIRED)
+    MESSAGE(FATAL_ERROR "Could not find MKL libraries")
+  ENDIF (MKL_FIND_REQUIRED)
+ENDIF (MKL_FOUND)
+
+# MARK_AS_ADVANCED(MKL_LIBRARY)
diff --git a/CMake/ARMA_FindOpenBLAS.cmake b/CMake/ARMA_FindOpenBLAS.cmake
new file mode 100644
index 0000000..b42abe6
--- /dev/null
+++ b/CMake/ARMA_FindOpenBLAS.cmake
@@ -0,0 +1,37 @@
+# - Find the OpenBLAS library (no includes)
+# This module defines
+#  OpenBLAS_LIBRARIES, the libraries needed to use OpenBLAS.
+#  OpenBLAS_FOUND, If false, do not try to use OpenBLAS.
+# also defined, but not for general use are
+#  OpenBLAS_LIBRARY, where to find the OpenBLAS library.
+
+SET(OpenBLAS_NAMES ${OpenBLAS_NAMES} openblas)
+FIND_LIBRARY(OpenBLAS_LIBRARY
+  NAMES ${OpenBLAS_NAMES}
+  PATHS /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
+  )
+
+IF (OpenBLAS_LIBRARY)
+  SET(OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY})
+  SET(OpenBLAS_FOUND "YES")
+ELSE (OpenBLAS_LIBRARY)
+  SET(OpenBLAS_FOUND "NO")
+ENDIF (OpenBLAS_LIBRARY)
+
+
+IF (OpenBLAS_FOUND)
+   IF (NOT OpenBLAS_FIND_QUIETLY)
+      MESSAGE(STATUS "Found the OpenBLAS library: ${OpenBLAS_LIBRARIES}")
+   ENDIF (NOT OpenBLAS_FIND_QUIETLY)
+ELSE (OpenBLAS_FOUND)
+   IF (OpenBLAS_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find the OpenBLAS library")
+   ENDIF (OpenBLAS_FIND_REQUIRED)
+ENDIF (OpenBLAS_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_OpenBLAS_LIB_PATH ${OpenBLAS_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  OpenBLAS_LIBRARY
+  )
diff --git a/CMake/FindArmadillo.cmake b/CMake/FindArmadillo.cmake
index 21cd335..288fc68 100644
--- a/CMake/FindArmadillo.cmake
+++ b/CMake/FindArmadillo.cmake
@@ -30,11 +30,6 @@
 #  License text for the above reference.)
 
 
-# UNIX paths are standard, no need to write.
-find_library(ARMADILLO_LIBRARY
-  NAMES armadillo
-  PATHS "$ENV{ProgramFiles}/Armadillo/lib"  "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
-  )
 find_path(ARMADILLO_INCLUDE_DIR
   NAMES armadillo
   PATHS "$ENV{ProgramFiles}/Armadillo/include"
@@ -74,34 +69,201 @@ endif (ARMADILLO_INCLUDE_DIR)
 
 #======================
 
-# Determine whether or not we need to link against HDF5.  We need to look in
-# config.hpp.
+# Determine what support libraries are being used, and whether or not we need to
+# link against them.  We need to look in config.hpp.
+set(SUPPORT_INCLUDE_DIRS "")
+set(SUPPORT_LIBRARIES "")
+set(ARMA_NEED_LIBRARY true) # Assume true.
 if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
-  # Look for #define ARMA_USE_HDF5.
   file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp" _armadillo_CONFIG_CONTENTS)
-  string(REGEX MATCH "[\r\n][\t ]*#define[ \t]+ARMA_USE_HDF5[ \t\r\n]" ARMA_USE_HDF5 "${_armadillo_CONFIG_CONTENTS}")
+  # ARMA_USE_WRAPPER
+  string(REGEX MATCH "\r?\n[\t ]*#define[ \t]+ARMA_USE_WRAPPER[ \t]*\r?\n" ARMA_USE_WRAPPER "${_armadillo_CONFIG_CONTENTS}")
 
-  if(NOT "${ARMA_USE_HDF5}" STREQUAL "")
-    message(STATUS "Armadillo HDF5 support is enabled.")
-    # We have HDF5 support and need to link against HDF5.
-    find_package(HDF5 REQUIRED)
-  endif(NOT "${ARMA_USE_HDF5}" STREQUAL "")
-endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
+  # ARMA_USE_LAPACK
+  string(REGEX MATCH "\r?\n[\t ]*#define[ \t]+ARMA_USE_LAPACK[ \t]*\r?\n" ARMA_USE_LAPACK "${_armadillo_CONFIG_CONTENTS}")
 
-#======================
+  # ARMA_USE_BLAS
+  string(REGEX MATCH "\r?\n[\t ]*#define[ \t]+ARMA_USE_BLAS[ \t]*\r?\n" ARMA_USE_BLAS "${_armadillo_CONFIG_CONTENTS}")
+    # ARMA_USE_ARPACK
+  # ARMA_USE_ARPACK
+  string(REGEX MATCH "\r?\n[\t ]*#define[ \t]+ARMA_USE_ARPACK[ \t]*\r?\n" ARMA_USE_ARPACK "${_armadillo_CONFIG_CONTENTS}")
+
+  # Look for #define ARMA_USE_HDF5.
+  string(REGEX MATCH "\r?\n[\t ]*#define[ \t]+ARMA_USE_HDF5[ \t]*\r?\n" ARMA_USE_HDF5 "${_armadillo_CONFIG_CONTENTS}")
+
+  # If we aren't wrapping, things get a little more complex.
+  if("${ARMA_USE_WRAPPER}" STREQUAL "")
+    set(ARMA_NEED_LIBRARY false)
+    message(STATUS "ARMA_USE_WRAPPER is not defined, so all dependencies of "
+                   "Armadillo must be manually linked.")
+
+    set(HAVE_LAPACK false)
+    set(HAVE_BLAS   false)
+
+    # Search for LAPACK/BLAS (or replacement).
+    if ((NOT "${ARMA_USE_LAPACK}" STREQUAL "") AND
+        (NOT "${ARMA_USE_BLAS}" STREQUAL ""))
+      # In order of preference: MKL, ACML, OpenBLAS, ATLAS
+      include(ARMA_FindMKL)
+      include(ARMA_FindACMLMP)
+      include(ARMA_FindACML)
+
+      if (MKL_FOUND)
+        message(STATUS "Using MKL for LAPACK/BLAS: ${MKL_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${MKL_LIBRARIES}")
+        set(HAVE_LAPACK true)
+        set(HAVE_BLAS   true)
+      elseif (ACMLMP_FOUND)
+        message(STATUS "Using multi-core ACML libraries for LAPACK/BLAS:
+            ${ACMLMP_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${ACMLMP_LIBRARIES}")
+        set(HAVE_LAPACK true)
+        set(HAVE_BLAS   true)
+      elseif (ACML_FOUND)
+        message(STATUS "Using ACML for LAPACK/BLAS: ${ACML_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${ACML_LIBRARIES}")
+        set(HAVE_LAPACK true)
+        set(HAVE_BLAS   true)
+      endif ()
+    endif ((NOT "${ARMA_USE_LAPACK}" STREQUAL "") AND
+           (NOT "${ARMA_USE_BLAS}" STREQUAL ""))
+
+    # If we haven't found BLAS, try.
+    if (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT HAVE_BLAS)
+      # Search for BLAS.
+      include(ARMA_FindOpenBLAS)
+      include(ARMA_FindCBLAS)
+      include(ARMA_FindBLAS)
+
+      if (OpenBLAS_FOUND)
+        # Warn if ATLAS is found also.
+        if (CBLAS_FOUND)
+          message(STATUS "Warning: both OpenBLAS and ATLAS have been found; "
+              "ATLAS will not be used.")
+        endif (CBLAS_FOUND)
+        message(STATUS "Using OpenBLAS for BLAS: ${OpenBLAS_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${OpenBLAS_LIBRARIES}")
+        set(HAVE_BLAS true)
+      elseif (CBLAS_FOUND)
+        message(STATUS "Using ATLAS for BLAS: ${CBLAS_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${CBLAS_LIBRARIES}")
+        set(SUPPORT_INCLUDE_DIRS "${SUPPORT_INCLUDE_DIRS}"
+            "${CBLAS_INCLUDE_DIR}")
+        set(HAVE_BLAS true)
+      elseif (BLAS_FOUND)
+        message(STATUS "Using standard BLAS: ${BLAS_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${BLAS_LIBRARIES}")
+        set(HAVE_BLAS true)
+      endif ()
+    endif (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT HAVE_BLAS)
+
+    # If we haven't found LAPACK, try.
+    if (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT HAVE_LAPACK)
+      # Search for LAPACK.
+      include(ARMA_FindCLAPACK)
+      include(ARMA_FindLAPACK)
+
+      # Only use ATLAS if OpenBLAS isn't being used.
+      if (CLAPACK_FOUND AND NOT OpenBLAS_FOUND)
+        message(STATUS "Using ATLAS for LAPACK: ${CLAPACK_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${CLAPACK_LIBRARIES}")
+        set(SUPPORT_INCLUDE_DIRS "${SUPPORT_INCLUDE_DIRS}"
+            "${CLAPACK_INCLUDE_DIR}")
+        set(HAVE_LAPACK true)
+      elseif (LAPACK_FOUND)
+        message(STATUS "Using standard LAPACK: ${LAPACK_LIBRARIES}")
+
+        set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${LAPACK_LIBRARIES}")
+        set(HAVE_LAPACK true)
+      endif ()
+    endif (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT HAVE_LAPACK)
+
+    if (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT LAPACK_FOUND)
+      message(FATAL "Cannot find LAPACK library, but ARMA_USE_LAPACK is set. "
+                    "Try specifying LAPACK libraries manually by setting the "
+                    "LAPACK_LIBRARY variable.")
+    endif (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT LAPACK_FOUND)
+
+    if (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT BLAS_FOUND)
+      message(FATAL "Cannot find BLAS library, but ARMA_USE_BLAS is set.  Try "
+                    "specifying BLAS libraries manually by setting the "
+                    "BLAS_LIBRARY variable.")
+    endif (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT BLAS_FOUND)
+
+    # Search for ARPACK (or replacement).
+    if (NOT "${ARMA_USE_ARPACK}" STREQUAL "")
+      # Use Armadillo ARPACK-finding procedure.
+      include(ARMA_FindARPACK)
+
+      if (NOT ARPACK_FOUND)
+        message(ERROR "ARMA_USE_ARPACK is defined in armadillo_bits/config.hpp,"
+                      " but ARPACK cannot be found.  Try specifying "
+                      "ARPACK_LIBRARY.")
+      endif (NOT ARPACK_FOUND)
+
+      set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${ARPACK_LIBRARY}")
+    endif (NOT "${ARMA_USE_ARPACK}" STREQUAL "")
+
+    # Search for HDF5 (or replacement).
+    if (NOT "${ARMA_USE_HDF5}" STREQUAL "")
+      find_package(HDF5 REQUIRED)
+
+      set(SUPPORT_INCLUDE_DIRS "${SUPPORT_INCLUDE_DIRS}" "${HDF5_INCLUDE_DIRS}")
+      set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${HDF5_LIBRARIES}")
+    endif (NOT "${ARMA_USE_HDF5}" STREQUAL "")
+
+  else("${ARMA_USE_WRAPPER}" STREQUAL "")
+    # Some older versions still require linking against HDF5 since they did not
+    # wrap libhdf5.  This was true until 4.300 (check this!).
+
+    if(NOT "${ARMA_USE_HDF5}" STREQUAL "")
+      message(STATUS "Armadillo HDF5 support is enabled and manual linking is "
+                     "required.")
+      # We have HDF5 support and need to link against HDF5.
+      find_package(HDF5 REQUIRED)
+
+      set(SUPPORT_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS}")
+      set(SUPPORT_LIBRARIES "${HDF5_LIBRARIES}")
+    endif(NOT "${ARMA_USE_HDF5}" STREQUAL "")
+
+  endif("${ARMA_USE_WRAPPER}" STREQUAL "")
+
+endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
 
+if (ARMA_NEED_LIBRARY)
+  # UNIX paths are standard, no need to write.
+  find_library(ARMADILLO_LIBRARY
+    NAMES armadillo
+    PATHS "$ENV{ProgramFiles}/Armadillo/lib"  "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
+    )
 
-# Checks 'REQUIRED', 'QUIET' and versions.
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Armadillo
-  REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
-  VERSION_VAR ARMADILLO_VERSION_STRING)
-# version_var fails with cmake < 2.8.4.
+  # Checks 'REQUIRED', 'QUIET' and versions.
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(Armadillo
+    REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
+    VERSION_VAR ARMADILLO_VERSION_STRING)
+  # version_var fails with cmake < 2.8.4.
+else (ARMA_NEED_LIBRARY)
+  # Checks 'REQUIRED', 'QUIET' and versions.
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(Armadillo
+    REQUIRED_VARS ARMADILLO_INCLUDE_DIR
+    VERSION_VAR ARMADILLO_VERSION_STRING)
+endif (ARMA_NEED_LIBRARY)
 
 if (ARMADILLO_FOUND)
-  set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR})
-  # HDF5 libraries are stored in HDF5_LIBRARIES, if they were necessary.
-  set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY} ${HDF5_LIBRARIES})
+  # Also include support include directories.
+  set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR} ${SUPPORT_INCLUDE_DIRS})
+  # Also include support libraries to link against.
+  set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY} ${SUPPORT_LIBRARIES})
+  message(STATUS "Armadillo libraries: ${ARMADILLO_LIBRARIES}")
 endif (ARMADILLO_FOUND)
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list