Skip to content

Commit

Permalink
Disable JAVA SDK (with a warning) when JNI not found
Browse files Browse the repository at this point in the history
Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow committed Jun 27, 2023
1 parent ae8d96c commit 6c53fba
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions analytical_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ option(LET_IT_CRASH_ON_EXCEPTION "Disable boost leaf's error handling and let it
execute_process(COMMAND uname -m OUTPUT_VARIABLE SYSTEM_PROCESSOR)
string(REGEX REPLACE "\n$" "" SYSTEM_PROCESSOR "${SYSTEM_PROCESSOR}")

# find jni ---------------------------------------------------------------------
if (ENABLE_JAVA_SDK)
find_package(JNI QUIET)
if (JNI_FOUND)
include_directories(SYSTEM ${JAVA_INCLUDE_PATH})
include_directories(SYSTEM ${JAVA_INCLUDE_PATH2})
else()
message(WARNING "Disable Java SDK because JNI libraries not found")
set(ENABLE_JAVA_SDK OFF)
endif()
endif()

if (ENABLE_JAVA_SDK)
#check whether we are using clang.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down Expand Up @@ -229,13 +241,6 @@ if (NOT Protobuf_FOUND)
endif()
include_directories(${Protobuf_INCLUDE_DIRS})

if (ENABLE_JAVA_SDK)
# find jni---------------------------------------------------------------------
find_package(JNI REQUIRED)
include_directories(SYSTEM ${JAVA_INCLUDE_PATH})
include_directories(SYSTEM ${JAVA_INCLUDE_PATH2})
endif()

find_package(gRPC QUIET)
if(gRPC_FOUND)
set(GRPC_LIBRARIES gRPC::gpr gRPC::grpc gRPC::grpc++)
Expand Down Expand Up @@ -290,19 +295,19 @@ target_link_libraries(gs_proto PUBLIC

add_library(gs_util SHARED "core/flags.cc" "core/launcher.cc")
target_link_libraries(gs_util PRIVATE
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${VINEYARD_LIBRARIES}
${Boost_LIBRARIES}
)
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${VINEYARD_LIBRARIES}
${Boost_LIBRARIES}
)

if (ENABLE_JAVA_SDK)
target_sources(gs_util PRIVATE "core/java/javasdk.cc")
target_compile_definitions(gs_util PUBLIC ENABLE_JAVA_SDK)
target_link_libraries(gs_util PRIVATE
${JAVA_JVM_LIBRARY}
${JNI_LIBRARIES}
)
${JAVA_JVM_LIBRARY}
${JNI_LIBRARIES}
)
endif()

add_executable(grape_engine
Expand All @@ -313,14 +318,14 @@ add_executable(grape_engine
)
target_include_directories(grape_engine PRIVATE proto utils)
target_link_libraries(grape_engine PRIVATE
gs_proto
gs_util
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${CMAKE_DL_LIBS}
${Boost_LIBRARIES}
${VINEYARD_LIBRARIES}
)
gs_proto
gs_util
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${CMAKE_DL_LIBS}
${Boost_LIBRARIES}
${VINEYARD_LIBRARIES}
)

if (ENABLE_JAVA_SDK)
target_compile_definitions(grape_engine PUBLIC ENABLE_JAVA_SDK)
Expand Down Expand Up @@ -571,15 +576,15 @@ install_gsa_dependency_modules("${PROJECT_SOURCE_DIR}/cmake")

configure_file(graphscope-analytical-config.in.cmake
"${PROJECT_BINARY_DIR}/graphscope-analytical-config.cmake" @ONLY
)
)
configure_file(graphscope-analytical-config-version.in.cmake
"${PROJECT_BINARY_DIR}/graphscope-analytical-config-version.cmake" @ONLY
)
)
install(FILES "${PROJECT_BINARY_DIR}/graphscope-analytical-config.cmake"
"${PROJECT_BINARY_DIR}/graphscope-analytical-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphscope-analytical
)
)
install(EXPORT graphscope-analytical-targets
FILE graphscope-analytical-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphscope-analytical
)
)

0 comments on commit 6c53fba

Please sign in to comment.