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. CMake warning : the target is mentionned as dependency but not declared
Forum Updated to NodeBB v4.3 + New Features

CMake warning : the target is mentionned as dependency but not declared

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 4 Posters 91 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.
  • A Offline
    A Offline
    ankou29666
    wrote last edited by
    #1

    Hi

    After a little refactoring of my CMakeLists.txt files in my project, I'm now facing the warning message :

    CMake Warning at /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:285 (message):
    [cmake]   The HttpServer target is mentioned as a dependency for HttpManagerLib, but
    [cmake]   not declared.  The linking might be incomplete.
    [cmake] Call Stack (most recent call first):
    [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:249 (__qt_internal_walk_libs)
    [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:337 (__qt_internal_walk_libs)
    [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:713 (__qt_internal_collect_all_target_dependencies)
    [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:818 (_qt_internal_finalize_executable)
    [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:787:EVAL:1 (qt6_finalize_target)
    [cmake]   Src/Main/CMakeLists.txt:DEFERRED
    

    I've had this issue a few days ago, but it was among my own modules, I had found a link suggesting that it was due to a missordered add_subdirectories, the depending one being built before the depended one. and indeed Placing the add_subdirectories in the right order fixed the problem.

    Now the issue occurs but between one of mine and a Qt one (Qt6::HttpServer).
    Here's Src/Application/HttpManager/CMakeLists.txt

    set (LIBNAME HttpManager)
    set (QT_LIBS Core Qml Concurrent Network HttpServer)
    set (CPP_FILES somesources.h somesources.cpp)
    
    ################################################################################
    project(${LIBNAME}Lib LANGUAGES CXX)
    
    find_package(Qt6 REQUIRED COMPONENTS ${QT_LIBS})
    
    qt_add_library(${PROJECT_NAME} STATIC ${CPP_FILES})
    qt_add_resources (${PROJECT_NAME} ...) # SSL certificate files for HTTPS server
    
    target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/Src/Entities)
    target_link_directories    (${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/Entities)
    
    foreach (module IN LISTS QT_LIBS)
        target_link_libraries(${PROJECT_NAME} PUBLIC Qt6::${module})
    endforeach()
    
    target_link_libraries(${PROJECT_NAME} PUBLIC EntitiesLib)
    

    I've checked and rechecked again in other CMakeList.txt files, and all add_subdirectory directives are called in the right build order, dependencies first, dependent libs next, then executables last.

    In Src/CMakeLists.txt

    add_subdirectory (Entities ${CMAKE_BINARY_DIR}/Entities)
    add_subdirectory (Application) # HttpManager module inside that directory, along with another plugin manager module, both depending on Entities, no dependency one to the other
    add_subdirectory (Plugins) # dynamic plugins, depends on Entities
    add_subdirectory (GlobalManager ${CMAKE_BINARY_DIR}/GlobalManager) # Depends on both modules in Application, serves as facade pattern in both main.cpp in Main and TestUI executables
    # add_subdirectory (UI) # for user interface, not implemented yet
    # add_subdirectory (TestUI ${CMAKE_BINARY_DIR}/TestUI) # QML hot reloader executable, not imported yet from another project, depends on GlobalManager
    add_subdirectory (Main ${CMAKE_BINARY_DIR}/Main) # release executable, same depends on GlobalManager
    

    Qt is my sole external dependency, no other library added

    Does anyone have any idea about what I'm doing wrong ?

    jsulmJ Paul ColbyP 2 Replies Last reply
    0
    • A ankou29666

      Hi

      After a little refactoring of my CMakeLists.txt files in my project, I'm now facing the warning message :

      CMake Warning at /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:285 (message):
      [cmake]   The HttpServer target is mentioned as a dependency for HttpManagerLib, but
      [cmake]   not declared.  The linking might be incomplete.
      [cmake] Call Stack (most recent call first):
      [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:249 (__qt_internal_walk_libs)
      [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:337 (__qt_internal_walk_libs)
      [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:713 (__qt_internal_collect_all_target_dependencies)
      [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:818 (_qt_internal_finalize_executable)
      [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:787:EVAL:1 (qt6_finalize_target)
      [cmake]   Src/Main/CMakeLists.txt:DEFERRED
      

      I've had this issue a few days ago, but it was among my own modules, I had found a link suggesting that it was due to a missordered add_subdirectories, the depending one being built before the depended one. and indeed Placing the add_subdirectories in the right order fixed the problem.

      Now the issue occurs but between one of mine and a Qt one (Qt6::HttpServer).
      Here's Src/Application/HttpManager/CMakeLists.txt

      set (LIBNAME HttpManager)
      set (QT_LIBS Core Qml Concurrent Network HttpServer)
      set (CPP_FILES somesources.h somesources.cpp)
      
      ################################################################################
      project(${LIBNAME}Lib LANGUAGES CXX)
      
      find_package(Qt6 REQUIRED COMPONENTS ${QT_LIBS})
      
      qt_add_library(${PROJECT_NAME} STATIC ${CPP_FILES})
      qt_add_resources (${PROJECT_NAME} ...) # SSL certificate files for HTTPS server
      
      target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/Src/Entities)
      target_link_directories    (${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/Entities)
      
      foreach (module IN LISTS QT_LIBS)
          target_link_libraries(${PROJECT_NAME} PUBLIC Qt6::${module})
      endforeach()
      
      target_link_libraries(${PROJECT_NAME} PUBLIC EntitiesLib)
      

      I've checked and rechecked again in other CMakeList.txt files, and all add_subdirectory directives are called in the right build order, dependencies first, dependent libs next, then executables last.

      In Src/CMakeLists.txt

      add_subdirectory (Entities ${CMAKE_BINARY_DIR}/Entities)
      add_subdirectory (Application) # HttpManager module inside that directory, along with another plugin manager module, both depending on Entities, no dependency one to the other
      add_subdirectory (Plugins) # dynamic plugins, depends on Entities
      add_subdirectory (GlobalManager ${CMAKE_BINARY_DIR}/GlobalManager) # Depends on both modules in Application, serves as facade pattern in both main.cpp in Main and TestUI executables
      # add_subdirectory (UI) # for user interface, not implemented yet
      # add_subdirectory (TestUI ${CMAKE_BINARY_DIR}/TestUI) # QML hot reloader executable, not imported yet from another project, depends on GlobalManager
      add_subdirectory (Main ${CMAKE_BINARY_DIR}/Main) # release executable, same depends on GlobalManager
      

      Qt is my sole external dependency, no other library added

      Does anyone have any idea about what I'm doing wrong ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote last edited by
      #2

      @ankou29666 How does CMakeLists.txt look like for EntitiesLib?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A ankou29666

        Hi

        After a little refactoring of my CMakeLists.txt files in my project, I'm now facing the warning message :

        CMake Warning at /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:285 (message):
        [cmake]   The HttpServer target is mentioned as a dependency for HttpManagerLib, but
        [cmake]   not declared.  The linking might be incomplete.
        [cmake] Call Stack (most recent call first):
        [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:249 (__qt_internal_walk_libs)
        [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6/QtPublicWalkLibsHelpers.cmake:337 (__qt_internal_walk_libs)
        [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:713 (__qt_internal_collect_all_target_dependencies)
        [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:818 (_qt_internal_finalize_executable)
        [cmake]   /Volumes/User/Users/yann/Qt/6.9.1/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:787:EVAL:1 (qt6_finalize_target)
        [cmake]   Src/Main/CMakeLists.txt:DEFERRED
        

        I've had this issue a few days ago, but it was among my own modules, I had found a link suggesting that it was due to a missordered add_subdirectories, the depending one being built before the depended one. and indeed Placing the add_subdirectories in the right order fixed the problem.

        Now the issue occurs but between one of mine and a Qt one (Qt6::HttpServer).
        Here's Src/Application/HttpManager/CMakeLists.txt

        set (LIBNAME HttpManager)
        set (QT_LIBS Core Qml Concurrent Network HttpServer)
        set (CPP_FILES somesources.h somesources.cpp)
        
        ################################################################################
        project(${LIBNAME}Lib LANGUAGES CXX)
        
        find_package(Qt6 REQUIRED COMPONENTS ${QT_LIBS})
        
        qt_add_library(${PROJECT_NAME} STATIC ${CPP_FILES})
        qt_add_resources (${PROJECT_NAME} ...) # SSL certificate files for HTTPS server
        
        target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/Src/Entities)
        target_link_directories    (${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/Entities)
        
        foreach (module IN LISTS QT_LIBS)
            target_link_libraries(${PROJECT_NAME} PUBLIC Qt6::${module})
        endforeach()
        
        target_link_libraries(${PROJECT_NAME} PUBLIC EntitiesLib)
        

        I've checked and rechecked again in other CMakeList.txt files, and all add_subdirectory directives are called in the right build order, dependencies first, dependent libs next, then executables last.

        In Src/CMakeLists.txt

        add_subdirectory (Entities ${CMAKE_BINARY_DIR}/Entities)
        add_subdirectory (Application) # HttpManager module inside that directory, along with another plugin manager module, both depending on Entities, no dependency one to the other
        add_subdirectory (Plugins) # dynamic plugins, depends on Entities
        add_subdirectory (GlobalManager ${CMAKE_BINARY_DIR}/GlobalManager) # Depends on both modules in Application, serves as facade pattern in both main.cpp in Main and TestUI executables
        # add_subdirectory (UI) # for user interface, not implemented yet
        # add_subdirectory (TestUI ${CMAKE_BINARY_DIR}/TestUI) # QML hot reloader executable, not imported yet from another project, depends on GlobalManager
        add_subdirectory (Main ${CMAKE_BINARY_DIR}/Main) # release executable, same depends on GlobalManager
        

        Qt is my sole external dependency, no other library added

        Does anyone have any idea about what I'm doing wrong ?

        Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote last edited by
        #3

        Hi @ankou29666,

        It's not entirely clear, but given that your CMake error call stack ends (ie starts) with:

        [cmake]   Src/Main/CMakeLists.txt:DEFERRED
        

        The issue is likely that you have not found the Qt HttpServer package in that CMakeLists.txt file.

        Although you've included Main after Application, ie:

        add_subdirectory (Application) # HttpManager module inside that directory, along with another plugin manager module, both
        ...
        add_subdirectory (Main ${CMAKE_BINARY_DIR}/Main) # release executable, same depends on GlobalManager
        

        The modules found in Application/CMakeLists.txt are (by default) scoped to that subdirectory only. Try doing a web search for "add_subdirectory scope".

        I would guess you need to either:

        1. remove the dependency from Src/Main/CMakeLists.txt; or
        2. more likely, move the find_package(Qt6 ...) to the top Src/CMakeLists.txt file, before the add_subdirectory calls.

        Cheers.

        1 Reply Last reply
        3
        • A Offline
          A Offline
          ankou29666
          wrote last edited by ankou29666
          #4

          Hi Paul and thanks for your reply.

          Yes I had completely missed the Src/Main/CMakeLists.txt Line, thank you very much for pointing it out.

          Yes indeed that was it. As I had turned some dependencies from PRIVATE to PUBLIC, I had removed that dependency from Main/CMakeLists.txt file and adding it back again fixes the problem.
          However I'm still a little surprized that, as my module HttpManager relies non only on Qt's HttpServer, but also on Concurrent and Network, the warning is gone only if I add back HttpServer, without adding back Concurrent and Network.
          So even though topic is solved, I still would like to add one more question : as Qt::HttpServer module depends on classes defined Qt::Network module (QTcpServer, as as QHttpServer depends on QTcpServer), and also likely QFuture in Qt::Concurrent module, I guess that importing Qt::HttpServer module also brings Qt::Concurrent and Qt::Network as implicit dependencies, that don't need to be declared explicitly ?

          @Paul-Colby said in CMake warning : the target is mentionned as dependency but not declared:

          more likely, move the find_package(Qt6 ...) to the top Src/CMakeLists.txt file, before the add_subdirectory calls.

          Yeah I currently have a find_package statement near the beginning of EVERY subfolder's CMakeLists.txt. I've been watching a few CMake videos on youtube and find one that was making the same suggestion.
          That's what I'm planning to do this afternoon.

          Christian EhrlicherC 1 Reply Last reply
          1
          • A ankou29666 has marked this topic as solved
          • A ankou29666

            Hi Paul and thanks for your reply.

            Yes I had completely missed the Src/Main/CMakeLists.txt Line, thank you very much for pointing it out.

            Yes indeed that was it. As I had turned some dependencies from PRIVATE to PUBLIC, I had removed that dependency from Main/CMakeLists.txt file and adding it back again fixes the problem.
            However I'm still a little surprized that, as my module HttpManager relies non only on Qt's HttpServer, but also on Concurrent and Network, the warning is gone only if I add back HttpServer, without adding back Concurrent and Network.
            So even though topic is solved, I still would like to add one more question : as Qt::HttpServer module depends on classes defined Qt::Network module (QTcpServer, as as QHttpServer depends on QTcpServer), and also likely QFuture in Qt::Concurrent module, I guess that importing Qt::HttpServer module also brings Qt::Concurrent and Qt::Network as implicit dependencies, that don't need to be declared explicitly ?

            @Paul-Colby said in CMake warning : the target is mentionned as dependency but not declared:

            more likely, move the find_package(Qt6 ...) to the top Src/CMakeLists.txt file, before the add_subdirectory calls.

            Yeah I currently have a find_package statement near the beginning of EVERY subfolder's CMakeLists.txt. I've been watching a few CMake videos on youtube and find one that was making the same suggestion.
            That's what I'm planning to do this afternoon.

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

            @ankou29666 said in CMake warning : the target is mentionned as dependency but not declared:

            guess that importing Qt::HttpServer module also brings Qt::Concurrent and Qt::Network as implicit dependencies, that don't need to be declared explicitly ?

            correct, that's why you have to use PRIVATE, PUBLIC and INTERFACE in your target_link_libraries() call: https://cmake.org/cmake/help/latest/command/target_link_libraries.html#libraries-for-a-target-and-or-its-dependents

            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
            1

            • Login

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