Uploaded image for project: 'SWORD'
  1. SWORD
  2. API-263

CMakeLists.txt uses deprecated singular CURL_LIBRARY, breaking libcurl linking on modern CMake

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.9.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Linux (Fedora 44 host, building in GNOME 50 Flatpak SDK based on freedesktop-sdk 5.08)
      CMake 3.28
      GCC 14
      curl 8.x (from SDK)

      Description

      Hello,

      I ran into a build issue with SWORD 1.9.0 while packaging a SWORD-based
      application for Flathub against a recent toolchain (CMake 3.28+,
      freedesktop-sdk 25.08). I tracked it down to what I believe is a small
      upstream bug, and wanted to report it in case you'd like to fix it for
      the next release.

      Symptom
      -------
      libsword.so builds successfully but has no NEEDED entry for libcurl
      and ships with unresolved curl_easy_* symbols. Any downstream binary
      that links against libsword (including SWORD's own buildtest) then
      fails to link with:

      undefined reference to `curl_easy_init'
      undefined reference to `curl_easy_perform'
      undefined reference to `curl_easy_setopt'
      undefined reference to `curl_easy_cleanup'
      undefined reference to `curl_global_init'
      undefined reference to `curl_global_cleanup'

      Despite CMake reporting curl as found:

      – cURL: system and /usr/include

      Note the empty space between "system" and "and" — that's where the
      curl library path was supposed to print.

      Root cause
      ----------
      In CMakeLists.txt around line 219:

      SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${CURL_LIBRARY})

      This uses the singular ${CURL_LIBRARY}. Modern CMake's FindCURL.cmake
      (since roughly 3.4) only sets CURL_LIBRARIES (plural) — the singular
      form has been deprecated and is no longer set on current CMake
      versions. The substitution therefore expands to an empty string, and
      libcurl never makes it onto the link line.

      The same pattern is used correctly elsewhere in the file (zlib, bzip2,
      xz, icu all use the singular form, but those Find modules still set
      the singular variable in modern CMake).

      Suggested fix
      -------------
      A one-line change to CMakeLists.txt:

      — a/CMakeLists.txt
      +++ b/CMakeLists.txt
      @@ -216,7 +216,7 @@ IF(WITH_CURL)
      ENDIF(CURL_CONFIG_OUTPUT STREQUAL "1")
      ENDIF(CURL_CONFIG)
      INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})

      • SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${CURL_LIBRARY})
        + SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${CURL_LIBRARIES})
        ENDIF(WITH_CURL)

      I verified this against SWORD 1.9.0 on CMake 3.28 with the GNOME 50
      runtime — libsword.so now correctly carries libcurl.so.4 in its NEEDED
      entries, and all downstream targets link cleanly.

      Most distributions probably don't hit this because they carry their
      own patches, or they use older CMake versions where the singular
      variable is still set. It only becomes visible on a freshly-modern
      toolchain.

      Happy to send a proper merge request if a Git repo is the preferred
      intake — otherwise feel free to apply the diff directly.

      Thanks for SWORD — it's the backbone of a Bible study app I'm building
      for the Linux desktop.

      Best regards,
      Andres Messina

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              andresmessina-SDG Andres Messina
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: