Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting CMake's FetchContent_Declare to pull from specific branch
Qt 6.11 is out! See what's new in the release blog

Getting CMake's FetchContent_Declare to pull from specific branch

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 330 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BastienSante
    wrote last edited by BastienSante
    #1

    Hello everyone, I don't know if here is the right place to ask, but I'm starting to work on my note editor again. Recently, MicroTeX has recieved updates, but they are not yet present on the master branch. I'm using it to render LaTeX fragments in QTextDocuments.

    my CMakeLists.txt contains these lines :

    FetchContent_Declare(MicroTeX
                         GIT_REPOSITORY https://github.com/NanoMichael/MicroTeX.git
                         GIT_TAG origin/master
    )
    
    FetchContent_MakeAvailable(MicroTeX)
    

    Since the most recent branch of MicroTeX is openmath, I've tried to change the GIT_TAG to origin/openmath or
    "openmath". However, doing so blocks all builds, as CMake says it could not clone the repository. How Can I force CMake to use this branch ?

    Thanks for your answers.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      From a quick look at the documentation of FetchContent_Declare, I think you should pass the commit hash matching that tag.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote last edited by
        #3

        I've tried to change the GIT_TAG to origin/openmath or "openmath". However, doing so blocks all builds, as CMake says it could not clone the repository.

        Can you show us the error message?

        I used GIT_TAG origin/openmath and it fetched correctly, however broke the configure step because that branch's code is full of compiler warnings, treated as error. (If I use origin/master, I get an unmet tinyxml2 dependency instead, which I haven't bothered installing).

        I think you should pass the commit hash matching that tag.

        This is correct, you should, for security (not technical) reasons:

        it is advisable to use a hash for GIT_TAG rather than a branch or tag name. A commit hash is more secure and helps to confirm that the downloaded contents are what you expected.^1

        But branch and tag names work too.

        Since the openmath branch has not changed in 2 years, you could always try:

          GIT_TAG 086f4eb740270b28bd0c61a0a359aea9300d61ae # Current openmath HEAD.
        

        For which I get the same result as GIT_TAG origin/openmath - ie it fetches, just has compilation errors compiling the MicroTex source.

        Cheers.

        SGaistS 1 Reply Last reply
        1
        • A Offline
          A Offline
          alexiaamber
          wrote last edited by
          #4

          One thing I'd check first is whether the openmath branch actually exists on the remote and whether your local CMake cache is holding on to an older checkout.

          You could also try specifying the branch name directly:

          FetchContent_Declare(
              MicroTeX
              GIT_REPOSITORY https://github.com/NanoMichael/MicroTeX.git
              GIT_TAG openmath
              GIT_SHALLOW FALSE
          )
          

          If you've already configured the project once, delete the _deps directory (or at least the microtex-src folder) and rerun CMake so it performs a fresh clone. I've run into cases where FetchContent kept using the cached repository and ignored changes to GIT_TAG.

          If it still fails, does the error say it can't find the openmath ref, or is it failing during the clone itself? That detail would help narrow down whether it's a branch name issue or something else.

          1 Reply Last reply
          0
          • Paul ColbyP Paul Colby

            I've tried to change the GIT_TAG to origin/openmath or "openmath". However, doing so blocks all builds, as CMake says it could not clone the repository.

            Can you show us the error message?

            I used GIT_TAG origin/openmath and it fetched correctly, however broke the configure step because that branch's code is full of compiler warnings, treated as error. (If I use origin/master, I get an unmet tinyxml2 dependency instead, which I haven't bothered installing).

            I think you should pass the commit hash matching that tag.

            This is correct, you should, for security (not technical) reasons:

            it is advisable to use a hash for GIT_TAG rather than a branch or tag name. A commit hash is more secure and helps to confirm that the downloaded contents are what you expected.^1

            But branch and tag names work too.

            Since the openmath branch has not changed in 2 years, you could always try:

              GIT_TAG 086f4eb740270b28bd0c61a0a359aea9300d61ae # Current openmath HEAD.
            

            For which I get the same result as GIT_TAG origin/openmath - ie it fetches, just has compilation errors compiling the MicroTex source.

            Cheers.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote last edited by
            #5

            @Paul-Colby Thanks for the clarification you made !

            I was way too terse with my answer.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved