From 4cd94bb24b6437a4846a8293cea7803e18dbab38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20M=C3=BChleisen?= Date: Mon, 29 Apr 2024 16:07:23 +0200 Subject: [PATCH] linking libs on windows --- CMakeLists.txt | 16 +++++++++++----- CMakeLists.txt.in | 9 +++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e645ffc5..eeae51a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,8 +50,8 @@ endif() if(APPLE) set(OS_NAME "osx") - set(OS_ARCH "universal") - SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE) + set(OS_ARCH "universal") + SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for Mac OS X" FORCE) endif() if(WIN32) set(OS_NAME "windows") @@ -64,21 +64,27 @@ if(OVERRIDE_JDBC_OS_ARCH) set(OS_ARCH ${OVERRIDE_JDBC_OS_ARCH}) endif() - add_jar(duckdb_jdbc ${JAVA_SRC_FILES} META-INF/services/java.sql.Driver GENERATE_NATIVE_HEADERS duckdb-native) add_jar(duckdb_jdbc_tests ${JAVA_TEST_FILES} INCLUDE_JARS duckdb_jdbc) + + +set(DUCKDB_SYSTEM_LIBS ${CMAKE_DL_LIBS}) + +if(MSVC) + set(DUCKDB_SYSTEM_LIBS ${DUCKDB_SYSTEM_LIBS} ws2_32 rstrtmgr bcrypt) +endif() + add_library(duckdb_java SHARED src/jni/duckdb_java.cpp src/jni/functions.cpp ${DUCKDB_SRC_FILES}) target_compile_options(duckdb_java PRIVATE -fexceptions) target_link_libraries(duckdb_java duckdb-native ) - +target_link_libraries(duckdb_java ${DUCKDB_SYSTEM_LIBS}) string(JOIN "_" LIB_SUFFIX ".so" ${OS_NAME} ${OS_ARCH}) set_target_properties(duckdb_java PROPERTIES SUFFIX ${LIB_SUFFIX}) set_target_properties(duckdb_java PROPERTIES PREFIX "lib") - add_custom_command( OUTPUT dummy_jdbc_target DEPENDS duckdb_java duckdb_jdbc duckdb_jdbc_tests diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in index 6244f626..8ebf1101 100644 --- a/CMakeLists.txt.in +++ b/CMakeLists.txt.in @@ -68,9 +68,18 @@ add_jar(duckdb_jdbc ${JAVA_SRC_FILES} META-INF/services/java.sql.Driver GENERATE_NATIVE_HEADERS duckdb-native) add_jar(duckdb_jdbc_tests ${JAVA_TEST_FILES} INCLUDE_JARS duckdb_jdbc) + + +set(DUCKDB_SYSTEM_LIBS ${CMAKE_DL_LIBS}) + +if(MSVC) + set(DUCKDB_SYSTEM_LIBS ${DUCKDB_SYSTEM_LIBS} ws2_32 rstrtmgr bcrypt) +endif() + add_library(duckdb_java SHARED src/jni/duckdb_java.cpp src/jni/functions.cpp ${DUCKDB_SRC_FILES}) target_compile_options(duckdb_java PRIVATE -fexceptions) target_link_libraries(duckdb_java duckdb-native ${LIBRARY_FILES}) +target_link_libraries(duckdb_java ${DUCKDB_SYSTEM_LIBS}) string(JOIN "_" LIB_SUFFIX ".so" ${OS_NAME} ${OS_ARCH}) set_target_properties(duckdb_java PROPERTIES SUFFIX ${LIB_SUFFIX})