adding lapacke.cmake stub

This commit is contained in:
Radovan Bast
2015-09-17 10:44:30 +02:00
parent e399058e37
commit 6efc29457d
5 changed files with 49 additions and 32 deletions

41
modules/lapacke.cmake Normal file
View File

@ -0,0 +1,41 @@
#.rst:
#
# Find and link to LAPACKE.
#
# Variables defined::
#
# LAPACKE_FOUND - describe me, uncached
# LAPACKE_LIBRARIES - describe me, uncached
# LAPACKE_INCLUDE_DIR - describe me, uncached
#
# autocmake.cfg configuration::
#
# docopt: --lapacke Find and link to LAPACKE [default: False].
# define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke']
# fetch: https://github.com/scisoft/autocmake/raw/master/modules/find/find_libraries.cmake
# https://github.com/scisoft/autocmake/raw/master/modules/find/find_include_files.cmake
option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF)
if(ENABLE_LAPACKE)
include(find_libraries)
include(find_include_files)
set(LAPACKE_FOUND FALSE)
set(LAPACKE_LIBRARIES "undefined")
set(LAPACKE_INCLUDE_DIR "undefined")
# if(APPLE)
# _find_library(Accelerate cblas_dgemm LAPACKE_LIBRARIES)
# _find_include_dir(Accelerate.h /usr LAPACKE_INCLUDE_DIR)
# else()
_find_library(lapacke LAPACKE_dgesv LAPACKE_LIBRARIES)
_find_include_dir(lapacke.h /usr LAPACKE_INCLUDE_DIR)
# endif()
if(NOT "${LAPACKE_LIBRARIES}" STREQUAL "undefined")
if(NOT "${LAPACKE_INCLUDE_DIR}" STREQUAL "undefined")
set(LAPACKE_FOUND TRUE)
endif()
endif()
endif()

View File

@ -5,8 +5,8 @@ min_cmake_version: 2.8
[cxx]
source: ../../../modules/cxx.cmake
[math_libs]
source: ../../../modules/math_libs.cmake
[lapacke]
source: ../../../modules/lapacke.cmake
[default_build_paths]
source: ../../../modules/default_build_paths.cmake

View File

@ -1,13 +1,7 @@
if(LAPACK_FOUND)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
#windows needs to find <lapacke.h> of openblas
include_directories($ENV{PATH})
else()
#ftravis-ci needs find <clapack.h> of ATLAS
include_directories(/usr/include/atlas)
endif()
if(LAPACKE_FOUND)
include_directories(${LAPACKE_INCLUDE_DIR})
add_executable(example example.cpp)
target_link_libraries(example ${MATH_LIBS})
target_link_libraries(example ${LAPACKE_LIBRARIES})
else()
message(FATAL_ERROR "LAPACK library not found for the test cc_lapacke!")
message(FATAL_ERROR "LAPACKE library not found")
endif()

View File

@ -1,19 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#if defined HAVE_MKL_LAPACK
#include <mkl_lapacke.h>
#include <mkl_cblas.h>
#pragma message "Using Intel MKL c-lapack interface, <mkl_lapacke.h>."
#elif defined HAVE_OPENBLAS_LAPACK
#include <lapacke.h>
#include <cblas.h>
#pragma message "Using OpenBLAS C-lapack interface, <lapacke.h>."
#else
#include <clapack.h>
#include <cblas.h>
#pragma message "Using ATLAS/SYSTEM_NATIVE C lapack interface, <clapack.h>."
#endif
#include "lapacke.h"
int main()
{
@ -39,12 +27,7 @@ int main()
int ierr;
int ipiv[n];
/* MKL, OpenBLAS */
#if defined HAVE_MKL_LAPACK || defined HAVE_OPENBLAS_LAPACK
ierr = LAPACKE_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
#else /* ATLAS, SYSTEM_NATIVE */
ierr = clapack_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
#endif
if (ierr != 0)
{
fprintf(stderr, "\ndgesv failure with error %i\n", ierr);

View File

@ -164,9 +164,8 @@ def test_fc_lapack():
configure_build_and_exe('fc_lapack', 'python setup.py --fc=gfortran --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
@skip_on_osx
def test_cxx_lapacke():
configure_build_and_exe('cxx_lapacke', 'python setup.py --cxx=g++ --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
configure_build_and_exe('cxx_lapacke', 'python setup.py --cxx=g++ --lapacke')
# ------------------------------------------------------------------------------