diff --git a/CMakeLists.txt b/CMakeLists.txt index 7891073b..4e7bd02b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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() diff --git a/src/AMSlib/CMakeLists.txt b/src/AMSlib/CMakeLists.txt index ecf1d7c5..9758a92f 100644 --- a/src/AMSlib/CMakeLists.txt +++ b/src/AMSlib/CMakeLists.txt @@ -41,8 +41,10 @@ target_include_directories(AMS PUBLIC $ $) 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 @@ -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)