Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindArmadillo.cmake
1 # - Find Armadillo
2 # Find the Armadillo C++ library
3 #
4 # Using Armadillo:
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")
18
19 #=============================================================================
20 # Copyright 2011 Clement Creusot <creusot@cs.york.ac.uk>
21 #
22 # Distributed under the OSI-approved BSD License (the "License");
23 # see accompanying file Copyright.txt for details.
24 #
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.)
31
32
33 # UNIX paths are standard, no need to write.
34 find_library(ARMADILLO_LIBRARY
35   NAMES armadillo
36   PATHS "$ENV{ProgramFiles}/Armadillo/lib"  "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
37   )
38 find_path(ARMADILLO_INCLUDE_DIR
39   NAMES armadillo
40   PATHS "$ENV{ProgramFiles}/Armadillo/include"
41   )
42
43
44 if(ARMADILLO_INCLUDE_DIR)
45
46   # ------------------------------------------------------------------------
47   #  Extract version information from <armadillo>
48   # ------------------------------------------------------------------------
49
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")
57
58   if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp")
59
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}")
65
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}")
68
69     unset(_armadillo_HEADER_CONTENTS)
70   endif()
71
72   set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}")
73 endif ()
74
75 #======================
76
77
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.
84
85 if (ARMADILLO_FOUND)
86   set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR})
87   set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY})
88 endif ()
89
90
91 # Hide internal variables
92 mark_as_advanced(
93   ARMADILLO_INCLUDE_DIR
94   ARMADILLO_LIBRARY)
95
96 #======================