Skip to content

Commit bf19cdb

Browse files
Merge pull request #46 from lanl/dempsey/cmake_mac
Fix rebound on mac
2 parents 4a4f0f3 + 7caffff commit bf19cdb

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ if(ARTEMIS_ENABLE_ASAN)
119119
add_link_options(-fsanitize=address -fsanitize=undefined)
120120
endif()
121121

122+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
123+
# silence sprintf warnings on mac
124+
add_compile_options(-Wno-deprecated-declarations)
125+
endif()
126+
122127
# NOTE(@jonahm): For some reason, order still matters for including
123128
# parthenon and singularity. Likely has to do with project
124129
# includes other than Kokkos. MPI and OpenMP likely culprits.

src/CMakeLists.txt

+11-4
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,15 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
144144
message(STATUS "Standalone mode. Adding artemis executable")
145145
add_executable(artemis main.cpp)
146146
target_link_libraries(artemis PRIVATE artemislib)
147-
add_custom_command(TARGET artemis POST_BUILD
148-
COMMAND ${CMAKE_COMMAND} -E copy
149-
${CMAKE_BINARY_DIR}/rebound/librebound.so
150-
$<TARGET_FILE_DIR:artemis>)
147+
148+
# Bake in rpath to rebound on mac
149+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
150+
set_target_properties(artemis PROPERTIES
151+
BUILD_RPATH "${CMAKE_BINARY_DIR}/rebound"
152+
)
153+
add_custom_command(TARGET artemis POST_BUILD
154+
COMMAND install_name_tool -add_rpath @executable_path/../rebound $<TARGET_FILE:artemis>
155+
COMMAND install_name_tool -change librebound.so @rpath/librebound.so $<TARGET_FILE:artemis>
156+
)
157+
endif()
151158
endif()

tst/run_tests.py

-16
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ def main(**kwargs):
157157

158158
# Build working directory and copy librebound.so into working directory
159159
os.makedirs(artemis.get_outputs_dir(), exist_ok=True)
160-
reb_path = os.path.join(artemis.get_exe_dir(), "librebound.so")
161-
if not os.path.exists(reb_path):
162-
raise TestError(f'librebound.so not found at "{reb_path}"!')
163-
shutil.copy(reb_path, artemis.get_outputs_dir())
164160

165161
# Run each test
166162
for name in test_names:
@@ -294,17 +290,13 @@ def set_globals(args):
294290
if exe_path is not None:
295291
adir = os.path.join(artemis.get_artemis_dir(), "tst")
296292
out_dir = os.path.join(adir, "testing") if out_dir is None else out_dir
297-
reb_path = os.path.join(os.path.dirname(exe_path), "librebound.so")
298293

299294
if use_cwd:
300295
raise TestError("--cwd and --exe=PATH cannot be passed together!")
301296

302297
if not (os.path.exists(exe_path) and os.access(exe_path, os.X_OK)):
303298
raise TestError(f'Provided exe "{exe_path}" not found or cannot be run!')
304299

305-
if not os.path.exists(reb_path):
306-
raise TestError(f'librebound.so not found at "{reb_path}"!')
307-
308300
abs_out_dir = os.path.abspath(out_dir)
309301
abs_exe_dir = os.path.abspath(os.path.dirname(exe_path))
310302
artemis.set_paths(abs_exe_dir, abs_out_dir)
@@ -318,10 +310,6 @@ def set_globals(args):
318310
if os.path.isfile(lpath_exe) and os.access(lpath_exe, os.X_OK):
319311
exe_path = lpath_exe
320312
out_dir = os.path.join(cwd, "testing") if out_dir is None else out_dir
321-
reb_path = os.path.join(os.path.dirname(exe_path), "librebound.so")
322-
323-
if not os.path.exists(reb_path):
324-
raise TestError(f'librebound.so not found at "{reb_path}"!')
325313

326314
abs_out_dir = os.path.abspath(out_dir)
327315
abs_exe_dir = os.path.abspath(os.path.dirname(exe_path))
@@ -331,14 +319,10 @@ def set_globals(args):
331319
# Check if we are one level up from the executable
332320
exe_path = read_cmakecache(lpath_cache)
333321
out_dir = os.path.join(cwd, "testing") if out_dir is None else out_dir
334-
reb_path = os.path.join(os.path.dirname(exe_path), "librebound.so")
335322

336323
if not (os.path.exists(exe_path) and os.access(exe_path, os.X_OK)):
337324
raise TestError(f'No exe in "{exe_path}" or cannot be run!')
338325

339-
if not os.path.exists(reb_path):
340-
raise TestError(f'librebound.so not found at "{reb_path}"!')
341-
342326
abs_out_dir = os.path.abspath(out_dir)
343327
abs_exe_dir = os.path.abspath(os.path.dirname(exe_path))
344328
artemis.set_paths(abs_exe_dir, abs_out_dir)

0 commit comments

Comments
 (0)