gnu: kio: Search 'smbd' on $PATH.
[jackhill/guix/guix.git] / gnu / packages / patches / flann-cmake-3.11.patch
1 Fixes this issue:
2 <https://github.com/mariusmuja/flann/issues/369>.
3 Patch from Buildroot:
4 <https://github.com/buildroot/buildroot/commit/45a39b3e2ba42b72d19bfcef30db1b8da9ead51a>.
5
6 From fa5ec96a94646492a3f908e12905b3e48a8e800b Mon Sep 17 00:00:00 2001
7 From: Romain Naour <romain.naour@gmail.com>
8 Date: Wed, 18 Apr 2018 20:24:13 +0200
9 Subject: [PATCH] src/cpp: fix cmake >= 3.11 build
10
11 CMake < 3.11 doesn't support add_library() without any source file
12 (i.e add_library(foo SHARED)). But flann CMake use a trick that use
13 an empty string "" as source list (i.e add_library(foo SHARED "")).
14 This look like a bug in CMake < 3.11.
15
16 With CMake >= 3.11, the new behaviour of add_library() break the
17 existing flann CMake code.
18
19 From CMake Changelog [1]:
20 "add_library() and add_executable() commands can now be called without
21 any sources and will not complain as long as sources are added later
22 via the target_sources() command."
23
24 Note: flann CMake code doesn't use target_sources() since no source file
25 are provided intentionally since the flann shared library is created by
26 linking with the flann_cpp_s static library with this line:
27
28 target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)
29
30 If you try to use "add_library(flann_cpp SHARED ${CPP_SOURCES})" (as it should
31 be normally done), the link fail due to already defined symbol.
32
33 They are building the shared version using the static library "to speedup the
34 build time" [3]
35
36 This issue is already reported upstream [2] with a proposed solution.
37
38 Upstream status: Pending
39
40 Fixes:
41 http://autobuild.buildroot.net/results/b2f/b2febfaf8c44ce477b3e4a5b9b976fd25e8d7454
42
43 [1] https://cmake.org/cmake/help/v3.11/release/3.11.html
44 [2] https://github.com/mariusmuja/flann/issues/369
45 [3] https://github.com/mariusmuja/flann/commit/0fd62b43be2fbb0b8d791ee36290791224dc030c
46
47 Signed-off-by: Romain Naour <romain.naour@gmail.com>
48 ---
49 src/cpp/CMakeLists.txt | 4 ++--
50 src/cpp/empty.cpp | 1 +
51 2 files changed, 3 insertions(+), 2 deletions(-)
52 create mode 100644 src/cpp/empty.cpp
53
54 diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
55 index b44a735..a816863 100644
56 --- a/src/cpp/CMakeLists.txt
57 +++ b/src/cpp/CMakeLists.txt
58 @@ -29,7 +29,7 @@ if (BUILD_CUDA_LIB)
59 endif()
60
61 if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
62 - add_library(flann_cpp SHARED "")
63 + add_library(flann_cpp SHARED "empty.cpp")
64 set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX)
65 target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)
66
67 @@ -85,7 +85,7 @@ if (BUILD_C_BINDINGS)
68 set_property(TARGET flann_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
69
70 if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
71 - add_library(flann SHARED "")
72 + add_library(flann SHARED "empty.cpp")
73 set_target_properties(flann PROPERTIES LINKER_LANGUAGE CXX)
74 target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
75 else()
76 diff --git a/src/cpp/empty.cpp b/src/cpp/empty.cpp
77 new file mode 100644
78 index 0000000..40a8c17
79 --- /dev/null
80 +++ b/src/cpp/empty.cpp
81 @@ -0,0 +1 @@
82 +/* empty */
83 --
84 2.14.3