summarylogtreecommitdiffstats
path: root/dlib-19.0.patch
blob: a3148d441e34980eed8bb737e5de846dbeef3412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
diff -ruN dlib-19.0/dlib/cmake_find_blas.txt dlib-19.0-patched/dlib/cmake_find_blas.txt
--- dlib-19.0/dlib/cmake_find_blas.txt	2016-06-26 03:05:41.000000000 +0800
+++ dlib-19.0-patched/dlib/cmake_find_blas.txt	2016-06-27 13:03:20.968515000 +0800
@@ -310,6 +310,116 @@
     endif()
 
 
+elseif(WIN32 AND CMAKE_CROSSCOMPILING)
+
+   message(STATUS "Searching for BLAS and LAPACK")
+
+   # try to find LAPACK libraries while cross compiling
+   set(extra_paths
+        /usr/i686-w64-mingw32/lib
+        /usr/i686-w64-mingw32/lib/atlas-sse3
+        /usr/i686-w64-mingw32/lib/atlas-sse2
+        /usr/i686-w64-mingw32/lib/atlas
+        /usr/i686-w64-mingw32/lib/openblas-base
+        /usr/x86_64-w64-mingw32/lib
+        /usr/x86_64-w64-mingw32/lib/atlas-sse3
+        /usr/x86_64-w64-mingw32/lib/atlas-sse2
+        /usr/x86_64-w64-mingw32/lib/openblas-base
+        /usr/x86_64-w64-mingw32/lib/atlas)
+        )
+
+   INCLUDE (CheckFunctionExists)
+
+   if (NOT blas_found)
+      find_library(cblas_lib openblas PATHS ${extra_paths})
+      if (cblas_lib)
+         set(blas_libraries ${cblas_lib})
+         set(blas_found 1)
+         message(STATUS "Found OpenBLAS library")
+         set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
+         # If you compiled OpenBLAS with LAPACK in it then it should have the
+         # sgetrf_single function in it.  So if we find that function in
+         # OpenBLAS then just use OpenBLAS's LAPACK. 
+         CHECK_FUNCTION_EXISTS(sgetrf_single OPENBLAS_HAS_LAPACK)
+         if (OPENBLAS_HAS_LAPACK)
+            message(STATUS "Using OpenBLAS's built in LAPACK")
+            # set(lapack_libraries gfortran) 
+            set(lapack_found 1)
+         endif()
+      endif()
+      mark_as_advanced( cblas_lib)
+   endif()
+
+   if (NOT lapack_found)
+      find_library(lapack_lib NAMES lapack lapack-3 PATHS ${extra_paths})
+      if (lapack_lib)
+         set(lapack_libraries ${lapack_lib})
+         set(lapack_found 1)
+         message(STATUS "Found LAPACK library")
+      endif()
+      mark_as_advanced( lapack_lib)
+   endif()
+
+   # try to find BLAS libraries while cross compiling
+   if (NOT blas_found)
+      find_library(atlas_lib atlas PATHS ${extra_paths})
+      find_library(cblas_lib cblas PATHS ${extra_paths})
+      if (atlas_lib AND cblas_lib)
+         set(blas_libraries ${atlas_lib} ${cblas_lib})
+         set(blas_found 1)
+         message(STATUS "Found ATLAS BLAS library")
+      endif()
+      mark_as_advanced( atlas_lib cblas_lib)
+   endif()
+
+   if (NOT blas_found)
+      find_library(cblas_lib cblas PATHS ${extra_paths})
+      if (cblas_lib)
+         set(blas_libraries ${cblas_lib})
+         set(blas_found 1)
+         message(STATUS "Found CBLAS library")
+      endif()
+      mark_as_advanced( cblas_lib)
+   endif()
+   
+   if (NOT blas_found)
+      find_library(generic_blas blas PATHS ${extra_paths})
+      if (generic_blas)
+         set(blas_libraries ${generic_blas})
+         set(blas_found 1)
+         message(STATUS "Found BLAS library")
+      endif()
+      mark_as_advanced( generic_blas)
+   endif()
+
+   # Make sure we really found a CBLAS library.  That is, it needs to expose
+   # the proper cblas link symbols.  So here we test if one of them is present
+   # and assume everything is good if it is. Note that we don't do this check if
+   # we found the Intel MKL since for some reason CHECK_FUNCTION_EXISTS doesn't work
+   # with it.  But it's fine since the MKL should always have cblas.
+   if (blas_found AND NOT found_intel_mkl)
+      set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
+      CHECK_FUNCTION_EXISTS(cblas_ddot HAVE_CBLAS)
+      if (NOT HAVE_CBLAS)
+         message(STATUS "BLAS library does not have cblas symbols, so dlib will not use BLAS or LAPACK")
+         set(blas_found 0)
+         set(lapack_found 0)
+      endif()
+   endif()
+
+   if (NOT blas_found)
+      message(" *****************************************************************************")
+      message(" *** No BLAS library found so using dlib's built in BLAS.  However, if you ***")
+      message(" *** install an optimized BLAS such as OpenBLAS or the Intel MKL your code ***")
+      message(" *** will run faster.  On Ubuntu you can install OpenBLAS by executing:    ***")
+      message(" ***    sudo apt-get install libopenblas-dev liblapack-dev                 ***")
+      message(" *** Or you can easily install OpenBLAS from source by downloading the     ***")
+      message(" *** source tar file from http://www.openblas.net, extracting it, and      ***")
+      message(" *** running:                                                              ***")
+      message(" ***    make; sudo make install                                            ***")
+      message(" *****************************************************************************")
+   endif()
+
 endif()
 
 
diff -ruN dlib-19.0/dlib/CMakeLists.txt dlib-19.0-patched/dlib/CMakeLists.txt
--- dlib-19.0/dlib/CMakeLists.txt	2016-06-26 03:05:41.000000000 +0800
+++ dlib-19.0-patched/dlib/CMakeLists.txt	2016-06-27 13:03:20.968515000 +0800
@@ -308,6 +308,7 @@
          if (PNG_FOUND AND LIBPNG_IS_GOOD)
             include_directories(${PNG_INCLUDE_DIR})
             set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARY})
+            set (dlib_needed_libraries ${dlib_needed_libraries} ${ZLIB_LIBRARY})
             set(REQUIRES_LIBS " libpng")
          else()
             # If we can't find libpng then statically compile it in.