Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created May 30, 2013 14:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/5678281 to your computer and use it in GitHub Desktop.
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
# 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