Merge pull request #6854 from sturkmen72:patch-8
[platform/upstream/opencv.git] / cmake / OpenCVFindOpenBLAS.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 SET(Open_BLAS_INCLUDE_SEARCH_PATHS
47   /usr/include
48   /usr/include/openblas
49   /usr/include/openblas-base
50   /usr/local/include
51   /usr/local/include/openblas
52   /usr/local/include/openblas-base
53   /opt/OpenBLAS/include
54   $ENV{OpenBLAS_HOME}
55   $ENV{OpenBLAS_HOME}/include
56 )
57
58 SET(Open_BLAS_LIB_SEARCH_PATHS
59         /lib/
60         /lib/openblas-base
61         /lib64/
62         /usr/lib
63         /usr/lib/openblas-base
64         /usr/lib64
65         /usr/local/lib
66         /usr/local/lib64
67         /opt/OpenBLAS/lib
68         $ENV{OpenBLAS}cd
69         $ENV{OpenBLAS}/lib
70         $ENV{OpenBLAS_HOME}
71         $ENV{OpenBLAS_HOME}/lib
72  )
73
74 FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS})
75 FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
76
77 SET(OpenBLAS_FOUND ON)
78
79 #    Check include files
80 IF(NOT OpenBLAS_INCLUDE_DIR)
81     SET(OpenBLAS_FOUND OFF)
82     MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off")
83 ENDIF()
84
85 #    Check libraries
86 IF(NOT OpenBLAS_LIB)
87     SET(OpenBLAS_FOUND OFF)
88     MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off")
89 ENDIF()
90
91 IF (OpenBLAS_FOUND)
92   IF (NOT OpenBLAS_FIND_QUIETLY)
93     MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}")
94     MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}")
95   ENDIF (NOT OpenBLAS_FIND_QUIETLY)
96 ELSE (OpenBLAS_FOUND)
97   IF (OpenBLAS_FIND_REQUIRED)
98     MESSAGE(FATAL_ERROR "Could not find OpenBLAS")
99   ENDIF (OpenBLAS_FIND_REQUIRED)
100 ENDIF (OpenBLAS_FOUND)
101
102 MARK_AS_ADVANCED(
103     OpenBLAS_INCLUDE_DIR
104     OpenBLAS_LIB
105     OpenBLAS
106 )