From b0a62a5eac91004ebeba93750b1c8482ca3ec49c Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 15 Nov 2012 21:07:13 +0000 Subject: [PATCH] Check for a 64-bit system where ARMA_64BIT_WORD is not enabled, and warn the user if that is the case. MLPACK still works fine without ARMA_64BIT_WORD, but it is not a bad idea to ensure size_t == uword (by defining ARMA_64BIT_WORD on 64-bit systems). --- CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47c8a7d5bd..7cc44773eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,28 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake") find_package(Armadillo 2.4.0 REQUIRED) +# If Armadillo was compiled without ARMA_64BIT_WORD and we are on a 64-bit +# system (where size_t will be 64 bits), suggest to the user that they should +# compile Armadillo with 64-bit words. +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # We are on a 64-bit system. Does Armadillo have ARMA_64BIT_WORD enabled? + file(READ "${ARMADILLO_INCLUDE_DIRS}/armadillo_bits/config.hpp" ARMA_CONFIG) + string(REGEX MATCH + "[\r\n][ ]*#define ARMA_64BIT_WORD" + ARMA_HAS_64BIT_WORD_PRE + "${ARMA_CONFIG}") + + string(LENGTH "${ARMA_HAS_64BIT_WORD_PRE}" ARMA_HAS_64BIT_WORD) + + if(ARMA_HAS_64BIT_WORD EQUAL 0) + message(WARNING "This is a 64-bit system, but Armadillo was compiled " + "without 64-bit index support. Consider recompiling Armadillo with " + "ARMA_64BIT_WORD to enable 64-bit indices (large matrix support). " + "MLPACK will still work without ARMA_64BIT_WORD defined, but will not " + "scale to matrices with more than 4 billion elements.") + endif(ARMA_HAS_64BIT_WORD EQUAL 0) +endif(CMAKE_SIZEOF_VOID_P EQUAL 8) + # 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