diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f34d46..21d1f7c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,20 @@ endif() set(CMAKE_CXX_STANDARD 11) +# Apple crosscompiling rpath patch +macro(apple_rpath_patch _T) + if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH) + foreach(_RP ${CMAKE_INSTALL_RPATH}) + add_custom_command(TARGET ${_T} POST_BUILD + COMMAND "${CMAKE_INSTALL_NAME_TOOL}" + "-add_rpath" "${_RP}" + "$/$" + COMMENT "Add to ${_T} rpath \"${_RP}\"") + endforeach() + endif() +endmacro() + + # Basic macro(gather_src DIR CPP H H_P) set(CS) @@ -600,6 +614,10 @@ else() endif() endif() +foreach(_T ${PIP_LIBS_TARGETS}) + apple_rpath_patch(${_T}) +endforeach() + if(NOT PIP_FREERTOS) # Auxiliary @@ -639,20 +657,6 @@ if(NOT PIP_FREERTOS) endforeach() endif() - -# Apple crosscompiling rpath patch -if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH) - foreach(_T ${PIP_LIBS_TARGETS}) - foreach(_RP ${CMAKE_INSTALL_RPATH}) - add_custom_command(TARGET ${_T} POST_BUILD - COMMAND "${CMAKE_INSTALL_NAME_TOOL}" - "-add_rpath" "${_RP}" - "$/$" - COMMENT "Add to ${_T} rpath \"${_RP}\"") - endforeach() - endforeach() -endif() - # # Build Documentation # diff --git a/utils/cloud_dispatcher/CMakeLists.txt b/utils/cloud_dispatcher/CMakeLists.txt index 80d86378..e96353c9 100644 --- a/utils/cloud_dispatcher/CMakeLists.txt +++ b/utils/cloud_dispatcher/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB CPPS "*.cpp") file(GLOB HDRS "*.h") add_executable(picloud ${CPPS} ${HDRS}) target_link_libraries(picloud pip pip_cloud) +apple_rpath_patch(picloud) if (DEFINED LIB) install(TARGETS picloud DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() diff --git a/utils/code_model_generator/CMakeLists.txt b/utils/code_model_generator/CMakeLists.txt index 4b04d1b8..e158d1ab 100755 --- a/utils/code_model_generator/CMakeLists.txt +++ b/utils/code_model_generator/CMakeLists.txt @@ -1,6 +1,7 @@ message(STATUS "Building pip_cmg") add_executable(pip_cmg "main.cpp") target_link_libraries(pip_cmg pip) +apple_rpath_patch(pip_cmg) if (DEFINED LIB) install(TARGETS pip_cmg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() diff --git a/utils/crypt_tool/CMakeLists.txt b/utils/crypt_tool/CMakeLists.txt index 302631d0..f15ca99b 100644 --- a/utils/crypt_tool/CMakeLists.txt +++ b/utils/crypt_tool/CMakeLists.txt @@ -1,6 +1,7 @@ message(STATUS "Building picrypt") add_executable(picrypt "main.cpp") target_link_libraries(picrypt pip pip_crypt) +apple_rpath_patch(picrypt) if (DEFINED LIB) install(TARGETS picrypt DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() diff --git a/utils/resources_compiler/CMakeLists.txt b/utils/resources_compiler/CMakeLists.txt index 84a014c0..459a4e86 100644 --- a/utils/resources_compiler/CMakeLists.txt +++ b/utils/resources_compiler/CMakeLists.txt @@ -4,6 +4,7 @@ file(GLOB HDRS "*.h") add_executable(pip_rc ${CPPS} ${HDRS}) set (PIRC_LIBS pip) target_link_libraries(pip_rc ${PIRC_LIBS}) +apple_rpath_patch(pip_rc) if (DEFINED LIB) install(TARGETS pip_rc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() diff --git a/utils/system_daemon/CMakeLists.txt b/utils/system_daemon/CMakeLists.txt index 1eb58c6f..2fec0291 100755 --- a/utils/system_daemon/CMakeLists.txt +++ b/utils/system_daemon/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB CPPS "*.cpp") file(GLOB HDRS "*.h") add_executable(pisd ${CPPS} ${HDRS}) target_link_libraries(pisd pip pip_crypt) +apple_rpath_patch(pisd) if (DEFINED LIB) install(TARGETS pisd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else() diff --git a/utils/system_test/CMakeLists.txt b/utils/system_test/CMakeLists.txt index fe07d4bb..175e5c00 100755 --- a/utils/system_test/CMakeLists.txt +++ b/utils/system_test/CMakeLists.txt @@ -1,6 +1,7 @@ message(STATUS "Building pip_system_test") add_executable(pip_system_test "main.cpp") target_link_libraries(pip_system_test pip) +apple_rpath_patch(pip_system_test) if (DEFINED LIB) install(TARGETS pip_system_test DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif () diff --git a/utils/udp_file_transfer/CMakeLists.txt b/utils/udp_file_transfer/CMakeLists.txt index 6333c33a..a1e63003 100644 --- a/utils/udp_file_transfer/CMakeLists.txt +++ b/utils/udp_file_transfer/CMakeLists.txt @@ -1,6 +1,7 @@ message(STATUS "Building pift") add_executable(pift "main.cpp") target_link_libraries(pift pip) +apple_rpath_patch(pift) if (DEFINED LIB) install(TARGETS pift DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) else()