Make Java an optional dependency

This commit is contained in:
mpilman 2019-02-07 22:18:31 -08:00 committed by Alex Miller
parent 44eb80b161
commit f601aa7407
4 changed files with 55 additions and 22 deletions

View File

@ -21,7 +21,7 @@ project(fdb
VERSION 6.1.0
DESCRIPTION "FoundationDB is a scalable, fault-tolerant, ordered key-value store with full ACID transactions."
HOMEPAGE_URL "http://www.foundationdb.org/"
LANGUAGES ASM C CXX Java)
LANGUAGES ASM C CXX)
if(WIN32)
# C# is currently only supported on Windows.
@ -57,29 +57,16 @@ find_package(PythonLibs 3.4 REQUIRED)
################################################################################
# LibreSSL
# Compiler configuration
################################################################################
set(DISABLE_TLS OFF CACHE BOOL "Don't try to find LibreSSL and always build without TLS support")
if(DISABLE_TLS)
set(WITH_TLS FALSE)
else()
set(LIBRESSL_USE_STATIC_LIBS TRUE)
find_package(LibreSSL)
if(LibreSSL_FOUND)
set(WITH_TLS TRUE)
else()
message(STATUS "LibreSSL NOT Found - Will compile without TLS Support")
message(STATUS "You can set LibreSSL_ROOT to the LibreSSL install directory to help cmake find it")
set(WITH_TLS FALSE)
endif()
endif()
include(ConfigureCompiler)
################################################################################
# Compiler configuration
################################################################################
include(ConfigureCompiler)
include(FDBComponents)
################################################################################
# Get repository information
@ -256,3 +243,9 @@ if (CMAKE_EXPORT_COMPILE_COMMANDS)
)
add_custom_target(procossed_compile_commands ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json)
endif()
################################################################################
# Inform user which components we are going to build
################################################################################
print_components()

View File

@ -1,3 +1,5 @@
add_subdirectory(c)
add_subdirectory(python)
add_subdirectory(java)
if(BUILD_JAVA)
add_subdirectory(java)
endif()

View File

@ -1,7 +1,3 @@
include(UseJava)
find_package(JNI 1.8 REQUIRED)
find_package(Java 1.8 COMPONENTS Development REQUIRED)
set(JAVA_BINDING_SRCS
src/main/com/apple/foundationdb/async/AsyncIterable.java
src/main/com/apple/foundationdb/async/AsyncIterator.java

42
cmake/FDBComponents.cmake Normal file
View File

@ -0,0 +1,42 @@
################################################################################
# Java Bindings
################################################################################
set(BUILD_JAVA OFF)
find_package(JNI 1.8 REQUIRED)
find_package(Java 1.8 COMPONENTS Development)
if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND)
set(BUILD_JAVA ON)
include(UseJava)
enable_language(Java)
endif()
################################################################################
# LibreSSL
################################################################################
set(DISABLE_TLS OFF CACHE BOOL "Don't try to find LibreSSL and always build without TLS support")
if(DISABLE_TLS)
set(WITH_TLS OFF)
else()
set(LIBRESSL_USE_STATIC_LIBS TRUE)
find_package(LibreSSL)
if(LibreSSL_FOUND)
set(WITH_TLS ON)
else()
message(STATUS "LibreSSL NOT Found - Will compile without TLS Support")
message(STATUS "You can set LibreSSL_ROOT to the LibreSSL install directory to help cmake find it")
set(WITH_TLS OFF)
endif()
endif()
function(print_components)
message(STATUS "=============================")
message(STATUS " Components Build Overview ")
message(STATUS "=============================")
message(STATUS "Build Python Bindings: ON")
message(STATUS "Build Java Bindings: ${BUILD_JAVA}")
message(STATUS "Build with TLS support: ${WITH_TLS}")
message(STATUS "=============================")
endfunction()