Skip to content

Commit 2565abd

Browse files
committed
Fixes for clang compiler
1 parent 15da6aa commit 2565abd

File tree

12 files changed

+40
-49
lines changed

12 files changed

+40
-49
lines changed

CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ set(FLANN_VERSION 1.8.0)
1212
DISSECT_VERSION()
1313
GET_OS_INFO()
1414

15+
if ( "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}" MATCHES ".*clang")
16+
set(CMAKE_COMPILER_IS_CLANG 1)
17+
endif ()
18+
19+
if ( "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang")
20+
set(CMAKE_COMPILER_IS_CLANGXX 1)
21+
endif ()
22+
23+
1524
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
1625

1726
# Add an "uninstall" target
@@ -63,6 +72,8 @@ endif()
6372
find_hdf5()
6473
if (NOT HDF5_FOUND)
6574
message(WARNING "hdf5 library not found, some tests will not be run")
75+
else()
76+
include_directories(${HDF5_INCLUDE_DIR})
6677
endif()
6778

6879
if (USE_MPI OR HDF5_IS_PARALLEL)
@@ -90,6 +101,13 @@ if (USE_MPI)
90101
endif(USE_MPI)
91102

92103

104+
if (USE_MPI AND HDF5_IS_PARALLEL)
105+
find_package(Boost COMPONENTS mpi system serialization thread REQUIRED)
106+
include_directories(${Boost_INCLUDE_DIRS})
107+
add_definitions("-DHAVE_MPI")
108+
endif()
109+
110+
93111
find_package(GTest)
94112
if (NOT GTEST_FOUND)
95113
message(WARNING "gtest library not found, some tests will not be run")
@@ -130,7 +148,7 @@ if (WIN32)
130148
# lots of warnings with cl.exe right now, use /W1
131149
add_definitions("/W1 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /bigobj")
132150
else(WIN32)
133-
add_definitions( "-Wall -Wno-unknown-pragmas" )
151+
add_definitions( "-Wall -Wno-unknown-pragmas -Wno-unused-function" )
134152
endif(WIN32)
135153

136154
add_subdirectory( cmake )

examples/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ if (HDF5_FOUND)
2424

2525

2626
if (USE_MPI AND HDF5_IS_PARALLEL)
27-
find_package(Boost COMPONENTS mpi system serialization thread REQUIRED)
28-
include_directories(${Boost_INCLUDE_DIRS})
29-
add_definitions("-DHAVE_MPI")
30-
3127
add_executable(flann_example_mpi flann_example_mpi.cpp)
3228
target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
3329

src/cpp/CMakeLists.txt

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
99
file(GLOB_RECURSE CU_SOURCES *.cu)
1010

1111
add_library(flann_cpp_s STATIC ${CPP_SOURCES})
12-
if(CMAKE_COMPILER_IS_GNUCC)
12+
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
1313
set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
1414
endif()
1515
set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC FLANN_USE_CUDA)
@@ -63,33 +63,21 @@ if (BUILD_CUDA_LIB)
6363
endif()
6464

6565

66+
if (USE_MPI AND HDF5_IS_PARALLEL)
67+
add_executable(flann_mpi_server flann/mpi/flann_mpi_server.cpp)
68+
target_link_libraries(flann_mpi_server flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
6669

70+
add_executable(flann_mpi_client flann/mpi/flann_mpi_client.cpp)
71+
target_link_libraries(flann_mpi_client flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
6772

68-
69-
70-
if (HDF5_FOUND)
71-
include_directories(${HDF5_INCLUDE_DIR})
72-
73-
if (USE_MPI AND HDF5_IS_PARALLEL)
74-
find_package(Boost COMPONENTS mpi serialization system thread REQUIRED)
75-
include_directories(${Boost_INCLUDE_DIRS})
76-
add_definitions("-DHAVE_MPI")
77-
78-
add_executable(flann_mpi_server flann/mpi/flann_mpi_server.cpp)
79-
target_link_libraries(flann_mpi_server flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
80-
81-
add_executable(flann_mpi_client flann/mpi/flann_mpi_client.cpp)
82-
target_link_libraries(flann_mpi_client flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
83-
84-
install (TARGETS flann_mpi_client flann_mpi_server
85-
DESTINATION bin)
86-
endif()
73+
install (TARGETS flann_mpi_client flann_mpi_server
74+
DESTINATION bin)
8775
endif()
8876

8977

9078
if (BUILD_C_BINDINGS)
9179
add_library(flann_s STATIC ${C_SOURCES})
92-
if(CMAKE_COMPILER_IS_GNUCC)
80+
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
9381
set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC)
9482
endif()
9583
set_property(TARGET flann_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)

src/cpp/flann/algorithms/autotuned_index.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class AutotunedIndex : public NNIndex<Distance>
231231
Matrix<size_t>& indices,
232232
Matrix<DistanceType>& dists,
233233
size_t knn,
234-
const SearchParams& params)
234+
const SearchParams& params) const
235235
{
236236
if (params.checks == FLANN_CHECKS_AUTOTUNED) {
237237
return bestIndex_->knnSearch(queries, indices, dists, knn, bestSearchParams_);
@@ -245,7 +245,7 @@ class AutotunedIndex : public NNIndex<Distance>
245245
std::vector< std::vector<size_t> >& indices,
246246
std::vector<std::vector<DistanceType> >& dists,
247247
size_t knn,
248-
const SearchParams& params)
248+
const SearchParams& params) const
249249
{
250250
if (params.checks == FLANN_CHECKS_AUTOTUNED) {
251251
return bestIndex_->knnSearch(queries, indices, dists, knn, bestSearchParams_);
@@ -255,12 +255,12 @@ class AutotunedIndex : public NNIndex<Distance>
255255
}
256256

257257
}
258-
258+
259259
int radiusSearch(const Matrix<ElementType>& queries,
260260
Matrix<size_t>& indices,
261261
Matrix<DistanceType>& dists,
262262
DistanceType radius,
263-
const SearchParams& params)
263+
const SearchParams& params) const
264264
{
265265
if (params.checks == FLANN_CHECKS_AUTOTUNED) {
266266
return bestIndex_->radiusSearch(queries, indices, dists, radius, bestSearchParams_);
@@ -274,7 +274,7 @@ class AutotunedIndex : public NNIndex<Distance>
274274
std::vector< std::vector<size_t> >& indices,
275275
std::vector<std::vector<DistanceType> >& dists,
276276
DistanceType radius,
277-
const SearchParams& params)
277+
const SearchParams& params) const
278278
{
279279
if (params.checks == FLANN_CHECKS_AUTOTUNED) {
280280
return bestIndex_->radiusSearch(queries, indices, dists, radius, bestSearchParams_);

src/cpp/flann/algorithms/dist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ struct Hamming
548548
}
549549

550550
template <typename Iterator1, typename Iterator2>
551-
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
551+
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = 0) const
552552
{
553553
#ifdef FLANN_PLATFORM_64_BIT
554554
const uint64_t* pa = reinterpret_cast<const uint64_t*>(a);

src/cpp/flann/algorithms/kdtree_single_index.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class KDTreeSingleIndex : public NNIndex<Distance>
329329
ar & low;
330330
ar & high;
331331
}
332-
friend serialization::access;
332+
friend struct serialization::access;
333333
};
334334

