convert Cmake file to Qmake



  • Hello.I am trying to convert a cmake file to qmake .I am in Linux desktop.I made a qmake file of it as i know but it dose not working.It is Linux app.
    Here is original Cmake file.It Build the app fine.NO error .It has two cmake file
    NO 1.

    cmake_minimum_required(VERSION 3.0.2)
    project(CoreImageViewer)
    
    include(GNUInstallDirs)
    
    set(MAJOR_VERSION 0)
    set(MINOR_VERSION 6)
    set(PATCH_VERSION 0)
    set(LXIMAGE_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION})
    
    set(LXQTBT_MINIMUM_VERSION "0.4.0")
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    
    find_package(Qt5Widgets REQUIRED)
    find_package(Qt5Network REQUIRED)
    find_package(Qt5DBus REQUIRED)
    find_package(Qt5PrintSupport REQUIRED)
    find_package(Qt5X11Extras REQUIRED)
    find_package(Qt5LinguistTools REQUIRED)
    find_package(Qt5Svg REQUIRED)
    find_package(fm-qt REQUIRED)
    find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
    find_package(Exif REQUIRED)
    message(STATUS "Building with Qt ${Qt5Core_VERSION}")
    
    include(LXQtCompilerSettings NO_POLICY_SCOPE)
    
    # TODO: make the X11 stuff optional.
    # for screenshot support
    find_package(X11 REQUIRED)
    
    find_package(PkgConfig REQUIRED)
    # Xfixes is needed to capture the mouse cursor image
    pkg_check_modules(XFIXES REQUIRED xfixes)
    
    # add src subdirectory
    add_subdirectory(src)
    
    

    no .2 .It is in src folder.

    include_directories(
        ${X11_INCLUDE_DIR}
        ${XFIXES_INCLUDE_DIRS}
    )
    
    # For some unknown reasons these are required for build on FreeBSD
    link_directories(
        ${QT_LIBRARY_DIR}
        ${GLIB_LIBRARY_DIRS}
    )
    
    set(lximage-qt_SRCS
        lximage-qt.cpp
        mainwindow.cpp
        iapplication.cpp
        imageview.cpp
        modelfilter.cpp
        loadimagejob.cpp
        saveimagejob.cpp
        screenshotdialog.cpp
        screenshotselectarea.cpp
        screenshotselectareagraphicsview.cpp
        graphicsscene.cpp
        icons.qrc
    )
    
    qt5_add_dbus_adaptor(lximage-qt_SRCS
        org.lxde.LxImage.Application.xml
        application.h
        LxImage::Application
        applicationadaptor
        ApplicationAdaptor
    )
    
    set(lximage-qt_UIS
        mainwindow.ui
        screenshotdialog.ui
    )
    qt5_wrap_ui(lximage-qt_UI_H ${lximage-qt_UIS})
    
    # prevent the generated files from being deleted during make clean
    set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM true)
    
    # process desktop entry files
    include(LXQtTranslateDesktop)
    
    file(GLOB desktop_files_in ../data/*.desktop.in)
    lxqt_translate_desktop(desktop_files SOURCES ${desktop_files_in})
    install(FILES ${desktop_files} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
    add_executable(lximage-qt
        ${lximage-qt_SRCS}
        ${lximage-qt_UI_H}
        ${desktop_files}
        ${QM_FILES}
    )
    
    add_definitions(
        -DLXIMAGE_DATA_DIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}/lximage-qt"
        -DLXIMAGE_VERSION="${LXIMAGE_VERSION}"
    )
    
    set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Core Qt5::DBus Qt5::PrintSupport Qt5::X11Extras Qt5::Svg)
    
    target_link_libraries(lximage-qt
        fm-qt
        ${QT_LIBRARIES}
        ${EXIF_LIBRARIES}
        ${X11_LIBRARIES}
        ${XFIXES_LIBRARIES}
    )
    
    install(TARGETS lximage-qt RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
    
    

    Here is mine that i made

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = CoreImageViewer
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    INCLUDEPATH +=/usr/share/cmake/lxqt-build-tools \
                  /usr/share/cmake/fm-qt \
                  /usr/lib64/cmake/Qt5X11Extras \
                  /usr/lib64/cmake/Qt5X11Extras \
                  /usr/lib64/cmake/Qt5Widgets \
                  /usr/lib64/cmake/Qt5Svg \
                  /usr/lib64/cmake/Qt5PrintSupport \
                  /usr/lib64/cmake/Qt5Network \
                  /usr/lib64/cmake/Qt5LinguistTools \
                  /usr/lib64/cmake/Qt5Gui \
                  /usr/lib64/cmake/Qt5DBus \
                  /usr/lib64/cmake/Qt5Core \
                  /usr/share/glib-2.0/
    
    LIBS +=/usr/lib/libexif.so \
           /usr/lib/libSM.so \
           /usr/lib/libICE.so \
           /usr/lib/libX11.so \
           /usr/lib/libXRes.so \
           /usr/lib/libXtst.so \
           /usr/lib/libXau.so \
           /usr/lib/libXcomposite.so \
           /usr/lib/libXcursor.so \
           /usr/lib/libXdamage.so \
           /usr/lib/libXdmcp.so \
           /usr/lib/libXext.so \
           /usr/lib/libXfixes.so \
           /usr/lib/libXft.so \
           /usr/lib/libXi.so \
           /usr/lib/libXinerama.so \
           /usr/lib/libXi.so \
           /usr/lib/libxkbfile.so \
           /usr/lib/libXmu.so \
           /usr/lib/libXpm.so \
           /usr/lib/libXrandr.so \
           /usr/lib/libXrender.so \
           /usr/lib/libXss.so \
           /usr/lib/libXt.so \
           /usr/lib/libXv.so \
           /usr/lib/libXxf86misc.so \
           /usr/lib/libXxf86vm.so
    
    SOURCES += \
        icons.qrc \
        graphicsscene.cpp \
        iapplication.cpp \
        iapplicationadaptor.cpp \
        imageview.cpp \
        loadimagejob.cpp \
        lximage-qt.cpp \
        mainwindow.cpp \
        modelfilter.cpp \
        saveimagejob.cpp \
        screenshotdialog.cpp \
        screenshotselectarea.cpp \
        screenshotselectareagraphicsview.cpp
    
    HEADERS += \
        graphicsscene.h \
        iapplication.h \
        iapplicationadaptor.h \
        imageview.h \
        loadimagejob.h \
        lximage-qt.h \
        mainwindow.h \
        modelfilter.h \
        saveimagejob.h \
        screenshotdialog.h \
        screenshotselectarea.h \
        screenshotselectareagraphicsview.h \
        ui_mainwindow.h \
        ui_screenshotdialog.h
    
    FORMS += \
        mainwindow.ui \
        screenshotdialog.ui
    

    Showing error massage.when i build the app with the cmake file (first one) it builds file.
    Please Help Me.

    /usr/include/libfm/fm-folder.h:28: error: glib-object.h: No such file or directory
    #include <glib-object.h>
             ^~~~~~~~~~~~~~~
    

  • Moderators

    @saber There is no need to add all these CMake directories like: /usr/lib64/cmake/...
    Also no need to add libraries from /usr/lib - these will be found automatically if needed.
    Try with

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = CoreImageViewer
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += \
        icons.qrc \
        graphicsscene.cpp \
        iapplication.cpp \
        iapplicationadaptor.cpp \
        imageview.cpp \
        loadimagejob.cpp \
        lximage-qt.cpp \
        mainwindow.cpp \
        modelfilter.cpp \
        saveimagejob.cpp \
        screenshotdialog.cpp \
        screenshotselectarea.cpp \
        screenshotselectareagraphicsview.cpp
    
    HEADERS += \
        graphicsscene.h \
        iapplication.h \
        iapplicationadaptor.h \
        imageview.h \
        loadimagejob.h \
        lximage-qt.h \
        mainwindow.h \
        modelfilter.h \
        saveimagejob.h \
        screenshotdialog.h \
        screenshotselectarea.h \
        screenshotselectareagraphicsview.h \
        ui_mainwindow.h \
        ui_screenshotdialog.h
    
    FORMS += \
        mainwindow.ui \
        screenshotdialog.ui
    


  • @jsulm Thanks for reply

    Qt outputs this error

    /usr/include/libfm/fm-folder.h:28: error: glib-object.h: No such file or directory
     #include <glib-object.h>
              ^~~~~~~~~~~~~~~
    

  • Moderators

    @saber On Ubuntu you need to install libglib2.0-dev package.
    Not Qt is outputting this error, but the compiler.



  • @jsulm
    It is in my linux system.(manjaro)
    cmake file can find it and it build without error.
    i think qmake file is not finding it.


  • Moderators

    @saber Where is this file located on your system?



  • @jsulm sorry for delay.new user can post after 300 second.

    glib2.0 is located in " /usr/lib/glib-2.0/"

    to build this app it also needs 2 folder "lxqt-build-tools" and "fm-qt "

    i have thoes installed but no linkeage in qmake.but cmake file link this two file.


  • Moderators

    @saber said in convert Cmake file to Qmake:

    /usr/lib/glib-2.0/

    This is the directory containing the libs. Your problem is the header file. Where is glib-object.h located?



  • @jsulm

    glib-object.h is located in ''/usr/include/glib-2.0/''


  • Moderators

    @saber Then add this to the pro file:

    INCLUDEPATH += /usr/include/glib-2.0
    

    Don't forget to rerun qmake before building.



  • @jsulm it solved old problem .But new one

    /usr/include/glib-2.0/glib/gtypes.h:32: error: glibconfig.h: No such file or directory
     #include <glibconfig.h>
              ^~~~~~~~~~~~~~
    

    i think I should include all the path like you said.
    but it will be a long .pro file


  • Moderators

    @saber I don't know why you have to add these include directories because on Ubuntu it is not necessary.



  • first I tried to build it on Ubuntu but got the first error.
    so moved to manjaro and tried to build but got the same error.
    can u please see the cmake file .
    because it does not shows this error.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.