Skip to content

[odbccpp] Add new port#50152

Draft
florsap wants to merge 20 commits intomicrosoft:masterfrom
florsap:add-odbccpp
Draft

[odbccpp] Add new port#50152
florsap wants to merge 20 commits intomicrosoft:masterfrom
florsap:add-odbccpp

Conversation

@florsap
Copy link
Copy Markdown

@florsap florsap commented Feb 24, 2026

  • Changes comply with the maintainer guide.
  • The packaged project shows strong association with the chosen port name. Check this box if at least one of the following criteria is met:
    • The project is amongst the first web search results for "" or " C++". Include a screenshot of the search engine results in the PR.
Screenshot 2026-02-24 at 09 25 00
  • Optional dependencies of the build are all controlled by the port. A dependency is controlled if it is declared an unconditional dependency in vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGE
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.

@florsap
Copy link
Copy Markdown
Author

florsap commented Feb 24, 2026

@microsoft-github-policy-service agree [company="SAP"]

@florsap
Copy link
Copy Markdown
Author

florsap commented Feb 24, 2026

@microsoft-github-policy-service agree company="SAP"

@JavierMatosD JavierMatosD marked this pull request as draft February 24, 2026 15:20
"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.

Comment on lines +9 to +19
-FIND_PACKAGE(ODBC REQUIRED)
+IF(UNIX)
+ FIND_PACKAGE(unixodbc CONFIG)
+ IF(unixodbc_FOUND)
+ SET(ODBC_TARGET UNIX::odbc)
+ ENDIF()
+ENDIF()
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()
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.

@florsap
Copy link
Copy Markdown
Author

florsap commented Feb 27, 2026

Hey, Odbccpp is an open source wrapper for the odbc api to use in c++. Currently, it is mostly used for two other open source projects GDAL and QGIS, it would be cool for them to have it available in vcpkg.
I hope the change is fine, I tried to orient on available ports and hopefully didn't miss anything in the maintainer guide. Thanks for taking a look and maybe considering it.

@florsap florsap marked this pull request as ready for review February 27, 2026 16:16
@florsap florsap marked this pull request as draft February 27, 2026 18:36
@florsap florsap marked this pull request as ready for review March 2, 2026 08:14
Copy link
Copy Markdown
Contributor

@JavierMatosD JavierMatosD left a comment

Choose a reason for hiding this comment

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

Tagging team review to discuss the proper find_package call


-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.

"dependencies": [
{
"name": "unixodbc",
"platform": "!windows"
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 port in vcpkg supports "linux | osx"

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.

Fixed it. I thought the same originally, but it seems to be the common way to use !windows for other packages. https://github.com/search?q=repo%3Amicrosoft%2Fvcpkg+%22name%22%3A+%22unixodbc%22%2C+++++++%22platform%22%3A+%22%21windows%22&type=code

But I'm fine with either and for me "linux | osx" seems to be more precise, too.

@JavierMatosD JavierMatosD added requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. and removed requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. labels Mar 2, 2026
@JavierMatosD JavierMatosD marked this pull request as draft March 2, 2026 22:40
@florsap florsap marked this pull request as ready for review March 3, 2026 11:29
-FIND_PACKAGE(ODBC REQUIRED)
+IF(UNIX)
+ FIND_PACKAGE(unofficial-unixodbc CONFIG)
+ 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.

Comment on lines +14 to +17
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()
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.

@JavierMatosD JavierMatosD marked this pull request as draft March 5, 2026 21:44
Copy link
Copy Markdown
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

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

Hm, my review wasn't submitted when I wrote it.

"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.

Following unixodbc's supports is right.

Comment on lines +9 to +19
-FIND_PACKAGE(ODBC REQUIRED)
+IF(UNIX)
+ FIND_PACKAGE(unixodbc CONFIG)
+ IF(unixodbc_FOUND)
+ SET(ODBC_TARGET UNIX::odbc)
+ ENDIF()
+ENDIF()
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()
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.

Comment on lines +9 to +19
-FIND_PACKAGE(ODBC REQUIRED)
+IF(UNIX)
+ FIND_PACKAGE(unixodbc CONFIG)
+ IF(unixodbc_FOUND)
+ SET(ODBC_TARGET UNIX::odbc)
+ ENDIF()
+ENDIF()
+IF(NOT ODBC_TARGET)
+ FIND_PACKAGE(ODBC REQUIRED)
+ SET(ODBC_TARGET ODBC::ODBC)
+ENDIF()
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants