-
Notifications
You must be signed in to change notification settings - Fork 189
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
Integrate librepa and kdpart into the build system #4474
base: python
Are you sure you want to change the base?
Conversation
0e6569b
to
4757b14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side, this should work for a local build. I'm not sure if it works when running make install
to deploy ESPResSo, since libkdpart.so
is generated from a Makefile instead of being a proper target. Not sure if we can make it a target because it's consumed by librepa
instead of ESPResSo, and it's unclear to me if librepa.so
hardcodes the libkdpart.so
runtime path or relies on the standard LD_LIBRARY_PATH
environment variable. The only way to know for sure it to write some code in ESPResSo that calls a librepa symbol that itself calls a kdpart symbol.
@RudolfWeeber could you please take a look and make sure, this PR satisfies your requirements? I was able to compile and link ESPResSo against librepa.so
and run the testsuite with this:
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 9426568be..6944df47f 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -106,4 +106,6 @@ target_link_libraries(
Boost::serialization Boost::mpi)
+target_link_libraries(espresso_core PRIVATE repa)
+target_include_directories(espresso_core PRIVATE ${librepa_SOURCE_DIR})
target_include_directories(espresso_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/src/core/integrate.cpp b/src/core/integrate.cpp
index a424f7c24..61414c13d 100644
--- a/src/core/integrate.cpp
+++ b/src/core/integrate.cpp
@@ -70,4 +70,6 @@
#include <utility>
+#include <repa/repa.hpp>
+
#ifdef VALGRIND_INSTRUMENTATION
#include <callgrind.h>
This is a follow-up to the dev-meeting discussion about name clashes when including external libraries with CMake target name clashesESPResSo CMake target names cannot clash with included libraries thanks to the use of a unique prefix: add_library(espresso_core SHARED)
add_library(espresso::core ALIAS espresso_core)
target_sources(espresso_core PRIVATE cells.cpp ...)
target_link_libraries(espresso_core PRIVATE espresso::config ...)
install(TARGETS espresso_core
LIBRARY DESTINATION ${ESPRESSO_INSTALL_PYTHON}/espressomd) Advantages:
CMake project option clashesRegarding CMake project options, to my knowledge there isn't a built-in way to namespace them. Contrary to There are several workarounds. The first one consists in defining a subset of common CMake options that can be safely inherited from a parent project, and automatically disable all other options. The MWE below is adapted from project(ESPRESSO LANGUAGES CXX)
# define common build options that are inherited from parent projects
option(WITH_COVERAGE "Enable code coverage instrumentation" OFF)
add_subdirectory(src)
# define build options specific to this project, that
# cannot be activated if this project is a subproject
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# we're in the root, define additional targets for developers.
option(ESPRESSO_WITH_TESTS "Enable tests" ON)
if(ESPRESSO_WITH_TESTS)
add_subdirectory(tests)
endif()
endif() The downside is, some project-specific options shouldn't be hidden, e.g. The second workaround consists in setting the CMake options before the if(NOT librepa_POPULATED)
FetchContent_Populate(librepa)
set(WITH_TESTS_OLD ${WITH_TESTS})
set(WITH_TESTS OFF CACHE INTERNAL "")
add_subdirectory(${librepa_SOURCE_DIR} ${librepa_BINARY_DIR})
set(WITH_TESTS ${WITH_TESTS_OLD} CACHE BOOL "Enable tests" FORCE)
endif() The third method consists in manually prefixing all CMake options with the project name, i.e. cmake .. -D ESPRESSO_WITH_HDF5=ON -D ESPRESSO_WITH_TESTS=ON This is the solution taken by the waLBerla project. This PR introduces a patch to add a prefix to all librepa CMake options that clash with ESPResSo. In my opinion, the third method is the safest and most sustainable strategy. We would need to add a prefix to our own CMake options, and convince library developers to do the same to their projects. |
Co-authored-by: Jean-Noël Grad <[email protected]>
Fixes #4429
Description of changes:
WITH_LOAD_BALANCING
librepa
andkdpart
are fetched from their repositories and a flagLOAD_BALANCING
is set, similar to the walberla integration.kdpart
is installed at configure time, since it uses Makefiles andlibrepa
tries to find it at configure timelibrepa
is only built when calling e.g.make
after configuringkdpart
andlibrepa
needed extensive patching, some of the changes could be proposed upstream