Skip to content

Commit 067f827

Browse files
committed
MacOS: embed Rpath into executables
1 parent afb711c commit 067f827

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

.github/workflows/ci_macos.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ jobs:
106106
- run: ctest --test-dir build --preset default
107107
- run: cmake --install build
108108

109+
- run: cmake -S Examples -B Examples/build -Dh5fortran_ROOT=~
110+
- run: cmake --build Examples/build
111+
- run: ctest --test-dir Examples/build -V
112+
109113

110114
mac-build-shared:
111115
needs: [mac-shared, mac-build-static]
@@ -119,3 +123,7 @@ jobs:
119123
- run: cmake --build build
120124
- run: ctest --test-dir build --preset default
121125
- run: cmake --install build
126+
127+
- run: cmake -S Examples -B Examples/build -Dh5fortran_ROOT=~
128+
- run: cmake --build Examples/build
129+
- run: ctest --test-dir Examples/build -V

cmake/build_hdf5.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ include(ExternalProject)
66

77
set(hdf5_external true CACHE BOOL "autobuild HDF5")
88

9-
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
10-
# MacOS:shared: HDF5 package is mistaken RPATH otherwise
11-
129
if(hdf5_parallel)
1310
find_package(MPI REQUIRED COMPONENTS C)
1411
endif()

cmake/dll_path.cmake

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
set(DLL_PATH)
55

6+
if(NOT (MSVC OR BUILD_SHARED_LIBS))
7+
return()
8+
endif()
9+
610
if(MSVC OR (MINGW AND BUILD_SHARED_LIBS))
711

812
if(hdf5_external)
@@ -26,16 +30,8 @@ if(MSVC OR (MINGW AND BUILD_SHARED_LIBS))
2630

2731
# this is the vital line, without it CMake set_tests_properties mangles the ENVIRONMENT
2832
string(REPLACE ";" "\\;" DLL_PATH "${DLL_PATH}")
29-
elseif(APPLE AND BUILD_SHARED_LIBS)
30-
31-
if(hdf5_external)
32-
set(DLL_PATH "${ZLIB_ROOT}/lib:$ENV{DYLD_FALLBACK_LIBRARY_PATH}")
33-
endif()
34-
35-
elseif(UNIX AND BUILD_SHARED_LIBS)
36-
37-
if(hdf5_external)
38-
set(DLL_PATH "${ZLIB_ROOT}/lib:$ENV{LD_LIBRARY_PATH}")
39-
endif()
40-
33+
elseif(APPLE AND hdf5_external)
34+
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
35+
elseif(UNIX AND hdf5_external)
36+
set(DLL_PATH "${ZLIB_ROOT}/lib:$ENV{LD_LIBRARY_PATH}")
4137
endif()

src/tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if(DLL_PATH)
1515
set_tests_properties(h5fortran:minimal PROPERTIES ENVIRONMENT "Path=${DLL_PATH}")
1616
# set_tests_properties(h5fortran:minimal PROPERTIES ENVIRONMENT_MODIFICATION "Path=path_list_prepend:${DLL_PATH}")
1717
elseif(APPLE)
18-
set_tests_properties(h5fortran:minimal PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${DLL_PATH}")
18+
1919
elseif(UNIX)
2020
set_tests_properties(h5fortran:minimal PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${DLL_PATH}")
2121
endif()
@@ -45,7 +45,7 @@ if(DLL_PATH)
4545
set_tests_properties(h5fortran:${name} PROPERTIES ENVIRONMENT "Path=${DLL_PATH}")
4646
# set_tests_properties(h5fortran:${name} PROPERTIES ENVIRONMENT_MODIFICATION "Path=path_list_prepend:${DLL_PATH}")
4747
elseif(APPLE)
48-
set_tests_properties(h5fortran:${name} PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${DLL_PATH}")
48+
4949
elseif(UNIX)
5050
set_tests_properties(h5fortran:minimal PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${DLL_PATH}")
5151
endif()

0 commit comments

Comments
 (0)