[mlpack-git] master: Fix warning. (861ac83)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Apr 15 15:02:58 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/ea0d81f60e7d6eeb0902dba4e8de9a857c5ef56d...861ac83cea1ceb728b2700f7b5d3550ca7b75839

>---------------------------------------------------------------

commit 861ac83cea1ceb728b2700f7b5d3550ca7b75839
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Apr 15 15:02:48 2015 -0400

    Fix warning.


>---------------------------------------------------------------

861ac83cea1ceb728b2700f7b5d3550ca7b75839
 CMake/CreateArmaConfigInfo.cmake | 67 +++++++++++++++++++++++-----------------
 CMakeLists.txt                   |  1 +
 2 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/CMake/CreateArmaConfigInfo.cmake b/CMake/CreateArmaConfigInfo.cmake
index 1986118..606c051 100644
--- a/CMake/CreateArmaConfigInfo.cmake
+++ b/CMake/CreateArmaConfigInfo.cmake
@@ -10,26 +10,39 @@ else(EXISTS "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp")
   set(OLD_FILE_CONTENTS "")
 endif(EXISTS "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp")
 
-# We'll need to open the config.hpp we are using.
-if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
-  file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp"
-      ARMA_CONFIG)
+# If we are using Armadillo 5+, ARMA_64BIT_WORD is implicitly enabled.
+set(ARMA_HAS_64BIT_WORD 0) # This may be unnecessary.
+if(NOT (${ARMADILLO_VERSION_MAJOR} LESS 5))
+  set(ARMA_HAS_64BIT_WORD 1)
+else(NOT (${ARMADILLO_VERSION_MAJOR} LESS 5))
+  # Otherwise, we'll need to open the config.hpp we are using and inspect the
+  # setting of ARMA_64BIT_WORD.
+  if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
+    file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp"
+        ARMA_CONFIG)
 
-  # Extract ARMA_64BIT_WORD.
-  string(REGEX MATCH
-      "[\r\n][ ]*#define ARMA_64BIT_WORD"
-      ARMA_HAS_64BIT_WORD_PRE
-      "${ARMA_CONFIG}")
+    # Extract ARMA_64BIT_WORD.
+    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)
+    string(LENGTH "${ARMA_HAS_64BIT_WORD_PRE}" ARMA_HAS_64BIT_WORD)
+  else(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
+    # Assumes ARMA_64BIT_WORD is not set.
+    message(WARNING "Armadillo configuration file
+        (${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp) does not exist!")
+  endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
+endif(NOT (${ARMADILLO_VERSION_MAJOR} LESS 5))
 
-  if(ARMA_HAS_64BIT_WORD EQUAL 0)
-    set(ARMA_64BIT_WORD_DEFINE "#define MLPACK_ARMA_NO64BIT_WORD")
-  else(ARMA_HAS_64BIT_WORD EQUAL 0)
-    set(ARMA_64BIT_WORD_DEFINE "#define MLPACK_ARMA_64BIT_WORD")
-  endif(ARMA_HAS_64BIT_WORD EQUAL 0)
+# Now use the value we gathered to generate the new file contents.
+if(ARMA_HAS_64BIT_WORD EQUAL 0)
+  set(ARMA_64BIT_WORD_DEFINE "#define MLPACK_ARMA_NO64BIT_WORD")
+else(ARMA_HAS_64BIT_WORD EQUAL 0)
+  set(ARMA_64BIT_WORD_DEFINE "#define MLPACK_ARMA_64BIT_WORD")
+endif(ARMA_HAS_64BIT_WORD EQUAL 0)
 
-  set(NEW_FILE_CONTENTS
+set(NEW_FILE_CONTENTS
 "/**
  * @file arma_config.hpp
  *
@@ -52,16 +65,14 @@ ${ARMA_64BIT_WORD_DEFINE}
 #endif
 ")
 
-  # Did the contents of the file change at all?  If not, don't write it.
-  if(NOT "${OLD_FILE_CONTENTS}" STREQUAL "${NEW_FILE_CONTENTS}")
-    # We have a reason to write the new file.
-    message(STATUS "Regenerating arma_config.hpp.")
-    file(REMOVE "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp")
-    file(WRITE "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp"
-        "${NEW_FILE_CONTENTS}")
-  endif(NOT "${OLD_FILE_CONTENTS}" STREQUAL "${NEW_FILE_CONTENTS}")
+# Did the contents of the file change at all?  If not, don't write it.
+if(NOT "${OLD_FILE_CONTENTS}" STREQUAL "${NEW_FILE_CONTENTS}")
+  # We have a reason to write the new file.
+  message(STATUS "Regenerating arma_config.hpp.")
+  file(REMOVE "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp")
+  file(WRITE "${CMAKE_SOURCE_DIR}/src/mlpack/core/util/arma_config.hpp"
+      "${NEW_FILE_CONTENTS}")
+endif(NOT "${OLD_FILE_CONTENTS}" STREQUAL "${NEW_FILE_CONTENTS}")
+
+
 
-else(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
-  message(WARNING "Armadillo configuration file
-      (${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp) does not exist!")
-endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f04b033..7c47aa1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -323,6 +323,7 @@ include(CMake/CreateArmaConfigInfo.cmake)
 add_custom_target(mlpack_arma_config ALL
     COMMAND ${CMAKE_COMMAND}
         -D ARMADILLO_INCLUDE_DIR="${ARMADILLO_INCLUDE_DIR}"
+        -D ARMADILLO_VERSION_MAJOR="${ARMADILLO_VERSION_MAJOR}"
         -P CMake/CreateArmaConfigInfo.cmake
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Updating arma_config.hpp (if necessary)")



More information about the mlpack-git mailing list