Merge remote-tracking branch 'upstream/3.4' into merge-3.4
[platform/upstream/opencv.git] / cmake / OpenCVFindAtlas.cmake
1 #COPYRIGHT
2 #
3 #All contributions by the University of California:
4 #Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
5 #All rights reserved.
6 #
7 #All other contributions:
8 #Copyright (c) 2014, 2015, the respective contributors
9 #All rights reserved.
10 #
11 #Caffe uses a shared copyright model: each contributor holds copyright over
12 #their contributions to Caffe. The project versioning records all such
13 #contribution and copyright details. If a contributor wants to further mark
14 #their specific copyright on a particular contribution, they should indicate
15 #their copyright solely in the commit message of the change when it is
16 #committed.
17 #
18 #LICENSE
19 #
20 #Redistribution and use in source and binary forms, with or without
21 #modification, are permitted provided that the following conditions are met:
22 #
23 #1. Redistributions of source code must retain the above copyright notice, this
24 #   list of conditions and the following disclaimer.
25 #2. Redistributions in binary form must reproduce the above copyright notice,
26 #   this list of conditions and the following disclaimer in the documentation
27 #   and/or other materials provided with the distribution.
28 #
29 #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 #ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 #DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
33 #ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 #LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 #ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #
40 #CONTRIBUTION AGREEMENT
41 #
42 #By contributing to the BVLC/caffe repository through pull-request, comment,
43 #or otherwise, the contributor releases their content to the
44 #license and copyright terms herein.
45
46
47 # Find the Atlas (and Lapack) libraries
48 #
49 # The following variables are optionally searched for defaults
50 #  Atlas_ROOT_DIR:            Base directory where all Atlas components are found
51 #
52 # The following are set after configuration is done:
53 #  Atlas_FOUND
54 #  Atlas_INCLUDE_DIRS
55 #  Atlas_LIBRARIES
56 #  Atlas_LIBRARYRARY_DIRS
57
58 set(Atlas_INCLUDE_SEARCH_PATHS
59   /usr/include/atlas
60   /usr/include/atlas-base
61   $ENV{Atlas_ROOT_DIR}
62   $ENV{Atlas_ROOT_DIR}/include
63 )
64
65 set(Atlas_LIB_SEARCH_PATHS
66   /usr/lib/atlas
67   /usr/lib/atlas-base
68   $ENV{Atlas_ROOT_DIR}
69   $ENV{Atlas_ROOT_DIR}/lib
70 )
71
72 find_path(Atlas_CBLAS_INCLUDE_DIR   NAMES cblas.h   PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
73 find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES lapacke.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS})
74
75 find_library(Atlas_CBLAS_LIBRARY NAMES  ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS})
76 find_library(Atlas_BLAS_LIBRARY NAMES   atlas_r   atlas                 PATHS ${Atlas_LIB_SEARCH_PATHS})
77 find_library(Atlas_LAPACK_LIBRARY NAMES lapack alapack_r alapack lapack_atlas  PATHS ${Atlas_LIB_SEARCH_PATHS})
78
79 set(LOOKED_FOR
80   Atlas_CBLAS_INCLUDE_DIR
81   Atlas_CLAPACK_INCLUDE_DIR
82
83   Atlas_CBLAS_LIBRARY
84   Atlas_BLAS_LIBRARY
85   Atlas_LAPACK_LIBRARY
86 )
87
88 include(FindPackageHandleStandardArgs)
89 find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR})
90
91 if(ATLAS_FOUND)
92   set(Atlas_INCLUDE_DIR ${Atlas_CBLAS_INCLUDE_DIR} ${Atlas_CLAPACK_INCLUDE_DIR})
93   set(Atlas_LIBRARIES ${Atlas_LAPACK_LIBRARY} ${Atlas_CBLAS_LIBRARY} ${Atlas_BLAS_LIBRARY})
94   mark_as_advanced(${LOOKED_FOR})
95
96   message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})")
97 endif(ATLAS_FOUND)