Skip to content

Commit

Permalink
linking libs on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Mühleisen committed Apr 29, 2024
1 parent f45dd3e commit 4cd94bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 4cd94bb

Please sign in to comment.