335335
typedef std::vector<Interval> BoundingBox;

src/cpp/flann/algorithms/nn_index.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ class NNIndex : public IndexBase
516516
resultSet.copy(indices[i], dists[i], n, params.sorted);
517517

518518
// mark the next element in the output buffers as unused
519-
if (n<indices.cols) indices[i][n] = -1;
519+
if (n<indices.cols) indices[i][n] = size_t(-1);
520520
if (n<dists.cols) dists[i][n] = std::numeric_limits<DistanceType>::infinity();
521521
indices_to_ids(indices[i], indices[i], n);
522522
}
@@ -537,7 +537,7 @@ class NNIndex : public IndexBase
537537
resultSet.copy(indices[i], dists[i], n, params.sorted);
538538

539539
// mark the next element in the output buffers as unused
540-
if (n<indices.cols) indices[i][n] = -1;
540+
if (n<indices.cols) indices[i][n] = size_t(-1);
541541
if (n<dists.cols) dists[i][n] = std::numeric_limits<DistanceType>::infinity();
542542
indices_to_ids(indices[i], indices[i], n);
543543
}

src/cpp/flann/general.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,34 +198,24 @@ inline size_t flann_datatype_size(flann_datatype_t type)
198198
switch (type) {
199199
case FLANN_INT8:
200200
return sizeof(flann_datatype_type<FLANN_INT8>::type);
201-
break;
202201
case FLANN_INT16:
203202
return sizeof(flann_datatype_type<FLANN_INT16>::type);
204-
break;
205203
case FLANN_INT32:
206204
return sizeof(flann_datatype_type<FLANN_INT32>::type);
207-
break;
208205
case FLANN_INT64:
209206
return sizeof(flann_datatype_type<FLANN_INT64>::type);
210-
break;
211207
case FLANN_UINT8:
212208
return sizeof(flann_datatype_type<FLANN_UINT8>::type);
213-
break;
214209
case FLANN_UINT16:
215210
return sizeof(flann_datatype_type<FLANN_UINT16>::type);
216-
break;
217211
case FLANN_UINT32:
218212
return sizeof(flann_datatype_type<FLANN_UINT32>::type);
219-
break;
220213
case FLANN_UINT64:
221214
return sizeof(flann_datatype_type<FLANN_UINT64>::type);
222-
break;
223215
case FLANN_FLOAT32:
224216
return sizeof(flann_datatype_type<FLANN_FLOAT32>::type);
225-
break;
226217
case FLANN_FLOAT64:
227218
return sizeof(flann_datatype_type<FLANN_FLOAT64>::type);
228-
break;
229219
default:
230220
return 0;
231221
}

src/cpp/flann/mpi/index.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ int Index<Distance>::radiusSearch(const flann::Matrix<ElementType>& query, flann
263263
} //namespace flann::mpi
264264

265265
namespace boost { namespace mpi {
266-
template<>
267266
template<typename DistanceType>
268267
struct is_commutative<flann::mpi::ResultsMerger<DistanceType>, flann::mpi::SearchResults<DistanceType> > : mpl::true_ { };
269268
} } // end namespace boost::mpi

src/cpp/flann/util/dynamic_bitset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class DynamicBitset
148148
ar & size_;
149149
ar & bitset_;
150150
}
151-
friend serialization::access;
151+
friend struct serialization::access;
152152

153153
private:
154154
std::vector<size_t> bitset_;

0 commit comments

Comments
 (0)