Skip to content

Commit

Permalink
Merge pull request #46 from lanl/dempsey/cmake_mac
Browse files Browse the repository at this point in the history
Fix rebound on mac
  • Loading branch information
adamdempsey90 authored Jan 22, 2025
2 parents 4a4f0f3 + 7caffff commit bf19cdb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ if(ARTEMIS_ENABLE_ASAN)
add_link_options(-fsanitize=address -fsanitize=undefined)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
# silence sprintf warnings on mac
add_compile_options(-Wno-deprecated-declarations)
endif()

# NOTE(@jonahm): For some reason, order still matters for including
# parthenon and singularity. Likely has to do with project
# includes other than Kokkos. MPI and OpenMP likely culprits.
Expand Down
15 changes: 11 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,15 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
message(STATUS "Standalone mode. Adding artemis executable")
add_executable(artemis main.cpp)
target_link_libraries(artemis PRIVATE artemislib)
add_custom_command(TARGET artemis POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/rebound/librebound.so
$<TARGET_FILE_DIR:artemis>)

# Bake in rpath to rebound on mac
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set_target_properties(artemis PROPERTIES
BUILD_RPATH "${CMAKE_BINARY_DIR}/rebound"
)
add_custom_command(TARGET artemis POST_BUILD
COMMAND install_name_tool -add_rpath @executable_path/../rebound $<TARGET_FILE:artemis>
COMMAND install_name_tool -change librebound.so @rpath/librebound.so $<TARGET_FILE:artemis>
)
endif()
endif()
16 changes: 0 additions & 16 deletions tst/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ def main(**kwargs):

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

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

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

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

if not os.path.exists(reb_path):
raise TestError(f'librebound.so not found at "{reb_path}"!')

abs_out_dir = os.path.abspath(out_dir)
abs_exe_dir = os.path.abspath(os.path.dirname(exe_path))
artemis.set_paths(abs_exe_dir, abs_out_dir)
Expand All @@ -318,10 +310,6 @@ def set_globals(args):
if os.path.isfile(lpath_exe) and os.access(lpath_exe, os.X_OK):
exe_path = lpath_exe
out_dir = os.path.join(cwd, "testing") if out_dir is None else out_dir
reb_path = os.path.join(os.path.dirname(exe_path), "librebound.so")

if not os.path.exists(reb_path):
raise TestError(f'librebound.so not found at "{reb_path}"!')

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

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

if not os.path.exists(reb_path):
raise TestError(f'librebound.so not found at "{reb_path}"!')

abs_out_dir = os.path.abspath(out_dir)
abs_exe_dir = os.path.abspath(os.path.dirname(exe_path))
artemis.set_paths(abs_exe_dir, abs_out_dir)
Expand Down

0 comments on commit bf19cdb

Please sign in to comment.