0

I'm using MSVC 2022 on windows, with ninja as a build generator and cmake 3.31.8.

Here is the error output when running 'ninja package' when it gets to the fixup_bundle section:

CPack: - Install project: MYAPP[]
Installing dependencies of myapplication.       
warning: target 'mylibrary.dll' is not absolute...
CMake Error at C:/Users/ContainerUser/scoop/apps/cmake/3.31.8/share/cmake-3.31/Modules/GetPrerequisites.cmake:663 (file):
  file failed to open for reading (No such file or directory):

    /mylibrary.dll
Call Stack (most recent call first):
  C:/Users/ContainerUser/scoop/apps/cmake/3.31.8/share/cmake-3.31/Modules/GetPrerequisites.cmake:975 (get_prerequisites)
  C:/Users/ContainerUser/scoop/apps/cmake/3.31.8/share/cmake-3.31/Modules/BundleUtilities.cmake:647 (get_prerequisites)
  C:/Users/ContainerUser/scoop/apps/cmake/3.31.8/share/cmake-3.31/Modules/BundleUtilities.cmake:933 (get_bundle_keys)

There's nothing really special about how this DLL is built, and its not the only DLL in the project. I tried renaming it, removing OUTPUT_NAME, getting rid of VERSION & SOVERSION but none of these had any impact.

ADD_LIBRARY(mylibrary_shared SHARED ${BASE_SOURCES} ${DOC_SOURCES} ${HEADER_FILES})
TARGET_LINK_LIBRARIES(mylibrary_shared ${MY_LIB_DEPENDS})

SET_TARGET_PROPERTIES(mylibrary_shared PROPERTIES
        VERSION "${mylibrary_LIBVERSION}"
        SOVERSION "${mylibrary_SOVERSION}"
        CLEAN_DIRECT_OUTPUT 1
        OUTPUT_NAME "mylibrary"
        COMPILE_FLAGS "-DBUILDING_MYLIBRARY"
        )

Here is my BundleUtilities code:

SET(APPS "\${CMAKE_INSTALL_PREFIX}/myapplication.exe")
INSTALL(CODE "
    message(\"Installing dependencies of myapplication.\")
    file(GLOB_RECURSE MYPLUGINS
      \"\${CMAKE_INSTALL_PREFIX}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    include(BundleUtilities)
    fixup_bundle(\"${APPS}\" \"\${MYPLUGINS}\" \"${MY_BIN_DIR}\")
    verify_app(${APPS})
    "
    COMPONENT controller)

For some more context, this code works 100% fine when using msbuild. I'm trying to switch to the ninja generator and got this error. I'm at a loss for how to even debug it. I can't seem to get any diagnostic output from cmake's GetPrerequisites.cmake and I'm not sure how to determine why the path might be blank. Any assistance in this regard is appreciated.

I also tried this with the latest cmake version 4.0.3 and this didn't fix it.

1 Answer 1

0

I was able to fix it by adding an extra path to ${MY_BIN_DIR} in the fixup_bundle command that includes the DLL directly. I'm not sure why it worked fine with msbuild and not with ninja, but that may just remain a mystery.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.