- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
Description
I am installing Drogon with Postgres support. I have the development headers and libraries. CMake detects Postgres and sets pg_FOUND correctly. Postgres is enabled with option(USE_POSTGRESQL "Enable PostgreSQL" ON). However, the preprocessor symbol USE_POSTGRESQL is not set. Thus in DbClientManager::addDbClient()  in orm_lib/src/DBClientManager.cc the code to add the Postgres connection configuration to the dbInfos_ vector is not compiled and the fatal error is produced at runtime instead.
To resolve the problem, I manually added the USE_POSTGRESQL definition to CMakeLists.txt around line 616:
if (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
    if (pg_FOUND)
        message(STATUS "Enable PostgreSQL")
        option(USE_POSTGRESQL "Enable PostgreSQL" ON)
        add_definitions(-DUSE_POSTGRESQL)
    else (pg_FOUND)
        option(USE_POSTGRESQL "Disable PostgreSQL" OFF)
    endif (pg_FOUND)I confirmed the absence of the USE_POSTGRESQL symbol was the issue by adding static_assert and assert macros to the Drogon source code, rebuilding, and observing that compilation and runtime failures occurred in the expected places.
Once I added the definition directly to CMakeLists.txt I was able to connect to my Postgres server without any further issues.
I am using Ubuntu 22.04 with gcc 15 and CMake 4.