2 # Find the Armadillo C++ library
5 # find_package(Armadillo REQUIRED)
6 # include_directories(${ARMADILLO_INCLUDE_DIRS})
7 # add_executable(foo foo.cc)
8 # target_link_libraries(foo ${ARMADILLO_LIBRARIES})
9 # This module sets the following variables:
10 # ARMADILLO_FOUND - set to true if the library is found
11 # ARMADILLO_INCLUDE_DIRS - list of required include directories
12 # ARMADILLO_LIBRARIES - list of libraries to be linked
13 # ARMADILLO_VERSION_MAJOR - major version number
14 # ARMADILLO_VERSION_MINOR - minor version number
15 # ARMADILLO_VERSION_PATCH - patch version number
16 # ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4")
17 # ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech")
19 #=============================================================================
20 # Copyright 2011 Clement Creusot <creusot@cs.york.ac.uk>
22 # Distributed under the OSI-approved BSD License (the "License");
23 # see accompanying file Copyright.txt for details.
25 # This software is distributed WITHOUT ANY WARRANTY; without even the
26 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 # See the License for more information.
28 #=============================================================================
29 # (To distribute this file outside of CMake, substitute the full
30 # License text for the above reference.)
33 # UNIX paths are standard, no need to write.
34 find_library(ARMADILLO_LIBRARY
36 PATHS "$ENV{ProgramFiles}/Armadillo/lib" "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
38 find_path(ARMADILLO_INCLUDE_DIR
40 PATHS "$ENV{ProgramFiles}/Armadillo/include"
44 if(ARMADILLO_INCLUDE_DIR)
46 # ------------------------------------------------------------------------
47 # Extract version information from <armadillo>
48 # ------------------------------------------------------------------------
50 # WARNING: Early releases of Armadillo didn't have the arma_version.hpp file.
51 # (e.g. v.0.9.8-1 in ubuntu maverick packages (2001-03-15))
52 # If the file is missing, set all values to 0
53 set(ARMADILLO_VERSION_MAJOR 0)
54 set(ARMADILLO_VERSION_MINOR 0)
55 set(ARMADILLO_VERSION_PATCH 0)
56 set(ARMADILLO_VERSION_NAME "EARLY RELEASE")
58 if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp")
60 # Read and parse armdillo version header file for version number
61 file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS REGEX "#define ARMA_VERSION_[A-Z]+ ")
62 string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}")
63 string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}")
64 string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}")
66 # WARNING: The number of spaces before the version name is not one.
67 string(REGEX REPLACE ".*#define ARMA_VERSION_NAME +\"([0-9a-zA-Z _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}")
69 unset(_armadillo_HEADER_CONTENTS)
72 set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}")
75 #======================
78 # Checks 'REQUIRED', 'QUIET' and versions.
79 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
80 find_package_handle_standard_args(Armadillo
81 REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
82 VERSION_VAR ARMADILLO_VERSION_STRING)
83 # version_var fails with cmake < 2.8.4.
86 set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR})
87 set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY})
91 # Hide internal variables
96 #======================