Skip to content

Commit

Permalink
Build for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alesapin committed Sep 16, 2024
1 parent 02c86a8 commit f9de56a
Show file tree
Hide file tree
Showing 659 changed files with 90,292 additions and 50,693 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ set (CH_ODBC_DEFAULT_DSN_UNICODE "ClickHouse DSN (Unicode)" CACHE STRING "Defaul

if (MSVC)
# This default encoding mode will be overriden by UNICODE, in the corresponding cases.
add_compile_definitions (SBCS _SBCS)
#add_compile_definitions (SBCS _SBCS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif ()

Expand Down Expand Up @@ -128,7 +128,10 @@ if (WERROR)
# TODO: Set CMAKE_COMPILE_WARNING_AS_ERROR (cmake 3.24)
target_compile_options(global-group INTERFACE "-Werror")
endif ()

if (OS_WINDOWS)
find_package(ODBC REQUIRED)
find_package(Threads REQUIRED)
endif()
add_subdirectory (contrib EXCLUDE_FROM_ALL)

if (CH_ODBC_ENABLE_SSL)
Expand Down Expand Up @@ -172,8 +175,10 @@ if (CH_ODBC_ENABLE_TESTING)
endif ()

set(ENABLE_SSL 1)

add_subdirectory(contrib/poco)


if (CH_ODBC_ENABLE_TESTING)
include (CTest)
enable_testing ()
Expand Down
2 changes: 1 addition & 1 deletion cmake/arch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (ARCH_BITS 32)
endif ()

if (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
if (CMAKE_LIBRARY_ARCHITECTURE MATCHES "i386")
message (FATAL_ERROR "32bit platforms are not supported")
endif ()
Expand Down
3 changes: 3 additions & 0 deletions cmake/os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
elseif (CMAKE_SYSTEM_NAME MATCHES "SunOS")
set (OS_SUNOS 1)
add_definitions(-D OS_SUNOS)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
set (OS_WINDOWS 1)
add_definitions(-D OS_WINDOWS)
else ()
message (FATAL_ERROR "Platform '${CMAKE_SYSTEM_NAME}' is not supported")
endif ()
4 changes: 3 additions & 1 deletion contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ add_contrib (unixodbc-cmake unixodbc)
add_contrib (nanodbc-cmake nanodbc)
add_contrib (lz4-cmake lz4)
add_contrib (double-conversion-cmake double-conversion)
add_contrib (openssl-cmake openssl)
if (OS_DARWIN OR OS_LINUX)
add_contrib (openssl-cmake openssl)
endif()
add_contrib (zlib-ng-cmake zlib-ng)
set (FOLLY_INLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/folly" CACHE INTERNAL "")

Expand Down
9 changes: 7 additions & 2 deletions contrib/icu-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (OS_LINUX OR OS_DARWIN)
if (OS_LINUX OR OS_DARWIN OR OS_WINDOWS)
option(ENABLE_ICU "Enable ICU" 1)
else ()
option(ENABLE_ICU "Enable ICU" 0)
Expand Down Expand Up @@ -479,7 +479,12 @@ set(ICUDATA_SOURCES
)

# Note that we don't like any kind of binary plugins (because of runtime dependencies, vulnerabilities, ABI incompatibilities).
add_definitions(-D_REENTRANT -DU_HAVE_ELF_H=1 -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=0 -DDEFAULT_ICU_PLUGINS="/dev/null")
if (OS_LINUX OR OS_DARWIN)
add_definitions(-D_REENTRANT -DU_HAVE_ELF_H=1 -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=0 -DDEFAULT_ICU_PLUGINS="/dev/null")
elseif (OS_WINDOWS)
add_definitions(-D_REENTRANT -DDEFAULT_ICU_PLUGINS="/dev/null")

endif()

add_library(_icuuc ${ICUUC_SOURCES})
add_library(_icui18n ${ICUI18N_SOURCES})
Expand Down
37 changes: 26 additions & 11 deletions contrib/nanodbc-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
if (NOT TARGET ch_contrib::unixodbc)
message(FATAL_ERROR "Configuration error: unixodbc is not a target")
endif()

set (LIBRARY_DIR "${CMAKE_SOURCE_DIR}/contrib/nanodbc")
if (OS_DARWIN OR OS_LINIX)
if (NOT TARGET ch_contrib::unixodbc)
message(FATAL_ERROR "Configuration error: unixodbc is not a target")
endif()

set (LIBRARY_DIR "${CMAKE_SOURCE_DIR}/contrib/nanodbc")

set (SRCS
"${LIBRARY_DIR}/nanodbc/nanodbc.cpp"
)

set (SRCS
"${LIBRARY_DIR}/nanodbc/nanodbc.cpp"
)
add_library(_nanodbc ${SRCS})
target_link_libraries(_nanodbc PUBLIC ch_contrib::unixodbc)
target_include_directories(_nanodbc SYSTEM PUBLIC "${LIBRARY_DIR}/")
add_library(ch_contr
ib::nanodbc ALIAS _nanodbc)
elseif (OS_WINDOWS)
set (LIBRARY_DIR "${CMAKE_SOURCE_DIR}/contrib/nanodbc")
set (SRCS
"${LIBRARY_DIR}/nanodbc/nanodbc.cpp"
)

add_library(_nanodbc ${SRCS})
target_link_libraries(_nanodbc PUBLIC ch_contrib::unixodbc)
target_include_directories(_nanodbc SYSTEM PUBLIC "${LIBRARY_DIR}/")
add_library(ch_contrib::nanodbc ALIAS _nanodbc)
add_library(_nanodbc ${SRCS})
target_link_libraries(_nanodbc PUBLIC ODBC::Driver)
target_include_directories(_nanodbc SYSTEM PUBLIC "${LIBRARY_DIR}/")
add_library(ch_contrib::nanodbc ALIAS _nanodbc)

endif()
17 changes: 13 additions & 4 deletions contrib/poco/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
add_subdirectory (Crypto)
add_subdirectory (Data)
add_subdirectory (Data/ODBC)
add_subdirectory (Foundation)
add_subdirectory (JSON)
add_subdirectory (MongoDB)
add_subdirectory (Net)
add_subdirectory (NetSSL_OpenSSL)
add_subdirectory (Redis)
if (OS_LINUX OR OS_DARWIN)
add_subdirectory (Crypto)
add_subdirectory (NetSSL_OpenSSL)
elseif (OS_WINDOWS)
if (MSVC)
if (TARGET Foundation)
set_property(TARGET Foundation APPEND PROPERTY INTERFACE_LINK_LIBRARIES Iphlpapi)
elseif (TARGET Poco::Foundation)
set_property(TARGET _poco_foundation APPEND PROPERTY INTERFACE_LINK_LIBRARIES Iphlpapi)
endif ()
endif ()
add_subdirectory (NetSSL_Win)
endif()
add_subdirectory (Util)
add_subdirectory (XML)
8 changes: 6 additions & 2 deletions contrib/poco/Data/ODBC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (ENABLE_ODBC)
if (NOT TARGET ch_contrib::unixodbc)
if ((OS_DARWIN OR OS_LINUX) AND NOT TARGET ch_contrib::unixodbc)
message(FATAL_ERROR "Configuration error: unixodbc is not a target")
endif()

Expand Down Expand Up @@ -38,7 +38,11 @@ if (ENABLE_ODBC)
-Wno-zero-as-null-pointer-constant
)
target_include_directories (_poco_data_odbc SYSTEM PUBLIC "include")
target_link_libraries (_poco_data_odbc PUBLIC Poco::Data ch_contrib::unixodbc)
if (OS_LINUX OR OS_DARWIN)
target_link_libraries (_poco_data_odbc PUBLIC Poco::Data ch_contrib::unixodbc)
elseif(OS_WINDOWS)
target_link_libraries (_poco_data_odbc PUBLIC Poco::Data ODBC::Driver)
endif()

message (STATUS "Using Poco::Data::ODBC")
else ()
Expand Down
Loading

0 comments on commit f9de56a

Please sign in to comment.