Satisfy nblib dependencies with updated library targets.
authorM. Eric Irrgang <mei2n@virginia.edu>
Sun, 10 Oct 2021 00:01:49 +0000 (00:01 +0000)
committerM. Eric Irrgang <mei2n@virginia.edu>
Sun, 10 Oct 2021 00:01:49 +0000 (00:01 +0000)
Fixes #2027

api/nblib/CMakeLists.txt
src/gromacs/gmxlib/CMakeLists.txt
src/gromacs/utility/CMakeLists.txt

index 5c95c8c03aff3bb160476870f4584bbc6bfb78da..ee252c0d9c61974b28ccd689215f7c0bc10f2e7e 100644 (file)
@@ -98,11 +98,20 @@ target_sources(nblib
 gmx_target_compile_options(nblib)
 
 target_link_libraries(nblib PRIVATE libgromacs)
-target_include_directories(nblib SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include)
 target_include_directories(nblib PRIVATE ${PROJECT_SOURCE_DIR}/api)
 include_directories(BEFORE ${CMAKE_SOURCE_DIR}/api)
 target_link_libraries(nblib PRIVATE common)
-# There are transitive dependencies on the legacy GROMACS headers.
+target_link_libraries(nblib PRIVATE
+                      fileio
+                      gmxlib
+                      listed_forces
+                      mdtypes
+                      mdlib
+                      topology
+                      utility)
+
+# There are transitive interface dependencies on the legacy GROMACS headers.
+# TODO(#3288): Explicitly link specific modules for public API dependencies as legacy_api is removed.
 target_link_libraries(nblib PUBLIC legacy_api)
 # TODO: Explicitly link specific modules.
 target_link_libraries(nblib PRIVATE legacy_modules)
index acb56892a68de5e5aaee21620e00a879ea6ea97d..ea579427e6d6a2ca984af82ff7100c31ad293f10 100644 (file)
@@ -43,9 +43,10 @@ file(GLOB GMXLIB_SOURCES *.cpp)
 
 set(GMXLIB_SOURCES ${GMXLIB_SOURCES} ${NONBONDED_SOURCES} PARENT_SCOPE)
 
+# TODO(#3288): Explicitly link specific modules for source dependencies when gmxlib is an OBJECT target.
 # Source files have the following private module dependencies.
 target_link_libraries(gmxlib PRIVATE
-                      #                      gmxlib
+                      #                      common
                       #                      math
                       #                      mdtypes
                       #                      tng_io
@@ -58,22 +59,8 @@ target_include_directories(gmxlib INTERFACE
 #target_link_libraries(gmxlib PUBLIC
 target_link_libraries(gmxlib INTERFACE
                       legacy_api
-                      )
-
-# TODO: when fileio is an OBJECT target
-#target_link_libraries(gmxlib PUBLIC legacy_api)
-#target_link_libraries(gmxlib PRIVATE common)
-
-# Module dependencies
-# fileio interfaces convey transitive dependence on these modules.
-#target_link_libraries(gmxlib PUBLIC
-target_link_libraries(gmxlib INTERFACE
                       utility
                       )
-# Source files have the following private module dependencies.
-#target_link_libraries(gmxlib PRIVATE tng_io)
-# TODO: Explicitly link specific modules.
-#target_link_libraries(gmxlib PRIVATE legacy_modules)
 
 if(BUILD_TESTING)
     add_subdirectory(nonbonded/tests)
index fd1a6e7d8b844513c1c519641708c159e8d566ed..0353d69da003acda7515da6affad64c5a21a1866 100644 (file)
@@ -39,30 +39,30 @@ add_library(utility INTERFACE)
 file(GLOB UTILITY_SOURCES *.cpp)
 if (GMX_GPU_CUDA)
     gmx_add_libgromacs_sources(cuda_version_information.cu)
-endif()
+endif ()
 if (GMX_GPU_SYCL)
     _gmx_add_files_to_property(SYCL_SOURCES
-        sycl_version_information.cpp
-    )
-endif()
+                               sycl_version_information.cpp
+                               )
+endif ()
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${UTILITY_SOURCES} PARENT_SCOPE)
 
-if(GMX_INSTALL_LEGACY_API)
-  install(FILES
-          baseversion.h
-          classhelpers.h
-          enumerationhelpers.h
-         fileptr.h
-         futil.h
-         flags.h
-         pleasecite.h
-          programcontext.h
-          range.h
-          smalloc.h
-         stringutil.h
-          unique_cptr.h
-          DESTINATION include/gromacs/utility)
-endif()
+if (GMX_INSTALL_LEGACY_API)
+    install(FILES
+            baseversion.h
+            classhelpers.h
+            enumerationhelpers.h
+            fileptr.h
+            futil.h
+            flags.h
+            pleasecite.h
+            programcontext.h
+            range.h
+            smalloc.h
+            stringutil.h
+            unique_cptr.h
+            DESTINATION include/gromacs/utility)
+endif ()
 
 # Public interface for modules, including dependencies and interfaces
 #target_include_directories(utility PUBLIC
@@ -72,15 +72,21 @@ target_include_directories(utility INTERFACE
 target_link_libraries(utility INTERFACE
                       legacy_api
                       )
+if (GMX_LIB_MPI)
+    target_link_libraries(utility INTERFACE MPI::MPI_CXX)
+else ()
+    target_include_directories(
+        utility INTERFACE
+        $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/external/thread_mpi/include>
+    )
+endif ()
 
-# TODO: when utility is an OBJECT target
-#target_link_libraries(utility PUBLIC legacy_api)
-#target_link_libraries(utility PRIVATE common)
-
+# TODO(#3288): when utility is an OBJECT target, explicitly link source dependencies.
 # Source files have the following private module dependencies.
-# TODO: Explicitly link specific modules.
+#target_link_libraries(utility PRIVATE common)
+# TODO(#3288): Explicitly link specific modules as legacy_modules is removed.
 #target_link_libraries(utility PRIVATE legacy_modules)
 
 if (BUILD_TESTING)
     add_subdirectory(tests)
-endif()
+endif ()