Problem adding realm to C++ Qt app

I used Qt Creator to create a new Qt 6.7 console app.

I then added cpprealm to CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(
    cpprealm
    GIT_REPOSITORY https://github.com/realm/realm-cpp.git
    GIT_TAG        v1.0.0
)
FetchContent_MakeAvailable(cpprealm)

Running cmake then fails:

-- CMake version: 3.29.2
Dependencies: PACKAGE_NAME=realm-core;VERSION=13.25.1;OPENSSL_VERSION=3.0.8;ZLIB_VERSION=1.2.13;MDBREALM_TEST_SERVER_TAG=2023-12-15
-- Using linker gold
Dependencies: VERSION=1.0.0
-- Configuring done (0.6s)
CMake Error in build/Desktop_Qt_6_7_0-Debug/_deps/cpprealm-src/realm-core/src/realm/object-store/CMakeLists.txt:
  The dependency target "LibUV::LibUV" of target
  "ObjectStore_autogen_timestamp_deps" does not exist.


CMake Error in build/Desktop_Qt_6_7_0-Debug/_deps/cpprealm-src/src/CMakeLists.txt:
  The dependency target "CURL::libcurl" of target
  "cpprealm_autogen_timestamp_deps" does not exist.


CMake Error in build/Desktop_Qt_6_7_0-Debug/_deps/cpprealm-src/src/CMakeLists.txt:
  The dependency target "LibUV::LibUV" of target
  "cpprealm_autogen_timestamp_deps" does not exist.

However, there are three Qt specific settings in Qt Creator generated CMakeLists.txt:

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

If I turn off the first two:

set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTOMOC OFF)
set(CMAKE_AUTORCC ON)

cmake runs successfully and the project builds as expected.

Relevant documentation for those two settings is here:

Leaving AUTOIUC and AUTOMOC off would be very inconvenient when developing a Qt app. However, I don’t have enough familiarity with either CMake or the realm-cpp library to know how to resolve this.

If this should be an issue, I’m happy to add to the relevant issue tracking system.

Hi @Doug_Reese

Thanks for pointing this out, this is indeed an issue. Can you file the issue with the details here: Sign in to GitHub · GitHub

What’s happening is that our CMakeLists for realm-cpp haven’t added a special case to say that Qt does not require LibUV or CURL. You can also get around this by installing realm-cpp as a library on your system.

Hi Lee,

I figured out a solution that seems to work, but I’m not sure yet if there are other negative implications. I added

set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTOMOC OFF)
set(CMAKE_AUTORCC OFF)

to

  • realm-cpp: src/CMakeLists.txt
  • realm-core: src/realm/object-store/CMakeLists.txt

Although this is a different solution than what you describe, I’m happy to submit a pull request instead of a bug report if this is acceptable.

Installing realm-cpp as a library might be a better solution. I don’t see this option in the docs. Would this work on Linux, MacOS, and Windows? I need to target all three platforms. Do you have any advice as to the best way to install realm-cpp on all three platforms?

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.