Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing backend includes #1122

Open
danny-mhlv opened this issue Jan 19, 2024 · 2 comments
Open

Missing backend includes #1122

danny-mhlv opened this issue Jan 19, 2024 · 2 comments
Labels

Comments

@danny-mhlv
Copy link

Issue with CMake

Setup:
OS: Ubuntu 22.04.3 LTS,
Compiler: Clang 15.0.7 x86_64,
C++ standard: c++20,
CMake version: 3.28.1.

I've just started using SOCI for my project and encountered an odd error:

soci/include/soci/postgresql/soci-postgresql.h:22:10: fatal error: 'libpq-fe.h' file not found
[build] #include <libpq-fe.h>

As follows from the error - I am using PostgreSQL. Seems like main header of libpq++ is not included.

I'm going add_subdirectory(...) route in my project (I'm using git-submodules) and building a shared library version of SOCI (SOCI_SHARED set to ON).
Before using SOCI I've read the documentation and checked out the examples. Nothing helped.
Then I've started debugging CMake and figured out something.

In soci/cmake/SociBackend.cmake file:

if (SOCI_SHARED)
  add_library(${THIS_BACKEND_TARGET}
     SHARED
     ${THIS_BACKEND_SOURCES}
     ${THIS_BACKEND_HEADERS})
     add_library(Soci::${NAMEL} ALIAS ${THIS_BACKEND_TARGET})

  target_link_libraries(${THIS_BACKEND_TARGET}
    ${SOCI_CORE_TARGET}
    ${THIS_BACKEND_DEPENDS_LIBRARIES})
...

No include directories are provided for target (soci_postgresql in my case). Considering this - I've added:

target_include_directories(${THIS_BACKEND_TARGET} 
  PUBLIC
  ${THIS_BACKEND_DEPENDS_INCLUDE_DIRS})

I do understand, that I can as well include PostgreSQL's headers directly to my target, but wouldn't it be more convenient to include libpq-fe.h in SOCI (file: SociBackend.cmake), when initializing PostgreSQL's backend, considering it is already successfully locates said headers? Am I missing something?

For better understanding I've provided a minimal reproduction repository.

Thank you in advance.

@vadz vadz added the CMake label Jan 19, 2024
@vadz
Copy link
Member

vadz commented Jan 19, 2024

Sorry, I don't understand how exactly does this differ from building SOCI directly which definitely does work. CMake is not my strong point (and I'm being euphemistic here), so it's quite possible that there is a bug in SOCI CMakefiles but I have no idea why would it happen only when it's included as a subdirectory, would you?

@Krzmbrzl
Copy link
Contributor

This will be (or should be at least) resolved via #1118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants