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

Rework Dependency Management #150

Open
JonasGilg opened this issue Apr 28, 2020 · 3 comments
Open

Rework Dependency Management #150

JonasGilg opened this issue Apr 28, 2020 · 3 comments
Labels
discussion needed Further information is requested new feature A feature request or a general improvement idea refactoring This is mainly about code restructuring

Comments

@JonasGilg
Copy link
Member

Do you think we can add dependencies of plugins that are only required by that plugin differently?
The first thing coming to my mind is using CMake's exernal projects feature: https://cmake.org/cmake/help/latest/module/ExternalProject.html

This is a difficult question. With dependencies such as civetweb which can be build easily and do not drag in other things, I am quite happy to treat it like it's done now. This is especially true once we put the core plugins into the main repository. And it can happen that we use the library in other plugins in the future - curl, curlpp and cares were only required by the csp-lod-bodies plugin when we introduced it and now they are required by multiple plugins and cs-utils.

However there are more complicated dependencies (like VTK in the scivis branch). The best solution would be along these lines:

  • Get rid of make_externals.sh and make_externals.bat
  • In the main CMakeLists.txt we would call ExternalProject_Add for each core dependency.
  • Each plugin would call ExternalProject_Add for all additional dependencies. This however can lead to multiple calls to ExternalProject_Add for the same dependency. This would need to be resolved, especially if multiple plugins request different versions of the same dependency.
  • It also has to work for external dependencies which do not use CMake

What do you think? Would this be possible? But it's definitely not in the scope of this pull request...

Moved here from #149

@JonasGilg JonasGilg added new feature A feature request or a general improvement idea discussion needed Further information is requested refactoring This is mainly about code restructuring labels Apr 28, 2020
@JonasGilg
Copy link
Member Author

JonasGilg commented Apr 28, 2020

I never worked with ExternalProject_Add before. I know that it can handle make as a build system aswell and you can specify custom build commands if no default works.

I think this needs a lot of investigating, but could result in a much simpler project setup. Especially with the internal branches.

It may also make it easier to integrate other toolchains like MinGW or Cygwin, since they probably can't work with either the make_externals.bat/.sh

@JonasGilg
Copy link
Member Author

JonasGilg commented Apr 29, 2020

Alright, I tried to convert one of my other projects to make use of the ExternalProject feature and encountered a problem. ExternalProject_Add gets executed at build time, so the cmake project can't be configured correctly since the dependencies aren't build yet.

There exists some strategies to circumvent this limitation, but this needs more investigating, for which I don't have the time right now.

Edit: But my current feeling is that dependency management with CMake is not going to happen. And we should look into other ways of adding dependencies for plugins.

@bernstein
Copy link
Contributor

You can try FetchContent . I use it to fetch and build bullet for one of my cosmocout plugins.

Here is a snippet from the CMakeLists.txt.

include(FetchContent)

FetchContent_Declare(
  bullet
  GIT_REPOSITORY https://github.com/bulletphysics/bullet3.git
  GIT_TAG        2.89
  GIT_PROGRESS   TRUE
  GIT_SHALLOW    TRUE
  USES_TERMINAL_DOWNLOAD TRUE
  FETCHCONTENT_QUIET OFF
  # This doesn't overwrite USE_DOUBLE_PRECISION, why ???
  #   CMAKE_CACHE_ARGS -DUSE_DOUBLE_PRECISION:BOOL=TRUE
  # explained here http://cmake.3232098.n2.nabble.com/Passing-CMake-Arguments-to-FetchContent-td7599242.html
  # i have to use set with INTERNAL, see below
)

FetchContent_GetProperties(bullet)
#FetchContent_MakeAvailable(bullet)
if(NOT bullet_POPULATED)
  message(STATUS "Populating bullet, please wait...")

  #http://cmake.3232098.n2.nabble.com/Passing-CMake-Arguments-to-FetchContent-td7599242.html
  set(USE_DOUBLE_PRECISION ON CACHE INTERNAL "" FORCE)
  set(BUILD_UNIT_TESTS OFF CACHE INTERNAL "" FORCE)
  set(BUILD_CPU_DEMOS OFF CACHE INTERNAL "" FORCE)
  set(BUILD_BULLET2_DEMOS OFF CACHE INTERNAL "" FORCE)

  if (WIN32)
    set(USE_MSVC_RUNTIME_LIBRARY_DLL YES CACHE INTERNAL "" FORCE)
    set(INSTALL_LIBS YES CACHE INTERNAL "" FORCE)
    set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
  else()
    set(BUILD_SHARED_LIBS ON CACHE INTERNAL "" FORCE)
  endif()

  FetchContent_Populate(bullet)
  message(STATUS "finished building bullet")
  add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR})
endif()

set(BULLET_INCLUDE_DIRS "${bullet_SOURCE_DIR}/src")

If your dependency is a well written cmake project, then you can use a combination of FetchContent_Declare and FetchContent_MakeAvailable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needed Further information is requested new feature A feature request or a general improvement idea refactoring This is mainly about code restructuring
Projects
None yet
Development

No branches or pull requests

2 participants