Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build: Fix rpath in iOS shared libraries
When attempting to configure an iOS/ARM build with Xcode 7.2 and CMake 2.8.12, I got the following errors: CMake Error at CMakeLists.txt:560 (add_library): Attempting to use MACOSX_RPATH without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set. This could be because you are using a Mac OS X version less than 10.5 or because CMake's platform configuration is corrupt. (x 3) CMake Error at sharedlib/CMakeLists.txt:38 (add_library): Attempting to use MACOSX_RPATH without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set. This could be because you are using a Mac OS X version less than 10.5 or because CMake's platform configuration is corrupt. (x 3) Upgrading to CMake 3.x (tried 3.0 and 3.1) got rid of the errors, but the resulting shared libs still did not use @rpath as expected. Note also that CMake 3.x (at least the two versions I tested) does not automatically set the MACOSX_RPATH property as claimed. I could find nothing in the release notes for later CMake releases to indicate that either problem has been fixed. What I did find was this little nugget of code in the Darwin platform module: https://github.com/Kitware/CMake/blob/f6b93fbf3ae00a9157af2f6497bed074d585cea9/Modules/Platform/Darwin.cmake#L33-L36 This sets CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG="-Wl,-rpath," only if you are running OS X 10.5 or later. It makes no such check for iOS, perhaps because shared libraries aren't much of a thing with iOS apps. In any event, this commit simply sets CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG if it isn't set already, and that fixes all of the aforementioned problems.
- Loading branch information