FindArmadillo.cmake 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. # Copyright 2011 Clement Creusot <[email protected]>
  20. #
  21. # Distributed under the OSI-approved BSD License (the "License");
  22. # see accompanying file Copyright.txt for details.
  23. #
  24. # This software is distributed WITHOUT ANY WARRANTY; without even the
  25. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  26. # See the License for more information.
  27. #=============================================================================
  28. # (To distribute this file outside of CMake, substitute the full
  29. # License text for the above reference.)
  30. # UNIX paths are standard, no need to write.
  31. find_library(ARMADILLO_LIBRARY
  32. NAMES armadillo
  33. PATHS "$ENV{ProgramFiles}/Armadillo/lib" "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
  34. )
  35. find_path(ARMADILLO_INCLUDE_DIR
  36. NAMES armadillo
  37. PATHS "$ENV{ProgramFiles}/Armadillo/include"
  38. )
  39. if(ARMADILLO_INCLUDE_DIR)
  40. # ------------------------------------------------------------------------
  41. # Extract version information from <armadillo>
  42. # ------------------------------------------------------------------------
  43. # WARNING: Early releases of Armadillo didn't have the arma_version.hpp file.
  44. # (e.g. v.0.9.8-1 in ubuntu maverick packages (2001-03-15))
  45. # If the file is missing, set all values to 0
  46. set(ARMADILLO_VERSION_MAJOR 0)
  47. set(ARMADILLO_VERSION_MINOR 0)
  48. set(ARMADILLO_VERSION_PATCH 0)
  49. set(ARMADILLO_VERSION_NAME "EARLY RELEASE")
  50. if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp")
  51. # Read and parse armdillo version header file for version number
  52. file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS)
  53. string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}")
  54. string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}")
  55. string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}")
  56. # WARNING: The number of spaces before the version name is not one.
  57. string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}")
  58. endif()
  59. set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}")
  60. endif ()
  61. #======================
  62. # Checks 'REQUIRED', 'QUIET' and versions.
  63. include(FindPackageHandleStandardArgs)
  64. find_package_handle_standard_args(Armadillo
  65. REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
  66. VERSION_VAR ARMADILLO_VERSION_STRING)
  67. # version_var fails with cmake < 2.8.4.
  68. if (ARMADILLO_FOUND)
  69. set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR})
  70. set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY})
  71. endif ()
  72. # Hide internal variables
  73. mark_as_advanced(
  74. ARMADILLO_INCLUDE_DIR
  75. ARMADILLO_LIBRARY)
  76. #======================