Skip to content

Commit

Permalink
CMake: added option OSX_INSTALL_FRAMEWORKSDIR (default /Library/Frame…
Browse files Browse the repository at this point in the history
…works) to specify custom install path. rpath of tools is corrected to reference the library relative to the binary's location.

Signed-off-by: Matej Kenda <[email protected]>
  • Loading branch information
matejk committed Sep 17, 2019
1 parent c0012d0 commit c3bed86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
option(OSX_PACKAGE "Create a OSX package" ON)

set(OSX_INSTALL_FRAMEWORKSDIR "/Library/Frameworks" CACHE STRING "Installation directory for frameworks")
get_filename_component(OSX_INSTALL_FRAMEWORKSDIR "${OSX_INSTALL_FRAMEWORKSDIR}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")

set(CMAKE_MACOSX_RPATH ON)
set(SKIP_INSTALL_ALL ${OSX_PACKAGE})
endif()
Expand Down Expand Up @@ -348,7 +352,7 @@ if(NOT SKIP_INSTALL_ALL)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION /Library/Frameworks
FRAMEWORK DESTINATION ${OSX_INSTALL_FRAMEWORKSDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

Expand Down Expand Up @@ -415,7 +419,7 @@ if(OSX_PACKAGE)
COMMAND ${PKGBUILD_EXECUTABLE}
--component ${LIBIIO_FRAMEWORK_DIR}
--identifier com.adi.iio --version ${VERSION}
--install-location /Library/Frameworks ${LIBIIO_TEMP_PKG}
--install-location ${OSX_INSTALL_FRAMEWORKSDIR} ${LIBIIO_TEMP_PKG}
COMMAND ${PRODUCTBUILD_EXECUTABLE}
--distribution ${LIBIIO_DISTRIBUTION_XML} ${LIBIIO_PKG}
COMMAND ${CMAKE_COMMAND} -E remove ${LIBIIO_TEMP_PKG}
Expand Down
8 changes: 7 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ project(iio_attr C)
project(iio_readdev C)
project(iio_reg C)

if(APPLE)
# Add relative rpath to iio library (which is in the same framework)
set(CMAKE_INSTALL_RPATH "@executable_path/../..")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()

if (MSVC)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../deps/wingetopt/src)
set(GETOPT_C_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../deps/wingetopt/src/getopt.c)
Expand Down Expand Up @@ -50,7 +56,7 @@ set_target_properties(${IIO_TESTS_TARGETS} PROPERTIES

if(NOT SKIP_INSTALL_ALL)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
install(TARGETS ${IIO_TESTS_TARGETS} RUNTIME DESTINATION /Library/Frameworks/iio.framework/Tools)
install(TARGETS ${IIO_TESTS_TARGETS} RUNTIME DESTINATION ${OSX_INSTALL_FRAMEWORKSDIR}/iio.framework/Tools)
else()
install(TARGETS ${IIO_TESTS_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
Expand Down

0 comments on commit c3bed86

Please sign in to comment.