Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ports/odbccpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO SAP/odbc-cpp-wrapper
REF "v${VERSION}"
SHA512 8e79536bc24bd4f59ddc9554824df255fabb7ca651839ff2c90f8a352f61da99beb1df5042c2785d86a3294bcf8c0a93064ed89a62400063755cb5a7df47ca58
HEAD_REF master
PATCHES
use-vcpkg-unixodbc.patch
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DGTEST_FOUND=OFF
-DDOXYGEN_FOUND=OFF
)

vcpkg_cmake_install()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
48 changes: 48 additions & 0 deletions ports/odbccpp/use-vcpkg-unixodbc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6861360..8d8e62a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,17 @@ SET(CMAKE_CXX_STANDARD 11)

PROJECT(odbccpp)

-FIND_PACKAGE(ODBC REQUIRED)
+IF(UNIX)
+ FIND_PACKAGE(unixodbc CONFIG)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. https://github.com/microsoft/vcpkg/blob/master/ports/unixodbc/usage#L4 I'll need to consult the team since this ports exports unofficial targets. Tagging vcpkg-team-review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it seems this is allowed and this should use the vcpkg provided configs instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Javier, thanks for checking the change. I used the directions in the usage file of unixodbc: https://github.com/microsoft/vcpkg/blob/39a6cc0e44641977a7ccdfdb01a14eaf832aa330/ports/unixodbc/usage

Still, this failed. I think the correct target is unofficial::unixodbc::unixodbc, at least for me it looks like when checking the config https://github.com/microsoft/vcpkg/blob/39a6cc0e44641977a7ccdfdb01a14eaf832aa330/ports/unixodbc/unofficial-unixodbc-config.cmake

If this is correct and it makes sense, I could open an issue or push a small fix.

+ IF(unixodbc_FOUND)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ IF(unixodbc_FOUND)
+ IF(unofficial-unixodbc_FOUND)

I haven't dug too deep into the problem here but I suspect that this is still falling back to the find_package(ODBC REQUIRED) call below which ends up searching for odbc_config and attempts to execute it.

+ SET(ODBC_TARGET UNIX::odbc)
+ ENDIF()
+ENDIF()
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()
Comment on lines +8 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must match the dependencies expressed in the manifests. I have more suggestions once the manifest dependency question is answered.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, this is wrongfully adapted. Depending on the result of the other comment, this probably should be IF(LINUX OR APPLE).

Copy link
Copy Markdown
Contributor

@JavierMatosD JavierMatosD Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must match the dependencies expressed in the manifests. I have more suggestions once the manifest dependency question is answered.

@dg0yt, is there anything else you want to suggest? Otherwise, this port looks good to go to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IF(UNIX) still seems wrong to me. This would become an installation order dependency when unixodbc is extended to support bsd or ios or android.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safest wiring would be an option which is controlled by the portfile. Here (project mode):

if(ODBCCPP_USE_UNIXODBC)
   FIND_PACKAGE(unofficial-unixodbc CONFIG REQUIRED)
   SET(ODBC_TARGET unofficial::unixodbc::unixodbc)
ELSE()
   ...

and in the portfile (vcpkg script mode):

vcpkg_list(SET options)
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)
    list(APPEND options -DODBCCPP_USE_UNIXODBC=ON)
endif()

vcpkg_cmake_configure(
    ...
    OPTIONS
       ${options}
    ...
)
  • I would probably create an alias ODBC::ODBC instead of replacing its use with a variable.
  • There is no installed CMake config. But unless using dynamic loading, there are conditional transitive usage requirements. User must duplicate the condition.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful check. I added a config file to odbccpp, this is a good thing anyway. Also, I added your suggestions, I hope it fits now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()

I don't think this fallback is needed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to an if else clause, but in general it is necessary for for Windows, I think. Hope this fits for you.

+
FIND_PACKAGE(Doxygen)
FIND_PACKAGE(GTest)

diff --git a/src/odbc/CMakeLists.txt b/src/odbc/CMakeLists.txt
index 3bff9c4..dce9e3b 100644
--- a/src/odbc/CMakeLists.txt
+++ b/src/odbc/CMakeLists.txt
@@ -57,9 +57,9 @@ TARGET_COMPILE_DEFINITIONS(odbccpp_static
ODBC_STATIC
)

-TARGET_LINK_LIBRARIES(odbccpp_static
+TARGET_LINK_LIBRARIES(odbccpp_static
PUBLIC
- ODBC::ODBC
+ ${ODBC_TARGET}
)

SET_PROPERTY(TARGET odbccpp_static PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -76,7 +76,7 @@ TARGET_COMPILE_DEFINITIONS(odbccpp

TARGET_LINK_LIBRARIES(odbccpp
PUBLIC
- ODBC::ODBC
+ ${ODBC_TARGET}
)

SET_PROPERTY(TARGET odbccpp PROPERTY public_headers ${public_headers})
21 changes: 21 additions & 0 deletions ports/odbccpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "odbccpp",
"version": "1.4",
"description": "An object-oriented C++ wrapper of the ODBC API from SAP",
"homepage": "https://github.com/SAP/odbc-cpp-wrapper",
"license": "Apache-2.0",
"dependencies": [
{
"name": "unixodbc",
"platform": "linux | osx"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is ODBC provided on other platforms which are not !windows?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look. In general I oriented on nanodbc and freetds, but I took the platform here from the supports config of unixodbc (https://github.com/microsoft/vcpkg/blob/b2f068faf45a3f04145bec0f52a66526ad590227/ports/unixodbc/vcpkg.json). For other platforms it must be provided by the system. Let me know if I miss something, I have no issue to change it to !windows if it makes sense.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following unixodbc's supports is right.

},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7084,6 +7084,10 @@
"baseline": "1.10.0",
"port-version": 0
},
"odbccpp": {
"baseline": "1.4",
"port-version": 0
},
"ode": {
"baseline": "0.16.6",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/o-/odbccpp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "ebc55eefbac8df6fa1f173b7352da7d215412b51",
"version": "1.4",
"port-version": 0
}
]
}
Loading