Hi Alex,

Thanks for your help.
I have changed the FindArmadillo.cmake file using your comments.
The file is attached to this email.
I also modified Armadillo installation. A new ArmadilloConfig.cmake file is installed in ${INSTALL_DATA_DIR}/Armadillo/cmake/. It works well, thanks for the tips.

Clement.


On 16/03/11 19:16, Alexander Neundorf wrote:
Hi Clement,

On Wednesday 16 March 2011, creusot wrote:
Hi everybody,
I would like to propose a new cmake module for the Armadillo C++ library.
       http://arma.sourceforge.net/
This library provides fast linear algebra methods with an interface very
similar to octave code:
     colvec x = solve(A,b);
     colvec x = inv(trans(A)*A)*trans(A)*b ;
I have attached the FindArmadillo.cmake file to this email.
I propose myself as Module maintainer for Armadillo C++.
My details: Clement Creusot (creu...@cs.york.ac.uk)

Can you tell me if I need to do other steps (in addition to sending this
email) ?
Here you can find more information, please follow the links there:
http://www.vtk.org/Wiki/CMake:Module_Maintainers

When will the new module file be available to cmake users?
Well, the next release is 2.8.5 in 2 or 3 months or so.

Is there a clean way to provide the FindArmadillo.cmake file for people
installing armadillo that are not likely to update cmake anytime soon?
Not really. You could put it in the cmake wiki or on the armadillo website.
A good thing to do would be if armadillo would install a ArmadilloConfig.cmake
file, which will be automatically found by find_package() even without a
FindArmadillo.cmake

Is hard-copying the file into cmakeroot/Modules a good strategy?
No.

Is there an other way to dynamically add a cmake module while installing
a new software?
No, because this doesn't make sense.
The purpose of a FindFoo.cmake is to find out whether Foo is installed or not,
and iof installed, find out where it is installed. This means it must be
available also when Foo itself is not installed.

Best regards,
Clement.

Some comments on the file:

* In order to be accepted into cmake the license of the file must be BSD or
similar, LGPL is AFAIK not accepted.

* Please use consistent upper or lower-casing of the commands. Lower-casing is
prefered.

* The
if(WIN32)
else()
endif()
for finding the library and headers doesn't seem to be necessary, you can just
list all possible directories in one call to find_path() and find_library()
respectively.

* The additional search paths given in the not-WIN32 branch shouldn't be
necessary, these are all standard search paths.

* For checking whether it has been found successfully, please use the
find_package_handle_standard_args() macro:
find_package_handle_standard_args(Armadillo
                         REQUIRED_VARS Armadillo_LIBRARY Armadillo_INCLUDE_DIR
                         VERSION_VAR Armadillo_VERSION_STRING)

This will handle the version comparison, the check whether it is required or
not, QUIET and not QUIET automatically for you.

Alex

# - Try to find Armadillo include dirs and libraries
# Usage of this module as follows:
#
# == Using Armadillo: ==
#
#   find_package( Armadillo RECQUIRED )
#   include_directories(${ARMADILLO_INCLUDE_DIRS})
#   add_executable(foo foo.cc)
#   target_link_libraries(foo ${ARMADILLO_LIBRARIES})
#
#=============================================================================
#
# This module sets the following variables:
#  ARMADILLO_FOUND - set to true if the library is found
#  ARMADILLO_INCLUDE_DIRS - list of required include directories
#  ARMADILLO_LIBRARIES - list of libraries to be linked 
#  ARMADILLO_VERSION_MAJOR - major version number
#  ARMADILLO_VERSION_MINOR - minor version number
#  ARMADILLO_VERSION_PATCH - patch version number
#  ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4")
#  ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech")
#
#=============================================================================
# Copyright 2011 Clement Creusot
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#
#=============================================================================

# UNIX paths are standard, no need to write.
find_library(ARMADILLO_LIBRARY
  NAMES armadillo
  PATHS "$ENV{ProgramFiles}/Armadillo/lib"  "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo"
  )
find_path(ARMADILLO_INCLUDE_DIR
  NAMES armadillo
  PATHS "$ENV{ProgramFiles}/Armadillo/include"
  )


if(ARMADILLO_INCLUDE_DIR)

  # ------------------------------------------------------------------------
  #  Extract version information from <armadillo>
  # ------------------------------------------------------------------------

  # WARNING: Early releases of Armadillo didn't have the arma_version.hpp file.
  # (e.g. v.0.9.8-1 in ubuntu maverick packages (2001-03-15))
  # If the file is missing, set all values to 0  
  set(ARMADILLO_VERSION_MAJOR 0)
  set(ARMADILLO_VERSION_MINOR 0)
  set(ARMADILLO_VERSION_PATCH 0)
  set(ARMADILLO_VERSION_NAME "EARLY RELEASE")

  if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp")

    # Read and parse armdillo version header file for version number 
    file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS)
    string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}")
    string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}")
    string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}")

    # WARNING: The number of spaces before the version name is not one.
    string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}")
  
  endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp")

  set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}")
endif (ARMADILLO_INCLUDE_DIR)

#======================


# Checks 'RECQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs) 
find_package_handle_standard_args(Armadillo 
  REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
  VERSION_VAR ARMADILLO_VERSION_STRING) 
# version_var fails with cmake < 2.8.4.

if (ARMADILLO_FOUND)
  set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR})  
  set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY})  
endif (ARMADILLO_FOUND)


# Hide internal variables
mark_as_advanced(
  ARMADILLO_INCLUDE_DIR
  ARMADILLO_LIBRARY)

#======================
_______________________________________________
cmake-developers mailing list
cmake-developers@cmake.org
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to