1
votes

currently using target_link_libraries I link with some libraries, including qt, glew and assimp 3.0

in cmake I'm calling find (which calls assimp-config) and then use returned ASSIMP_LIBRARIES variable and pass it to target_link_libraries and everything is fine except path to assimp dylib inside my .app is absolute when all other paths are relative to @executable and point into .app/Content/Frameworks/ folder so I can destribute my app.

so far I can't see where is difference that I need between glew (for example) and assimp but when I check dependies with otool -L I can see that whatever I do assimp is linking with absolute path and my application can't find this dylib inside Frameworks

how to ensure that linking path of my application with that library will be relative in app bundle?

1

1 Answers

3
votes

Use a POST_BUILD custom command to fix the dependent shared library install name with the install_name_tool command line tool, e.g.:

add_custom_command (TARGET myAppExecutable
    POST_BUILD COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
        "-change" "/usr/local/lib/libassimp.dylib" "@executable_path/../Frameworks/libassimp.dylib"
    "$<TARGET_FILE:myAppExecutable>" VERBATIM)