mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
OS X: Enable rpath support on Mac OS X when find_library() is used.
This commit is contained in:
@@ -14,6 +14,10 @@ set_target_properties(shared2 PROPERTIES
|
||||
add_library(framework SHARED framework.cpp framework.h)
|
||||
set_target_properties(framework PROPERTIES MACOSX_RPATH 1 FRAMEWORK 1)
|
||||
|
||||
# another framework
|
||||
add_library(framework2 SHARED framework2.cpp framework2.h)
|
||||
set_target_properties(framework2 PROPERTIES MACOSX_RPATH 1 FRAMEWORK 1)
|
||||
|
||||
# executable to test a shared library dependency with install rpaths
|
||||
add_executable(test1 test1.cpp)
|
||||
target_link_libraries(test1 shared)
|
||||
@@ -60,4 +64,5 @@ export(TARGETS shared shared2 framework FILE "${CMAKE_CURRENT_BINARY_DIR}/exp.cm
|
||||
install(TARGETS shared EXPORT MyExport DESTINATION lib)
|
||||
install(TARGETS shared2 EXPORT MyExport DESTINATION lib2)
|
||||
install(TARGETS framework EXPORT MyExport DESTINATION lib-fw)
|
||||
install(TARGETS framework2 EXPORT MyExport DESTINATION lib-fw2)
|
||||
install(EXPORT MyExport DESTINATION lib FILE exp.cmake)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
#include "framework2.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void framework2()
|
||||
{
|
||||
printf("framework 2\n");
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
#ifndef framework2_h
|
||||
#define framework2_h
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef framework2_EXPORTS
|
||||
# define FRAMEWORK2_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define FRAMEWORK2_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define FRAMEWORK2_EXPORT
|
||||
#endif
|
||||
|
||||
void FRAMEWORK2_EXPORT framework2();
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,8 @@ add_executable(testb ${MacRuntimePath_B_SOURCE_DIR}/../A/test3.cpp)
|
||||
target_link_libraries(testb shared framework)
|
||||
|
||||
# test link with rpath enabled library by filename
|
||||
target_link_libraries(testb $<TARGET_LINKER_FILE:shared2> framework)
|
||||
find_library(fw2 NAMES framework2 HINTS ${MacRuntimePath_B_BINARY_DIR}/../Root/lib-fw2)
|
||||
target_link_libraries(testb $<TARGET_LINKER_FILE:shared2> ${fw2})
|
||||
|
||||
add_custom_target(testb_run ALL
|
||||
COMMAND testb
|
||||
|
||||
Reference in New Issue
Block a user