Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93268

target_link_libraries does not work with a target name on iOS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.0.1, 6.1.0 RC, 6.2.3, 6.3.0
    • Fix Version/s: None
    • Component/s: Build System: CMake
    • Labels:
      None
    • Environment:
      MacOS to iOS compilation using Qt Creator or cmake on command line
    • Platform/s:
      iOS/tvOS/watchOS

      Description

       

      Doing this in CMakeLists.txt

      add_library(untitled4 ${PROJECT_SOURCES})
      [...]
      qt_add_executable(untitled4Standalone [...])
      [...]
      target_link_libraries(untitled4Standalone PRIVATE untitled4)

      Fails with

       

      clang: error: no such file or directory: '/Users/tomana/build-untitled4-Qt_6_0_2_for_iOS/Debug/libuntitled4.a'

       

       

      The actual target location of untitled4 is "/Users/tomana/build-untitled4-Qt_6_0_2_for_iOS/Debug_-iphoneos_/libuntitled4.a".

      A workaround for this issue is adding the macro:

      macro(ios_fix_lib_build_folder TARGET) if(IOS AND XCODE) set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/") endif()endmacro()

      And then calling it like this:

      add_library(untitled4 ${PROJECT_SOURCES})
      ios_fix_lib_build_folder(untitled4)
      [...]
      qt_add_executable(untitled4Standalone [...])
      [...]
      target_link_libraries(untitled4Standalone PRIVATE untitled4)

       (macro taken from here: https://www.reddit.com/r/Xcode/comments/bgkez2/debugiphonesimulator_vs_debug_problems_with/)

      This happens both when deploying using Qt Creator 4.15.0 rc-1 or calling cmake from command line using `cmake -GXcode -DCMAKE_PREFIX_PATH:STRING=/Users/username/Qt/6.1.0/ios -DCMAKE_TOOLCHAIN_FILE:PATH=/Users/username/Qt/6.1.0/ios/lib/cmake/Qt6/qt.toolchain.cmake -DCMAKE_OSX_ARCHITECTURES:STRING=arm64 -DCMAKE_OSX_SYSROOT:STRING=iphoneos -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM:STRING=*** -S . -B build; cmake --build build`

      When compiling a Qt application using Qt 5.15.2 for iOS using the community toolchain  https://github.com/leetal/ios-cmake this does not happen. I've not been able to figure out how the ios-cmake project resolves this (and they do not use the macro above, I believe.)

      Should this issue be resolved in the qt ios toolchains, perhaps?

        Attachments

        1. CMakeLists.txt
          3 kB
        2. untitled4.zip
          4 kB

          Issue Links

          For Gerrit Dashboard: QTBUG-93268
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              alexandru.croitor Alexandru Croitor
              Reporter:
              tomana Tom Nœrland
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change