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. Include what you use
Qt 6.11 is out! See what's new in the release blog

Include what you use

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 765 Views
  • 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.
  • P Offline
    P Offline
    Pascal06
    wrote on last edited by
    #1

    Hello everybody,
    I'm fresh new to QT.
    I want to compile my first project (an example that I found on the internet) with QT, but I've got an error:

    CMake Error at CMakeLists.txt:20 (message):
      Could not find the program include-what-you-use
    

    How making this "include what you use" work in QT ?
    Thanks a lot in advance.

    Christian EhrlicherC 1 Reply Last reply
    0
    • P Pascal06

      Hello everybody,
      I'm fresh new to QT.
      I want to compile my first project (an example that I found on the internet) with QT, but I've got an error:

      CMake Error at CMakeLists.txt:20 (message):
        Could not find the program include-what-you-use
      

      How making this "include what you use" work in QT ?
      Thanks a lot in advance.

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

      @Pascal06 said in Include what you use:

      How making this "include what you use" work in QT ?

      Why do you want to use it? How did you compile include-what-you-use and is it in your PATH so cmake can find it?

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

      P 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @Pascal06 said in Include what you use:

        How making this "include what you use" work in QT ?

        Why do you want to use it? How did you compile include-what-you-use and is it in your PATH so cmake can find it?

        P Offline
        P Offline
        Pascal06
        wrote on last edited by
        #3

        @Christian-Ehrlicher
        Hello, thanks a lot for your reply.
        I don't know why I have to use this thing, it was in the project:

        project(xclm)
        cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
        
        set(CMAKE_CXX_STANDARD 11)
        set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
        set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
        set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
        
        # add single headers to project structure
        FILE(GLOB_RECURSE HeaderFiles "*.h")
        add_custom_target(headers SOURCES ${HeaderFiles})
        
        include_directories(.)
        
        find_package(Boost 1.57.0 COMPONENTS system program_options filesystem REQUIRED)
        
        if(Boost_FOUND)
            find_program(iwyu_path NAMES include-what-you-use iwyu)
            if(NOT iwyu_path)
              message(FATAL_ERROR "Could not find the program include-what-you-use")
            endif()
        
            set(iwyu_path_and_options ${iwyu_path} -Xiwyu --check_also)
        
            aux_source_directory(. SRC_LIST)
            aux_source_directory(hashes SRC_LIST)
            aux_source_directory(runner SRC_LIST)
            aux_source_directory(version SRC_LIST)
            add_executable(${PROJECT_NAME} ${SRC_LIST})
            target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
            set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
        else()
            message(FATAL_ERROR "boost library not found.")
        endif()
        

        Be indulgent, I'm very newbie to QT...
        Thanks a lot for your comprehsion

        Christian EhrlicherC 1 Reply Last reply
        0
        • P Pascal06

          @Christian-Ehrlicher
          Hello, thanks a lot for your reply.
          I don't know why I have to use this thing, it was in the project:

          project(xclm)
          cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
          
          set(CMAKE_CXX_STANDARD 11)
          set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
          set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
          set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
          
          # add single headers to project structure
          FILE(GLOB_RECURSE HeaderFiles "*.h")
          add_custom_target(headers SOURCES ${HeaderFiles})
          
          include_directories(.)
          
          find_package(Boost 1.57.0 COMPONENTS system program_options filesystem REQUIRED)
          
          if(Boost_FOUND)
              find_program(iwyu_path NAMES include-what-you-use iwyu)
              if(NOT iwyu_path)
                message(FATAL_ERROR "Could not find the program include-what-you-use")
              endif()
          
              set(iwyu_path_and_options ${iwyu_path} -Xiwyu --check_also)
          
              aux_source_directory(. SRC_LIST)
              aux_source_directory(hashes SRC_LIST)
              aux_source_directory(runner SRC_LIST)
              aux_source_directory(version SRC_LIST)
              add_executable(${PROJECT_NAME} ${SRC_LIST})
              target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
              set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
          else()
              message(FATAL_ERROR "boost library not found.")
          endif()
          

          Be indulgent, I'm very newbie to QT...
          Thanks a lot for your comprehsion

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

          If you don't need include-what-you-use then remove it from your CMakeLists.txt. Nothing Qt specific.

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

          P 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            If you don't need include-what-you-use then remove it from your CMakeLists.txt. Nothing Qt specific.

            P Offline
            P Offline
            Pascal06
            wrote on last edited by
            #5

            @Christian-Ehrlicher
            Hello,
            indeed, I commented lines related to iwyu in CMakeList and now it compile.
            Sorry my question was stupid.
            Thanks a lot for your help.

            Pascal

            1 Reply Last reply
            0
            • P Pascal06 has marked this topic as solved on

            • Login

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