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

target_link_libraries does not work with a target name on iOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.5, 6.3.1, 6.4.0 Beta1
    • 6.0.1, 6.1.0 RC, 6.2.3, 6.3.0
    • Build System: CMake
    • None
    • MacOS to iOS compilation using Qt Creator or cmake on command line
    • iOS/tvOS/watchOS
    • c0188b2dbd (qt/qtbase/dev) c0188b2dbd (qt/tqtc-qtbase/dev) b5254073fd (qt/qtbase/6.3) b5254073fd (qt/tqtc-qtbase/6.3) b5254073fd (qt/qtbase/6.3.1)

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes