kou commented on code in PR #47517:
URL: https://github.com/apache/arrow/pull/47517#discussion_r2389635598


##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,7 +15,76 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Use C++ 20 for ODBC and its subdirectory
+# GH-44792: Arrow will switch to C++ 20
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 add_custom_target(arrow_flight_sql_odbc)
 
+# Ensure fmt is loaded as header only
+add_compile_definitions(FMT_HEADER_ONLY)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)

Review Comment:
   I see.



##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// flight_sql_connection.h needs to be included first due to conflicts with 
windows.h
+#include "arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
+
+#include 
"arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
+#include 
"arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h"
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
+
+// odbc_api includes windows.h, which needs to be put behind winsock2.h.
+// odbc_environment.h includes winsock2.h

Review Comment:
   Ah, sorry. I missed `#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"`
 in the above `#include`s.
   



##########
cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   Should we use `#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"` 
instead? It seems that `platform.h` defines some macros before including 
`windows.h`.



##########
cpp/src/arrow/flight/sql/odbc/entry_points.cc:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// platform.h includes windows.h, so it needs to be included first
+#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif

Review Comment:
   It seems that `#include 
"arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/platform.h"` 
includes `windows.h`.



##########
cpp/src/arrow/flight/sql/odbc/CMakeLists.txt:
##########
@@ -15,11 +15,64 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_custom_target(arrow_flight_sql_odbc)
-
 # Use C++ 20 for ODBC and its subdirectory
 # GH-44792: Arrow will switch to C++ 20
 set(CMAKE_CXX_STANDARD 20)
 
+add_custom_target(arrow_flight_sql_odbc)
+
+if(WIN32)
+  if(MSVC_VERSION GREATER_EQUAL 1900)
+    set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
+  elseif(MINGW)
+    set(ODBCINST odbccp32 shlwapi)
+  endif()
+elseif(APPLE)
+  set(ODBCINST iodbcinst)
+else()
+  set(ODBCINST odbcinst)
+endif()
+
 add_subdirectory(flight_sql)
 add_subdirectory(odbcabstraction)
+
+arrow_install_all_headers("arrow/flight/sql/odbc")
+
+set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
+
+if(WIN32)
+  list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)
+endif()
+
+add_arrow_lib(arrow_flight_sql_odbc
+              CMAKE_PACKAGE_NAME
+              ArrowFlightSqlOdbc
+              PKG_CONFIG_NAME
+              arrow-flight-sql-odbc
+              OUTPUTS
+              ARROW_FLIGHT_SQL_ODBC_LIBRARIES
+              SOURCES
+              ${ARROW_FLIGHT_SQL_ODBC_SRCS}
+              DEPENDENCIES
+              arrow_flight_sql
+              DEFINITIONS
+              FMT_HEADER_ONLY
+              SHARED_LINK_FLAGS
+              ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in 
cpp/arrow/CMakeLists.txt
+              SHARED_LINK_LIBS
+              arrow_flight_sql_shared
+              SHARED_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_shared
+              STATIC_LINK_LIBS
+              arrow_flight_sql_static
+              STATIC_INSTALL_INTERFACE_LIBS
+              ArrowFlight::arrow_flight_sql_static
+              SHARED_PRIVATE_LINK_LIBS
+              ${ODBC_LIBRARIES}

Review Comment:
   Could you use CMake target as much as possible?
   
   ```suggestion
                 ODBC::ODBC
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to