This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d496ccb
commit 4b4cc31
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "jni/external/nmslib"] | ||
path = jni/external/nmslib | ||
url = https://github.com/nmslib/nmslib.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# | ||
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed | ||
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
# | ||
|
||
cmake_minimum_required(VERSION 2.8) | ||
|
||
project(KNNIndexV1_7_3_6) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
# Target Library to be built | ||
set(KNN_INDEX KNNIndexV1_7_3_6) | ||
|
||
# Check if similarity search exists | ||
find_path(NMS_REPO_DIR NAMES similarity_search PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib REQUIRED) | ||
|
||
# If not, pull the updated submodule | ||
if (NOT EXISTS ${NMS_REPO_DIR}) | ||
message(STATUS "Could not find nmslib. Pulling updated submodule.") | ||
execute_process(COMMAND git submodule update --init -- external/nmslib WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
endif () | ||
|
||
# Add the subdirectory so it is possible to use its targets | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search) | ||
|
||
# Set OS specific variables | ||
if (${CMAKE_SYSTEM_NAME} STREQUAL Darwin) | ||
set(JVM_OS_TYPE darwin) | ||
set(LIB_EXT .jnilib) | ||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux) | ||
set(JVM_OS_TYPE linux) | ||
set(LIB_EXT .so) | ||
else() | ||
message( FATAL_ERROR "Unable to run on system: ${CMAKE_SYSTEM_NAME}") | ||
endif() | ||
|
||
# Compile the library | ||
add_library(${KNN_INDEX} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/src/v1736/com_amazon_opendistroforelasticsearch_knn_index_v1736_KNNIndex.cpp) | ||
target_link_libraries(${KNN_INDEX} NonMetricSpaceLib) | ||
target_include_directories(${KNN_INDEX} PRIVATE $ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/${JVM_OS_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/nmslib/similarity_search/include) | ||
|
||
set_target_properties(${KNN_INDEX} PROPERTIES SUFFIX ${LIB_EXT}) | ||
set_target_properties(${KNN_INDEX} PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
set_target_properties(${KNN_INDEX} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../buildSrc) |