diff --git a/.appveyor.yml b/.appveyor.yml index 068f2e4c76c..f0ffa394909 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -85,8 +85,8 @@ build_script: - cd C:\projects\mlpack && mkdir build && cd build - > cmake -G "%VSVER%" - -DBLAS_LIBRARY:FILEPATH=%BLAS_LIBRARY% - -DLAPACK_LIBRARY:FILEPATH=%BLAS_LIBRARY% + -DBLAS_LIBRARIES:FILEPATH=%BLAS_LIBRARY% + -DLAPACK_LIBRARIES:FILEPATH=%BLAS_LIBRARY% -DARMADILLO_INCLUDE_DIR="C:/projects/mlpack/armadillo-8.400.0/include" -DARMADILLO_LIBRARY:FILEPATH=%ARMADILLO_LIBRARY% -DBOOST_INCLUDEDIR:PATH=%BOOST_INCLUDE% diff --git a/.ci/windows-steps.yaml b/.ci/windows-steps.yaml index 4d8b9e7923b..8d61b72f910 100644 --- a/.ci/windows-steps.yaml +++ b/.ci/windows-steps.yaml @@ -28,7 +28,7 @@ steps: # Configure armadillo - bash: | git clone --depth 1 https://github.com/mlpack/jenkins-conf.git conf - + curl -O http://masterblaster.mlpack.org:5005/armadillo-8.400.0.tar.gz -o armadillo-8.400.0.tar.gz tar -xzvf armadillo-8.400.0.tar.gz @@ -60,8 +60,8 @@ steps: cmake $(CMakeGenerator) ` $(CMakeArgs) ` - -DBLAS_LIBRARY:FILEPATH=$(Agent.ToolsDirectory)\OpenBLAS.0.2.14.1\lib\native\lib\x64\libopenblas.dll.a ` - -DLAPACK_LIBRARY:FILEPATH=$(Agent.ToolsDirectory)\OpenBLAS.0.2.14.1\lib\native\lib\x64\libopenblas.dll.a ` + -DBLAS_LIBRARIES:FILEPATH=$(Agent.ToolsDirectory)\OpenBLAS.0.2.14.1\lib\native\lib\x64\libopenblas.dll.a ` + -DLAPACK_LIBRARIES:FILEPATH=$(Agent.ToolsDirectory)\OpenBLAS.0.2.14.1\lib\native\lib\x64\libopenblas.dll.a ` -DARMADILLO_INCLUDE_DIR="..\armadillo-8.400.0\include" ` -DARMADILLO_LIBRARY="..\armadillo-8.400.0\Release\armadillo.lib" ` -DBOOST_INCLUDEDIR=$(Agent.ToolsDirectory)\boost.1.60.0.0\lib\native\include ` diff --git a/CMake/ARMA_FindACML.cmake b/CMake/ARMA_FindACML.cmake deleted file mode 100644 index 42561cafda0..00000000000 --- a/CMake/ARMA_FindACML.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - 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 () - set(ACML_FOUND "NO") -endif () - - -if (ACML_FOUND) - if (NOT ACML_FIND_QUIETLY) - message(STATUS "Found the ACML library: ${ACML_LIBRARIES}") - endif () -else () - if (ACML_FIND_REQUIRED) - message(FATAL_ERROR "Could not find the ACML library") - endif () -endif () - -# 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 deleted file mode 100644 index 47a192ced6f..00000000000 --- a/CMake/ARMA_FindACMLMP.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - 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 () - set(ACMLMP_FOUND "NO") -endif () - - -if (ACMLMP_FOUND) - if (NOT ACMLMP_FIND_QUIETLY) - message(STATUS "Found the ACMLMP library: ${ACMLMP_LIBRARIES}") - endif () -else () - if (ACMLMP_FIND_REQUIRED) - message(FATAL_ERROR "Could not find the ACMLMP library") - endif () -endif () - -# 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 deleted file mode 100644 index ff1ee227977..00000000000 --- a/CMake/ARMA_FindARPACK.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# - 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 () -else () - if (ARPACK_FIND_REQUIRED) - message(FATAL_ERROR "Could not find an ARPACK library") - endif () -endif () diff --git a/CMake/ARMA_FindBLAS.cmake b/CMake/ARMA_FindBLAS.cmake deleted file mode 100644 index ff37b4fc79e..00000000000 --- a/CMake/ARMA_FindBLAS.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# - 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 the ATLAS version preferentially. -find_library(BLAS_LIBRARY - NAMES ${BLAS_NAMES} - PATHS /usr/lib64/atlas /usr/lib/atlas /usr/local/lib64/atlas /usr/local/lib/atlas - NO_DEFAULT_PATH) - -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 () - set(BLAS_FOUND "NO") -endif () - - -if (BLAS_FOUND) - if (NOT BLAS_FIND_QUIETLY) - message(STATUS "Found BLAS: ${BLAS_LIBRARIES}") - endif () -else () - if (BLAS_FIND_REQUIRED) - message(FATAL_ERROR "Could not find BLAS") - endif () -endif () - -# 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 deleted file mode 100644 index da84c246b8f..00000000000 --- a/CMake/ARMA_FindCBLAS.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# - 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 () - set(CBLAS_FOUND "NO") -endif () - - -if (CBLAS_FOUND) - if (NOT CBLAS_FIND_QUIETLY) - message(STATUS "Found a CBLAS library: ${CBLAS_LIBRARIES}") - endif () -else () - if (CBLAS_FIND_REQUIRED) - message(FATAL_ERROR "Could not find a CBLAS library") - endif () -endif () - -# 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 deleted file mode 100644 index 97a9792a318..00000000000 --- a/CMake/ARMA_FindCLAPACK.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# - 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 () - set(CLAPACK_FOUND "NO") -endif () - - -if (CLAPACK_FOUND) - if (NOT CLAPACK_FIND_QUIETLY) - message(STATUS "Found a CLAPACK library: ${CLAPACK_LIBRARIES}") - endif () -else () - if (CLAPACK_FIND_REQUIRED) - message(FATAL_ERROR "Could not find a CLAPACK library") - endif () -endif () - -# 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 deleted file mode 100644 index b40d16d04c3..00000000000 --- a/CMake/ARMA_FindLAPACK.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# - 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) - -# Check ATLAS paths preferentially, using this necessary hack (I love CMake). -find_library(LAPACK_LIBRARY - NAMES ${LAPACK_NAMES} - PATHS /usr/lib64/atlas /usr/lib/atlas /usr/local/lib64/atlas /usr/local/lib/atlas - NO_DEFAULT_PATH) - -find_library(LAPACK_LIBRARY - NAMES ${LAPACK_NAMES} - PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib - ) - -if (LAPACK_LIBRARY) - set(LAPACK_LIBRARIES ${LAPACK_LIBRARY}) - set(LAPACK_FOUND "YES") -else () - set(LAPACK_FOUND "NO") -endif () - - -if (LAPACK_FOUND) - if (NOT LAPACK_FIND_QUIETLY) - message(STATUS "Found LAPACK: ${LAPACK_LIBRARIES}") - endif () -else () - if (LAPACK_FIND_REQUIRED) - message(FATAL_ERROR "Could not find LAPACK") - endif () -endif () - -# 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 deleted file mode 100644 index 452fa5a643c..00000000000 --- a/CMake/ARMA_FindMKL.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# - 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() - set(MKL_NAMES ${MKL_NAMES} mkl_intel) -endif() - -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() -endforeach() - -if (MKL_LIBRARIES) - set(MKL_FOUND "YES") -else () - set(MKL_FOUND "NO") -endif () - -if (MKL_FOUND) - if (NOT MKL_FIND_QUIETLY) - message(STATUS "Found MKL libraries: ${MKL_LIBRARIES}") - endif () -else () - if (MKL_FIND_REQUIRED) - message(FATAL_ERROR "Could not find MKL libraries") - endif () -endif () - -# mark_as_advanced(MKL_LIBRARY) diff --git a/CMake/ARMA_FindOpenBLAS.cmake b/CMake/ARMA_FindOpenBLAS.cmake deleted file mode 100644 index edfa27db83f..00000000000 --- a/CMake/ARMA_FindOpenBLAS.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - 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 () - set(OpenBLAS_FOUND "NO") -endif () - - -if (OpenBLAS_FOUND) - if (NOT OpenBLAS_FIND_QUIETLY) - message(STATUS "Found the OpenBLAS library: ${OpenBLAS_LIBRARIES}") - endif () -else () - if (OpenBLAS_FIND_REQUIRED) - message(FATAL_ERROR "Could not find the OpenBLAS library") - endif () -endif () - -# Deprecated declarations. -get_filename_component (NATIVE_OpenBLAS_LIB_PATH ${OpenBLAS_LIBRARY} PATH) - -mark_as_advanced( - OpenBLAS_LIBRARY - ) diff --git a/CMake/FindARPACK.cmake b/CMake/FindARPACK.cmake new file mode 100644 index 00000000000..08baa3b2b14 --- /dev/null +++ b/CMake/FindARPACK.cmake @@ -0,0 +1,55 @@ +# Searches for an installation of the ARPACK library. On success, it sets the following variables: +# +# ARPACK_FOUND Set to true to indicate the library was found +# ARPACK_LIBRARIES All libraries needed to use ARPACK (with full path) +# +# To specify an additional directory to search, set ARPACK_ROOT. +# +# TODO: Do we need to explicitly search for BLAS and LAPACK as well? The source distribution statically links these to +# libarpack. Are there any installations that don't do this or the equivalent? +# +# Author: Siddhartha Chaudhuri, 2009 +# + +SET(ARPACK_FOUND FALSE) + +# First look in user-provided root directory, then look in system locations +FIND_LIBRARY(ARPACK_LIBRARIES NAMES arpack libarpack ARPACK libARPACK PATHS "${ARPACK_ROOT}" "${ARPACK_ROOT}/lib" + NO_DEFAULT_PATH) +IF(NOT ARPACK_LIBRARIES) + FIND_LIBRARY(ARPACK_LIBRARIES NAMES arpack libarpack ARPACK libARPACK) +ENDIF(NOT ARPACK_LIBRARIES) + +IF(ARPACK_LIBRARIES) + # On OS X we probably also need gfortran and BLAS and LAPACK libraries + IF(APPLE) + FIND_LIBRARY(ARPACK_LAPACK_LIBRARY NAMES lapack LAPACK PATHS "${ARPACK_ROOT}" "${ARPACK_ROOT}/lib") + FIND_LIBRARY(ARPACK_BLAS_LIBRARY NAMES blas BLAS PATHS "${ARPACK_ROOT}" "${ARPACK_ROOT}/lib") + FIND_LIBRARY(ARPACK_GFORTRAN_LIBRARY NAMES gfortran PATHS "${ARPACK_ROOT}" "${ARPACK_ROOT}/lib" + PATH_SUFFIXES "" "gfortran/lib" "../gfortran/lib") + + IF(ARPACK_BLAS_LIBRARY) + SET(ARPACK_LIBRARIES ${ARPACK_LIBRARIES} ${ARPACK_BLAS_LIBRARY}) + ENDIF(ARPACK_BLAS_LIBRARY) + + IF(ARPACK_LAPACK_LIBRARY) + SET(ARPACK_LIBRARIES ${ARPACK_LIBRARIES} ${ARPACK_LAPACK_LIBRARY}) + ENDIF(ARPACK_LAPACK_LIBRARY) + + IF(ARPACK_GFORTRAN_LIBRARY) + SET(ARPACK_LIBRARIES ${ARPACK_LIBRARIES} ${ARPACK_GFORTRAN_LIBRARY}) + ENDIF(ARPACK_GFORTRAN_LIBRARY) + ENDIF(APPLE) + + SET(ARPACK_FOUND TRUE) +ENDIF(ARPACK_LIBRARIES) + +IF(ARPACK_FOUND) + IF(NOT ARPACK_FIND_QUIETLY) + MESSAGE(STATUS "Found ARPACK: libraries at ${ARPACK_LIBRARIES}") + ENDIF(NOT ARPACK_FIND_QUIETLY) +ELSE(ARPACK_FOUND) + IF(ARPACK_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "ARPACK not found") + ENDIF(ARPACK_FIND_REQUIRED) +ENDIF(ARPACK_FOUND) diff --git a/CMake/FindArmadillo.cmake b/CMake/FindArmadillo.cmake index 1244f649363..36ec63b5150 100644 --- a/CMake/FindArmadillo.cmake +++ b/CMake/FindArmadillo.cmake @@ -1,41 +1,41 @@ -# - Find Armadillo -# Find the Armadillo C++ library -# -# Using Armadillo: -# find_package(Armadillo REQUIRED) -# include_directories(${ARMADILLO_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# target_link_libraries(foo ${ARMADILLO_LIBRARIES}) -# This module sets the following variables: -# ARMADILLO_FOUND - set to true if the library is found -# ARMADILLO_INCLUDE_DIRS - list of required include directories -# ARMADILLO_LIBRARIES - list of libraries to be linked -# ARMADILLO_VERSION_MAJOR - major version number -# ARMADILLO_VERSION_MINOR - minor version number -# ARMADILLO_VERSION_PATCH - patch version number -# ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4") -# ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. -#============================================================================= -# Copyright 2011 Clement Creusot -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) +#[=======================================================================[.rst: +FindArmadillo +------------- +Find the Armadillo C++ library. +Armadillo is a library for linear algebra & scientific computing. + +Using Armadillo: + +:: + + find_package(Armadillo REQUIRED) + include_directories(${ARMADILLO_INCLUDE_DIRS}) + add_executable(foo foo.cc) + target_link_libraries(foo ${ARMADILLO_LIBRARIES}) + +This module sets the following variables: + +:: + + ARMADILLO_FOUND - set to true if the library is found + ARMADILLO_INCLUDE_DIRS - list of required include directories + ARMADILLO_LIBRARIES - list of libraries to be linked + ARMADILLO_VERSION_MAJOR - major version number + ARMADILLO_VERSION_MINOR - minor version number + ARMADILLO_VERSION_PATCH - patch version number + ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4") + ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") +#]=======================================================================] find_path(ARMADILLO_INCLUDE_DIR NAMES armadillo PATHS "$ENV{ProgramFiles}/Armadillo/include" ) - if(ARMADILLO_INCLUDE_DIR) # ------------------------------------------------------------------------ # Extract version information from @@ -52,318 +52,117 @@ if(ARMADILLO_INCLUDE_DIR) if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp") # Read and parse armdillo version header file for version number - file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS) - string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}") + file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _ARMA_HEADER_CONTENTS REGEX "#define ARMA_VERSION_[A-Z]+ ") + string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_ARMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_ARMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_ARMA_HEADER_CONTENTS}") # WARNING: The number of spaces before the version name is not one. - string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_ARMA_HEADER_CONTENTS}") endif() set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}") endif () - -#====================== - -# 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") - file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp" _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}") - - # ARMA_USE_LAPACK - string(REGEX MATCH "\r?\n[\t ]*#if[\t ]+!defined[(]ARMA_USE_LAPACK[)][\t ]*\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 ]*#if[\t ]+!defined[(]ARMA_USE_BLAS[)][\t ]*\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 ]*#if[\t ]+!defined[(]ARMA_USE_ARPACK[)][\t ]*\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 ]*#if[\t ]+!defined[(]ARMA_USE_HDF5[)][\t ]*\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 - set(MKL_FIND_QUIETLY true) - include(ARMA_FindMKL) - set(ACMLMP_FIND_QUIETLY true) - include(ARMA_FindACMLMP) - set(ACML_FIND_QUIETLY true) - 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 () - - # If we haven't found BLAS, try. - if (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT HAVE_BLAS) - # Search for BLAS. - set(OpenBLAS_FIND_QUIETLY true) - include(ARMA_FindOpenBLAS) - set(CBLAS_FIND_QUIETLY true) - include(ARMA_FindCBLAS) - set(BLAS_FIND_QUIETLY true) - 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 () - 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 () - - # If we haven't found LAPACK, try. - if (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT HAVE_LAPACK) - # Search for LAPACK. - set(CLAPACK_FIND_QUIETLY true) - include(ARMA_FindCLAPACK) - set(LAPACK_FIND_QUIETLY true) - 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 () - - if (NOT "${ARMA_USE_LAPACK}" STREQUAL "" AND NOT HAVE_LAPACK) - message(FATAL_ERROR "Cannot find LAPACK library, but ARMA_USE_LAPACK is " - "set. Try specifying LAPACK libraries manually by setting the " - "LAPACK_LIBRARY variable.") - endif () - - if (NOT "${ARMA_USE_BLAS}" STREQUAL "" AND NOT HAVE_BLAS) - message(FATAL_ERROR "Cannot find BLAS library, but ARMA_USE_BLAS is set. " - "Try specifying BLAS libraries manually by setting the BLAS_LIBRARY " - "variable.") - endif () - - # Search for ARPACK (or replacement). - if (NOT "${ARMA_USE_ARPACK}" STREQUAL "") - # Use Armadillo ARPACK-finding procedure. - set(ARPACK_FIND_QUIETLY true) - include(ARMA_FindARPACK) - - if (NOT ARPACK_FOUND) - message(FATAL_ERROR "ARMA_USE_ARPACK is defined in " - "armadillo_bits/config.hpp, but ARPACK cannot be found. Try " - "specifying ARPACK_LIBRARY.") - endif () - - set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${ARPACK_LIBRARY}") - endif () - - # Search for HDF5 (or replacement). - if (NOT "${ARMA_USE_HDF5}" STREQUAL "") - find_package(HDF5 QUIET) - - if(NOT HDF5_FOUND) - # On Debian systems, the HDF5 package has been split into multiple - # packages so that it is co-installable. But this may mean that the - # include files are hidden somewhere very odd that the FindHDF5.cmake - # script will not find. Thus, we'll also quickly check pkgconfig to see - # if there is information on what to use there. - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(HDF5 hdf5) - # But using pkgconfig is a little weird because HDF5_LIBRARIES won't - # be filled with exact library paths, like the other scripts. So - # instead what we get is HDF5_LIBRARY_DIRS which is the equivalent of - # what we'd pass to -L. - if (HDF5_FOUND) - # I'm not sure what I think of doing this here... - link_directories("${HDF5_LIBRARY_DIRS}") - endif() - endif() - endif() - - if(NOT HDF5_FOUND) - # We tried but didn't find it. - message(FATAL_ERROR "Armadillo HDF5 support is enabled, but HDF5 " - "cannot be found on the system. Consider disabling HDF5 support.") - endif() - - set(SUPPORT_INCLUDE_DIRS "${SUPPORT_INCLUDE_DIRS}" "${HDF5_INCLUDE_DIRS}") - set(SUPPORT_LIBRARIES "${SUPPORT_LIBRARIES}" "${HDF5_LIBRARIES}") - endif () - - else() - # Some older versions still require linking against HDF5 since they did not - # wrap libhdf5. This was true for versions older than 4.300. - if(NOT "${ARMA_USE_HDF5}" STREQUAL "" AND - "${ARMADILLO_VERSION_STRING}" VERSION_LESS "4.300.0") - 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) - - if(NOT HDF5_FOUND) - # On Debian systems, the HDF5 package has been split into multiple - # packages so that it is co-installable. But this may mean that the - # include files are hidden somewhere very odd that the FindHDF5.cmake - # script will not find. Thus, we'll also quickly check pkgconfig to see - # if there is information on what to use there. - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(HDF5 hdf5) - # But using pkgconfig is a little weird because HDF5_LIBRARIES won't - # be filled with exact library paths, like the other scripts. So - # instead what we get is HDF5_LIBRARY_DIRS which is the equivalent of - # what we'd pass to -L. - if (HDF5_FOUND) - # I'm not sure what I think of doing this here... - link_directories("${HDF5_LIBRARY_DIRS}") - endif() - endif() - endif() - - if(NOT HDF5_FOUND) - # We tried but didn't find it. - message(FATAL_ERROR "Armadillo HDF5 support is enabled, but HDF5 " - "cannot be found on the system. Consider disabling HDF5 support.") - endif() - - set(SUPPORT_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS}") - set(SUPPORT_LIBRARIES "${HDF5_LIBRARIES}") - endif() - - # Versions between 4.300 and 4.500 did successfully wrap HDF5, but didn't have good support for setting the include directory correctly. - if(NOT "${ARMA_USE_HDF5}" STREQUAL "" AND - "${ARMADILLO_VERSION_STRING}" VERSION_GREATER "4.299.0" AND - "${ARMADILLO_VERSION_STRING}" VERSION_LESS "4.450.0") - message(STATUS "Armadillo HDF5 support is enabled and include " - "directories must be found.") - find_package(HDF5) - - if(NOT HDF5_FOUND) - # On Debian systems, the HDF5 package has been split into multiple - # packages so that it is co-installable. But this may mean that the - # include files are hidden somewhere very odd that the FindHDF5.cmake - # script will not find. Thus, we'll also quickly check pkgconfig to see - # if there is information on what to use there. - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(HDF5 hdf5) - endif() - endif() - - if(NOT HDF5_FOUND) - # We tried but didn't find it. - message(FATAL_ERROR "Armadillo HDF5 support is enabled, but HDF5 " - "cannot be found on the system. Consider disabling HDF5 support.") - endif() + file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp" _ARMA_CONFIG_CONTENTS REGEX "^#define ARMA_USE_[A-Z]+") + string(REGEX MATCH "ARMA_USE_WRAPPER" _ARMA_USE_WRAPPER "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_LAPACK" _ARMA_USE_LAPACK "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_BLAS" _ARMA_USE_BLAS "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_ARPACK" _ARMA_USE_ARPACK "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_HDF5" _ARMA_USE_HDF5 "${_ARMA_CONFIG_CONTENTS}") +endif() - set(SUPPORT_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS}") - endif() +include(FindPackageHandleStandardArgs) - endif() -else() - message(FATAL_ERROR "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp not " - "found! Cannot determine what to link against.") -endif() +# If _ARMA_USE_WRAPPER is set, then we just link to armadillo, but if it's not then we need support libraries instead +set(_ARMA_SUPPORT_LIBRARIES) -if (ARMA_NEED_LIBRARY) +if(_ARMA_USE_WRAPPER) # 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" ) + set(_ARMA_REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR VERSION_VAR ARMADILLO_VERSION_STRING) +else() + # don't link to armadillo in this case + set(ARMADILLO_LIBRARY "") + if(_ARMA_USE_LAPACK) + if(ARMADILLO_FIND_QUIETLY OR NOT ARMADILLO_FIND_REQUIRED) + find_package(LAPACK QUIET) + else() + find_package(LAPCK REQUIRED) + endif() + if(LAPACK_FOUND) + set(_ARMA_SUPPORT_LIBRARIES "${_ARMA_SUPPORT_LIBRARIES}" "${LAPACK_LIBRARIES}") + endif() + endif() + if(_ARMA_USE_BLAS) + if(ARMADILLO_FIND_QUIETLY OR NOT ARMADILLO_FIND_REQUIRED) + find_package(BLAS QUIET) + else() + find_package(BLAS REQUIRED) + endif() + if(BLAS_FOUND) + set(_ARMA_SUPPORT_LIBRARIES "${_ARMA_SUPPORT_LIBRARIES}" "${BLAS_LIBRARIES}") + endif() + endif() + if(_ARMA_USE_ARPACK) + if(ARMADILLO_FIND_QUIETLY OR NOT ARMADILLO_FIND_REQUIRED) + find_package(ARPACK QUIET) + else() + find_package(ARPACK REQUIRED) + endif() + if(ARPACK_FOUND) + set(_ARMA_SUPPORT_LIBRARIES "${_ARMA_SUPPORT_LIBRARIES}" "${ARPACK_LIBRARIES}") + endif() + endif() + if(_ARMA_USE_HDF5) + find_package(HDF5 QUIET) + if(NOT HDF5_FOUND) + # On Debian systems, the HDF5 package has been split into multiple + # packages so that it is co-installable. But this may mean that the + # include files are hidden somewhere very odd that FindHDF5.cmake will + # not find. Thus, we'll also quickly check pkgconfig to see if there is + # information on what to use there. + message(WARNING "HDF5 required but not found; using PkgConfig") + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(HDF5 REQUIRED hdf5) + link_directories("${HDF5_LIBRARY_DIRS}") + else() + message(FATAL_ERROR "PkgConfig (Used to help find HDF5) was not found") + endif() + endif() + set(_ARMA_SUPPORT_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS}") + set(_ARMA_SUPPORT_LIBRARIES "${_ARMA_SUPPORT_LIBRARIES}" "${HDF5_LIBRARIES}") + endif() + set(ARMADILLO_FOUND true) + set(_ARMA_REQUIRED_VARS ARMADILLO_INCLUDE_DIR VERSION_VAR ARMADILLO_VERSION_STRING) +endif() - # 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 () - # Checks 'REQUIRED', 'QUIET' and versions. - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Armadillo - REQUIRED_VARS ARMADILLO_INCLUDE_DIR - VERSION_VAR ARMADILLO_VERSION_STRING) -endif () +find_package_handle_standard_args(Armadillo REQUIRED_VARS ${_ARMA_REQUIRED_VARS}) if (ARMADILLO_FOUND) - # Also include support include directories. - set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR} ${SUPPORT_INCLUDE_DIRS}) - # Also include support libraries to link against. - if (ARMA_NEED_LIBRARY) - set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY} ${SUPPORT_LIBRARIES}) - else () - set(ARMADILLO_LIBRARIES ${SUPPORT_LIBRARIES}) - endif () - message(STATUS "Armadillo libraries: ${ARMADILLO_LIBRARIES}") + set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR}) + set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY} ${_ARMA_SUPPORT_LIBRARIES}) endif () +# Clean up internal variables +unset(_ARMA_REQUIRED_VARS) +unset(_ARMA_SUPPORT_LIBRARIES) +unset(_ARMA_USE_WRAPPER) +unset(_ARMA_USE_LAPACK) +unset(_ARMA_USE_BLAS) +unset(_ARMA_USE_ARPACK) +unset(_ARMA_USE_HDF5) +unset(_ARMA_CONFIG_CONTENTS) +unset(_ARMA_HEADER_CONTENTS) +unset(__ARMA_SUPPORT_INCLUDE_DIRS) # Hide internal variables mark_as_advanced( ARMADILLO_INCLUDE_DIR ARMADILLO_LIBRARY) - -#====================== diff --git a/CMakeLists.txt b/CMakeLists.txt index 84e96b4510d..18536d4c523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,51 +292,6 @@ else() endif () endif() -# On Windows, Armadillo should be using LAPACK and BLAS but we still need to -# link against it. We don't want to use the FindLAPACK or FindBLAS modules -# because then we are required to have a FORTRAN compiler (argh!) so we will try -# and find LAPACK and BLAS ourselves, using a slightly modified variant of the -# script Armadillo uses to find these. -if (WIN32) - find_library(LAPACK_LIBRARY - NAMES lapack liblapack lapack_win32_MT lapack_win32 - PATHS "C:/Program Files/Armadillo" - PATH_SUFFIXES "examples/lib_win32/") - - if (NOT LAPACK_LIBRARY) - message(FATAL_ERROR "Cannot find LAPACK library (.lib)!") - endif () - - find_library(BLAS_LIBRARY - NAMES blas libblas blas_win32_MT blas_win32 - PATHS "C:/Program Files/Armadillo" - PATH_SUFFIXES "examples/lib_win32/") - - if (NOT BLAS_LIBRARY) - message(FATAL_ERROR "Cannot find BLAS library (.lib)!") - endif () - - # Piggyback LAPACK and BLAS linking into Armadillo link. - set(ARMADILLO_LIBRARIES - ${ARMADILLO_LIBRARIES} ${BLAS_LIBRARY} ${LAPACK_LIBRARY}) - - # Ensure that the libraries are added to the MSVC IDE runtime path. - get_filename_component(BLAS_DIR ${BLAS_LIBRARY} DIRECTORY) - get_filename_component(LAPACK_DIR ${LAPACK_LIBRARY} DIRECTORY) - - # Sometimes, especially with an OpenBLAS install via nuget, the DLLs are - # actually in ../../bin/x64/. Automatically add these. - if (EXISTS "${BLAS_DIR}/../../bin/x64/") - get_filename_component(BLAS_DLL_DIR "${BLAS_DIR}/../../bin/x64" ABSOLUTE) - set(DLL_COPY_DIRS ${DLL_COPY_DIRS} "${BLAS_DLL_DIR}") - endif () - - if (EXISTS "${LAPACK_DIR}/../../bin/x64/") - get_filename_component(LAPACK_DLL_DIR "${LAPACK_DIR}/../../bin/x64" ABSOLUTE) - set(DLL_COPY_DIRS ${DLL_COPY_DIRS} "${BLAS_DLL_DIR}") - endif () -endif () - # Include directories for the previous dependencies. set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIRS} ${ARMADILLO_INCLUDE_DIRS}) set(MLPACK_LIBRARIES ${MLPACK_LIBRARIES} ${ARMADILLO_LIBRARIES}) diff --git a/doc/guide/build_windows.hpp b/doc/guide/build_windows.hpp index 469b8660660..bb8ce9a1ea9 100644 --- a/doc/guide/build_windows.hpp +++ b/doc/guide/build_windows.hpp @@ -118,7 +118,7 @@ compiler version, check if the Visual Studio compiler and Windows SDK are instal - Run cmake: @code -cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARY:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARY:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DBOOST_INCLUDEDIR:PATH="C:/boost/" -DBOOST_LIBRARYDIR:PATH="C:/boost/lib64-msvc-14.2" -DDEBUG=OFF -DPROFILE=OFF .. +cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DBOOST_INCLUDEDIR:PATH="C:/boost/" -DBOOST_LIBRARYDIR:PATH="C:/boost/lib64-msvc-14.2" -DDEBUG=OFF -DPROFILE=OFF .. @endcode @note cmake will attempt to automatically download the ensmallen dependency. If for some reason cmake can't download the dependency, you will need to manually download ensmallen from http://ensmallen.org/ and extract it to "C:\mlpack\mlpack\deps\". Then, specify the path to ensmallen using the flag: -DENSMALLEN_INCLUDE_DIR=C:/mlpack/mlpack/deps/ensmallen/include