Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

add_custom_target cannot create target "aab" because another target with the same name already exists.



  • Hi,

    QtCreator cannot parse a complex solution using CMakeLists for Android.
    This solution should create one executable file and one library, so file hierarchy looks like:

    <ROOT_DIR>
    <exec_DIR>
    <lib_DIR>

    Root CMakeLists:

    cmake_minimum_required(VERSION 3.5)
    
    project(nienazwany3 LANGUAGES CXX)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    add_subdirectory(./src1)
    add_subdirectory(./src2)
    

    CMakeLists of executable file:

    cmake_minimum_required(VERSION 3.5)
    project(src1 LANGUAGES CXX)
    
    find_package(Qt5 COMPONENTS Core Quick REQUIRED)
    
    if(ANDROID)
        add_library(${PROJECT_NAME} SHARED
          src.cpp
        )
    else()
        add_executable(${PROJECT_NAME}
          src.cpp
        )
    endif()
    
    target_compile_definitions(${PROJECT_NAME}
      PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(${PROJECT_NAME}
      PRIVATE Qt5::Core Qt5::Quick)
    

    CMakeLists of library file:

    cmake_minimum_required(VERSION 3.5)
    project(src2 LANGUAGES CXX)
    
    find_package(Qt5 COMPONENTS Core Quick REQUIRED)
    
    add_library(${PROJECT_NAME}
      src.cpp
    )
    
    target_compile_definitions(${PROJECT_NAME}
      PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(${PROJECT_NAME}
      PRIVATE Qt5::Core Qt5::Quick)
    

    QtCreator: 4.12.4
    Qt: 5.15.0

    Example project: https://gofile.io/d/GQG1tL

    This example contains wrong source files - I just want QtCreator to parse this project, not compile it.
    Any idea?


Log in to reply