Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMS dependencies are now linked in as private #42

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ endif() # WITH_REDIS
if (WITH_HDF5)
find_package(HDF5 NAMES hdf5 COMPONENTS C shared REQUIRED NO_DEFAULT_PATH PATHS ${HDF5_Dir} ${HDF5_Dir}/share/cmake)
list(APPEND AMS_APP_INCLUDES ${HDF5_INCLUDE_DIR})
list(APPEND AMS_APP_LIBRARIES ${HDF5_C_SHARED_LIBRARY})
list(APPEND AMS_APP_LIBRARIES ${HDF5_LIBRARIES})
list(APPEND AMS_APP_DEFINES "-D__ENABLE_HDF5__")
message(STATUS "HDF5 Shared Library: ${HDF5_C_SHARED_LIBRARY}")
message(STATUS "HDF5 Shared Library: ${HDF5_LIBRARIES}")
message(STATUS "HDF5 Include directories: ${HDF5_INCLUDE_DIR}")
endif() # WITH_HDF5

Expand Down Expand Up @@ -182,12 +182,16 @@ if (WITH_TORCH)
find_package(Torch REQUIRED)
# This is annoying, torch populates all my cuda flags
# and resets them
set(CMAKE_CUDA_FLAGS "")
#set(CMAKE_CUDA_FLAGS "")
set(CMAKE_CUDA_ARCHITECTURES ON)

list(APPEND AMS_APP_INCLUDES "${TORCH_INCLUDE_DIRS}")
list(APPEND AMS_APP_LIBRARIES "${TORCH_LIBRARIES}")

# This is inspired by this thread here: https://discuss.pytorch.org/t/libtorch-cmake-build-tutorial/134898
# It picks manually all *.so files. In our case, we "trust" FindPackage to find the right libraries
# but it does not export where this libraries are. From looking into 2 systems, libtorch is never an absolute
# path. We can work around this by explicitly appending "TORCH_INSTALL_PREFIX/lib" and "TORCH_INSTALL_PREFIX/lib64".
# I am currently ommitting this change in favor of PRIVATE linkage. We will see how this work.
list(APPEND AMS_APP_DEFINES "-D__ENABLE_TORCH__")
endif()

Expand Down
8 changes: 5 additions & 3 deletions src/AMSlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ target_include_directories(AMS PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>
$<INSTALL_INTERFACE:include/>)
target_include_directories(AMS PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_directories(AMS PUBLIC ${AMS_APP_LIB_DIRS})
target_link_libraries(AMS PUBLIC ${AMS_APP_LIBRARIES} stdc++fs)
#AMS links in PRIVATELY everything that it uses. As, it only exposes AMS API, it doesn't
#expose umpire/torch/faiss API to the linked in library.
target_link_directories(AMS PRIVATE ${AMS_APP_LIB_DIRS})
target_link_libraries(AMS PRIVATE ${AMS_APP_LIBRARIES} stdc++fs)

#-------------------------------------------------------------------------------
# create the configuration header file with the respective information
Expand Down Expand Up @@ -75,7 +77,7 @@ install(TARGETS AMS
DESTINATION lib)

install(EXPORT AMSTargets
FILE AMS.cmake
FILE AMSConfig.cmake
DESTINATION lib/cmake/AMS)

install(FILES ${PROJECT_BINARY_DIR}/include/AMS.h DESTINATION include)
Expand Down
Loading