Created
May 30, 2013 14:32
-
-
Save roxlu/5678281 to your computer and use it in GitHub Desktop.
CMake: how to copy a Framework on Mac to the install directory (${roxlu_app_install_dir}) and change the @executable_path so that your application can link with it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EXPERIMENTAL: Copy frameworks from extern/lib/mac/frameworks, to the install dir and set the @executable paths | |
# frameworks from the extern/lib/mac/frameworks dir | |
# ---------------------------------------------------------------------------- | |
foreach(framework_name in ${roxlu_frameworks}) | |
set(framework_dir ${roxlu_base_dir}/extern/lib/mac/frameworks/${framework_name}.framework) | |
if(IS_DIRECTORY ${framework_dir}) | |
set(framework_dest_dir ${roxlu_app_install_dir}/lib/) | |
set(framework_file ${framework_dest_dir}${framework_name}.framework/${framework_name}) | |
get_filename_component(framework_file ${framework_file} ABSOLUTE) | |
# copy the framework to bin/lib directory and change the @executable path of the framework which will be then used to set the search path in the executable | |
file(COPY ${framework_dir} DESTINATION ${framework_dest_dir}) | |
add_custom_command(TARGET ${roxlu_app_name} PRE_LINK | |
COMMAND ${CMAKE_INSTALL_NAME_TOOL} -id "@executable_path/lib/${framework_name}.framework/Versions/Current/${framework_name}" "${framework_file}" | |
COMMENT "Changing install name" | |
) | |
# make sure that we link with this copied framework | |
find_library(fr ${framework_name} PATHS ${framework_dest_dir}) | |
roxlu_add_lib(${fr}) | |
endif() | |
endforeach() | |
# ---------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment