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. Connecting CMakeLists.txt with project
Forum Updated to NodeBB v4.3 + New Features

Connecting CMakeLists.txt with project

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.0k 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.
  • J Offline
    J Offline
    JayJay
    wrote on last edited by JayJay
    #1

    Hello,
    I work with UHD Driver (for USRP device) and I have already written some code. My project contains main.cpp and CMakeLists.txt. I would like to plot samples which i recieve from the device. I thought QT would be the best choice.
    The main problem is I don't know how can I open the files which already exist and expand the project with GUI using QT.
    When I try to open this project defaultly I recieve plain C++ mode and I can't use QT's cpabilities.
    I work on Ubuntu and I have installed newest Cmake version.

    CMakeLists.txt looks like this

    cmake_minimum_required(VERSION 2.8)
    
    
    option(UHD_USE_STATIC_LIBS OFF)
    
    
    set(BOOST_REQUIRED_COMPONENTS
        program_options
        system
        thread
    )
    if(MSVC)
        set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
        if(BOOST_ALL_DYN_LINK)
            add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
        else(BOOST_ALL_DYN_LINK)
            set(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
        endif(BOOST_ALL_DYN_LINK)
    endif(MSVC)
    find_package(Boost "1.46" REQUIRED ${BOOST_REQUIRED_COMPONENTS})
    
    if(CMAKE_VERSION VERSION_LESS "3.1")
        if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
            set(CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
        elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
            if("${IS_APPLE}" STREQUAL "")
                set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
            else()
                set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
            endif()
        endif()
    else()
        set(CMAKE_CXX_STANDARD 11)
    endif()
    
    if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
        set(CMAKE_EXE_LINKER_FLAGS "-lthr ${CMAKE_EXE_LINKER_FLAGS}")
        set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
    endif()
    
    include_directories(
        ${Boost_INCLUDE_DIRS}
        ${UHD_INCLUDE_DIRS}
    )
    link_directories(${Boost_LIBRARY_DIRS})
    
    
    add_executable(projekt projekt.cpp)
    
    set(CMAKE_BUILD_TYPE "Release")
    message(STATUS "******************************************************************************")
    message(STATUS "* NOTE: When building your own app, you probably need all kinds of different  ")
    message(STATUS "* compiler flags. This is just an example, so it's unlikely these settings    ")
    message(STATUS "* exactly match what you require. Make sure to double-check compiler and     ")
    message(STATUS "* linker flags to make sure your specific requirements are included.          ")
    message(STATUS "******************************************************************************")
    
    
    if(NOT UHD_USE_STATIC_LIBS)
        message(STATUS "Linking against shared UHD library.")
        target_link_libraries(projekt ${UHD_LIBRARIES} ${Boost_LIBRARIES})
    
    else(NOT UHD_USE_STATIC_LIBS)
        message(STATUS "Linking against static UHD library.")
        target_link_libraries(projekt
    
        )
    endif(NOT UHD_USE_STATIC_LIBS)
    

    I use that in my project:

    #include <uhd/utils/thread.hpp>
    #include <uhd/utils/safe_main.hpp>
    #include <uhd/usrp/multi_usrp.hpp>
    #include <uhd/exception.hpp>
    #include <uhd/types/tune_request.hpp>
    #include <boost/program_options.hpp>
    #include <boost/format.hpp>
    #include <boost/thread.hpp>
    

    Thanks for answeres :)

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

      Hi and welcome to devnet,

      Here you have the Qt CMake manual that should get you started.

      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
      1
      • J Offline
        J Offline
        JayJay
        wrote on last edited by
        #3

        Honestly I have already read it and it isn't clear for me at all.

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

          To get started, did you try to build a simple Qt application using the information of that guide ?

          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
          • J JayJay

            Hello,
            I work with UHD Driver (for USRP device) and I have already written some code. My project contains main.cpp and CMakeLists.txt. I would like to plot samples which i recieve from the device. I thought QT would be the best choice.
            The main problem is I don't know how can I open the files which already exist and expand the project with GUI using QT.
            When I try to open this project defaultly I recieve plain C++ mode and I can't use QT's cpabilities.
            I work on Ubuntu and I have installed newest Cmake version.

            CMakeLists.txt looks like this

            cmake_minimum_required(VERSION 2.8)
            
            
            option(UHD_USE_STATIC_LIBS OFF)
            
            
            set(BOOST_REQUIRED_COMPONENTS
                program_options
                system
                thread
            )
            if(MSVC)
                set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
                if(BOOST_ALL_DYN_LINK)
                    add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
                else(BOOST_ALL_DYN_LINK)
                    set(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
                endif(BOOST_ALL_DYN_LINK)
            endif(MSVC)
            find_package(Boost "1.46" REQUIRED ${BOOST_REQUIRED_COMPONENTS})
            
            if(CMAKE_VERSION VERSION_LESS "3.1")
                if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
                    set(CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
                elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
                    if("${IS_APPLE}" STREQUAL "")
                        set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
                    else()
                        set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
                    endif()
                endif()
            else()
                set(CMAKE_CXX_STANDARD 11)
            endif()
            
            if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
                set(CMAKE_EXE_LINKER_FLAGS "-lthr ${CMAKE_EXE_LINKER_FLAGS}")
                set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
            endif()
            
            include_directories(
                ${Boost_INCLUDE_DIRS}
                ${UHD_INCLUDE_DIRS}
            )
            link_directories(${Boost_LIBRARY_DIRS})
            
            
            add_executable(projekt projekt.cpp)
            
            set(CMAKE_BUILD_TYPE "Release")
            message(STATUS "******************************************************************************")
            message(STATUS "* NOTE: When building your own app, you probably need all kinds of different  ")
            message(STATUS "* compiler flags. This is just an example, so it's unlikely these settings    ")
            message(STATUS "* exactly match what you require. Make sure to double-check compiler and     ")
            message(STATUS "* linker flags to make sure your specific requirements are included.          ")
            message(STATUS "******************************************************************************")
            
            
            if(NOT UHD_USE_STATIC_LIBS)
                message(STATUS "Linking against shared UHD library.")
                target_link_libraries(projekt ${UHD_LIBRARIES} ${Boost_LIBRARIES})
            
            else(NOT UHD_USE_STATIC_LIBS)
                message(STATUS "Linking against static UHD library.")
                target_link_libraries(projekt
            
                )
            endif(NOT UHD_USE_STATIC_LIBS)
            

            I use that in my project:

            #include <uhd/utils/thread.hpp>
            #include <uhd/utils/safe_main.hpp>
            #include <uhd/usrp/multi_usrp.hpp>
            #include <uhd/exception.hpp>
            #include <uhd/types/tune_request.hpp>
            #include <boost/program_options.hpp>
            #include <boost/format.hpp>
            #include <boost/thread.hpp>
            

            Thanks for answeres :)

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @JayJay said in Connecting CMakeLists.txt with project:

            and I can't use QT's cpabilities

            Are you saying you can't use Qt or you can't use Qt Creator?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • J Offline
              J Offline
              JayJay
              wrote on last edited by
              #6

              I mean, when I open my project by CMakeLists it doesnt't give me the opurtinity to using QT like I would use it with .pro file. When I right click on the project the option "Add new" is blanked.

              mrjjM 1 Reply Last reply
              0
              • J JayJay

                I mean, when I open my project by CMakeLists it doesnt't give me the opurtinity to using QT like I would use it with .pro file. When I right click on the project the option "Add new" is blanked.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @JayJay
                That is normal as far as i know.
                With cmake, you must manually add new files.

                1 Reply Last reply
                3

                • Login

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