Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QMake alternative of cmake's “find_package”?

    General and Desktop
    2
    4
    636
    Loading More Posts
    • 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.
    • A
      aravmadd last edited by aravmadd

      HI,

      Currently i am using eigen library for one of my project.

      In CMake I can simply specifiy like

      find_package(Eigen3 CONFIGREQUIREDHINTS${CMAKE_SOURCE_DIR}/libs/eigen/share/eigen3/cmake)
      

      However in Qmake i need to specify like

      INCLUDEPATH += ..\dependencies\eigen\include\eigen3\Eigen
      

      By doing like mentioned above in pro file the problem is in my source codes i need to mention like below which are local paths and i dont like to use local paths so that it wont be a problem if i give this code to someone.

      #include <C:\Users\aravmadd\Desktop\project_qt\libs\eigen\include\eigen3\Eigen\Dense>
      
      However if i use find_package like CMake, i can just use like #include "Eigen\Dense"  in  the source codes
      

      Can you please suggest some alternatives so that i can replace that above local include path to simply like #include "Eigen\Dense"

      For Example if i mentioned in qmake

      INCLUDEPATH += ..\libs\eigen\include\eigen3\Eigen
      
      LIBS += -lwsock32
      LIBS += -lws2_32
      LIBS +=  -lkernel32 -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
      

      then i can use eigen library like this in my source codes
      qmake.JPG

      However if i use cmake like this

      find_package(Eigen3 CONFIGREQUIREDHINTS${CMAKE_SOURCE_DIR}/libs/eigen/share/eigen3/cmake)
      
      target_link_libraries(project PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Concurrent  wsock32 ws2_32 Eigen3::Eigen)
      

      then i can use eigen functionalites like this in my source code.
      ifcmake.JPG

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        @aravmadd said in QMake alternative of cmake's “find_package”?:

        INCLUDEPATH += ..\libs\eigen\include\eigen3\Eigen

        If you do this:

        INCLUDEPATH += ../libs/eigen/include/eigen3
        

        It will allow you to use nice includes:

        #include "Eigen/Dense"
        #include "Eigen/Geometry"
        

        Regarding your main question - there is nothing like find_package() in qmake. That's one of the reasons why Qt is moving away from qmake :-)

        There is stuff like inclusion of .pri files, or even .prf, but it does not compare to find_package() at all.

        (Z(:^

        A 1 Reply Last reply Reply Quote 2
        • sierdzio
          sierdzio Moderators last edited by

          @aravmadd said in QMake alternative of cmake's “find_package”?:

          INCLUDEPATH += ..\libs\eigen\include\eigen3\Eigen

          If you do this:

          INCLUDEPATH += ../libs/eigen/include/eigen3
          

          It will allow you to use nice includes:

          #include "Eigen/Dense"
          #include "Eigen/Geometry"
          

          Regarding your main question - there is nothing like find_package() in qmake. That's one of the reasons why Qt is moving away from qmake :-)

          There is stuff like inclusion of .pri files, or even .prf, but it does not compare to find_package() at all.

          (Z(:^

          A 1 Reply Last reply Reply Quote 2
          • A
            aravmadd @sierdzio last edited by aravmadd

            @sierdzio Thanks for the quick reply.

            I tried with cmake it is working great, but only problem is when i run the executable and generate all the dlls required using windeployqt.exe then for some reasons along with gui there is one thing like cmd shell is also opening :-(. Instead of trying to find this i thought i will find some alternative for find_package in qmake

            What i did was i have a folder called 3rd_Party.It only contains CMakeLists.txt file. And this CMakeList file builds the eigen library and creates one folder libs.And inside libs folder i can find all the required things. So basically now my build procedure is of two steps. First step is to build eigen thing using CMakelists.txt and second step was building qt project using qmake in QtCreator

            1 Reply Last reply Reply Quote 0
            • sierdzio
              sierdzio Moderators last edited by

              And you go to all that trouble just because a terminal window is showing up? You should rather fix the root cause of that instead of investing time in workarounds! And it is easy to do:

              add_executable(projectName WIN32 main.cpp)
              

              This WIN32 should be enough to stop terminal from showing up.

              (Z(:^

              1 Reply Last reply Reply Quote 0
              • First post
                Last post