Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. What's the right way to use Find*.cmake modules in cmake/Qt6?

What's the right way to use Find*.cmake modules in cmake/Qt6?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 855 Views 1 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.
  • S Offline
    S Offline
    Sauntor
    wrote on last edited by
    #1

    There are many 3rd party Find*.cmake modules in /usr/lib64/cmake/Qt6, i.e., FindWrapBrotli.cmake, FindMySQL.cmake, .etc.

    I try using it as following:

    find(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets ...)
    # XX: import module
    include("${QT_DIR}/FindMySQL.cmake")
    
    add_executable(mydemo ...)
    # XX: use variables output by FindMySQL.cmake
    target_include_directories(mydemo PUBLIC ${MySQL_INCLUDE_DIR})
    target_link_libraries(mydemo PUBLIC ${MySQL_LIBRARY})
    

    In the above example, contains this line:

    include("${QT_DIR}/FindMySQL.cmake")
    

    Is there any problem in this use case? Or is there an Offical way/guide that makes the same purpose?

    Christian EhrlicherC 1 Reply Last reply
    0
    • S Sauntor

      There are many 3rd party Find*.cmake modules in /usr/lib64/cmake/Qt6, i.e., FindWrapBrotli.cmake, FindMySQL.cmake, .etc.

      I try using it as following:

      find(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets ...)
      # XX: import module
      include("${QT_DIR}/FindMySQL.cmake")
      
      add_executable(mydemo ...)
      # XX: use variables output by FindMySQL.cmake
      target_include_directories(mydemo PUBLIC ${MySQL_INCLUDE_DIR})
      target_link_libraries(mydemo PUBLIC ${MySQL_LIBRARY})
      

      In the above example, contains this line:

      include("${QT_DIR}/FindMySQL.cmake")
      

      Is there any problem in this use case? Or is there an Offical way/guide that makes the same purpose?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @Sauntor simply use

      Find_package(MySQL) even though I don't know why you want to use MySQL directly.

      See https://cmake.org/cmake/help/latest/command/find_package.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @Sauntor simply use

        Find_package(MySQL) even though I don't know why you want to use MySQL directly.

        See https://cmake.org/cmake/help/latest/command/find_package.html

        S Offline
        S Offline
        Sauntor
        wrote on last edited by
        #3

        @Christian-Ehrlicher Those Find*.cmake seems deal cross platform problem already, i.e., deliver my project on windows and linux, if on windows, the Find*.cmake would check vcpkg, on linux, it may find components using pkg-config, so, I do not have to write my own script when build using cmake. That's why I want to use those cmake scripts/modules!

        Christian EhrlicherC 1 Reply Last reply
        0
        • S Sauntor

          @Christian-Ehrlicher Those Find*.cmake seems deal cross platform problem already, i.e., deliver my project on windows and linux, if on windows, the Find*.cmake would check vcpkg, on linux, it may find components using pkg-config, so, I do not have to write my own script when build using cmake. That's why I want to use those cmake scripts/modules!

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sauntor So what's the problem - simply use them as I wrote.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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