Skip to content

Commit

Permalink
build: Remove bundled dependencies in favor of CMake FetchContent (#1177
Browse files Browse the repository at this point in the history
)

As discussed in the past and also already implemented for vecmem, this PR removes the bundled copies of 

- nlohmann_json
- pybind11
- dfelibs
- autodiff

and uses CMake's FetchContent to grab a copy. Also added is an option `ACTS_USE_SYSTEM_PYBIND11` to allow using an already installed copy. For nlohmann_json and autodiff this was already present, and I don't think it's necessary for dfelibs.
  • Loading branch information
paulgessinger committed Mar 21, 2022
1 parent c30bcf8 commit c9a5b53
Show file tree
Hide file tree
Showing 114 changed files with 98 additions and 57,244 deletions.
18 changes: 6 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ option(ACTS_BUILD_EXAMPLES_GEANT4 "Build Geant4-based code in the examples" OFF)
option(ACTS_BUILD_EXAMPLES_HEPMC3 "Build HepMC3-based code in the examples" OFF)
option(ACTS_BUILD_EXAMPLES_PYTHIA8 "Build Pythia8-based code in the examples" OFF)
option(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS "Build python bindings for the examples" OFF)
option(ACTS_USE_SYSTEM_PYBIND11 "Use a system installation of pybind11" OFF )
option(ACTS_BUILD_ANALYSIS_APPS "Build Analysis applications in the examples" OFF)
# test related options
option(ACTS_BUILD_BENCHMARKS "Build benchmarks" OFF)
Expand Down Expand Up @@ -193,24 +194,19 @@ endmacro()
# when a particular package is actually needed.
# plugin dependencies
if(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS)
find_package(Python COMPONENTS Interpreter Development)
if(ACTS_USE_SYSTEM_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(thirdparty/pybind11)
endif()
endif()
if(ACTS_BUILD_PLUGIN_AUTODIFF)
if(ACTS_USE_SYSTEM_AUTODIFF)
find_package(autodiff ${_acts_autodiff_version} CONFIG REQUIRED)
message(STATUS "Using system installation of autodiff")
else()
# This policy allows to set the options outside without changing autodiff's CMakeLists.txt
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(AUTODIFF_BUILD_TESTS OFF)
set(AUTODIFF_BUILD_PYTHON OFF)
set(AUTODIFF_BUILD_EXAMPLES OFF)
set(AUTODIFF_BUILD_DOCS OFF)
add_subdirectory(thirdparty/autodiff)
# Mark autodiff as system include directories so that no warnings trigger
get_target_property(_autodiff_includes autodiff INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(autodiff PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_autodiff_includes}")
message(STATUS "Using bundled autodiff")
endif()
endif()
if(ACTS_BUILD_PLUGIN_CUDA)
Expand All @@ -230,8 +226,6 @@ if(ACTS_BUILD_PLUGIN_JSON)
message(STATUS "Using system installation of nlohmann::json")
find_package(nlohmann_json ${_acts_nlohmanjson_version} REQUIRED CONFIG)
else()
message(STATUS "Using bundled nlohmann::json")
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(thirdparty/nlohmann_json)
endif()
endif()
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,5 @@ http://mozilla.org/MPL/2.0/ .

The Acts project contains copies of the following external packages:

- [dfelibs](https://gitlab.cern.ch/msmk/dfelibs) by Moritz Kiehn
licensed under the MIT license.
- [JSON for Modern C++](https://github.com/nlohmann/json) by Niels Lohmann
licensed under the MIT License.
- [autodiff](https://github.com/autodiff/autodiff/) by Allan Leal licensed
under the MIT license.
- [OpenDataDetector](https://github.com/acts-project/OpenDataDetector)
licensed under the MPLv2 license.
8 changes: 6 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ components:
- [ROOT](https://root.cern.ch) >= 6.20 for the TGeo plugin and the examples
- [Sphinx](https://www.sphinx-doc.org) >= 2.0 with [Breathe](https://breathe.readthedocs.io/en/latest/), [Exhale](https://exhale.readthedocs.io/en/latest/), and [recommonmark](https://recommonmark.readthedocs.io/en/latest/index.html) extensions for the documentation
- [SYCL](https://www.khronos.org/sycl/) for the SYCL plugin
- [Pybind11](https://github.com/pybind/pybind11) for the Python bindings of the examples

There are some additional dependencies that are automatically provided as part of
the build system.
Expand Down Expand Up @@ -244,6 +245,7 @@ components.
| ACTS_BUILD_PLUGIN_JSON | Build Json plugin |
| ACTS_BUILD_PLUGIN_LEGACY | Build legacy plugin |
| ACTS_BUILD_PLUGIN_ONNX | Build ONNX plugin |
| ACTS_SETUP_VECMEM | Setup the vecmem library targets as part of this build |
| ACTS_BUILD_PLUGIN_SYCL | Build SYCL plugin |
| ACTS_BUILD_PLUGIN_TGEO | Build TGeo plugin |
| ACTS_BUILD_FATRAS | Build FAst TRAcking Simulation package |
Expand All @@ -261,10 +263,12 @@ components.
| ACTS_LOG_FAILURE_THRESHOLD | Automatically fail when a log above the specified debug level is emitted (useful for automated tests) |
| ACTS_FORCE_ASSERTIONS | Try to force keeping `assert` even in Release builds. (useful for automated tests) |
| ACTS_PARAMETER_DEFINITIONS_HEADER | Use a different (track) parameter definitions header |
| ACTS_USE_SYSTEM_AUTODIFF | Use autodiff provided by the system instead of the bundled version |
| ACTS_USE_SYSTEM_NLOHMANN_JSON | Use nlohmann::json provided by the system instead of the bundled version |
| ACTS_USE_SYSTEM_AUTODIFF | Use autodiff provided by the system instead of building it |
| ACTS_USE_SYSTEM_NLOHMANN_JSON | Use nlohmann::json provided by the system instead of building it |
| ACTS_USE_SYSTEM_BOOST | Use the system boost libraries (defaults to ON) |
| ACTS_USE_SYSTEM_EIGEN3 | Use the system eigen3 libraries (defaults to ON) |
| ACTS_USE_SYSTEM_VECMEM | Use system provided vecmem installation |
| ACTS_USE_SYSTEM_PYBIND11 | Use pybind11 installed in the system |

All Acts-specific options are disabled or empty by default and must be
specifically requested. Some of the options have interdependencies that are
Expand Down
33 changes: 4 additions & 29 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,15 @@ issues with missing files after installation.

## dfelibs

A copy of [dfelibs](https://github.com/msmk0/dfelibs) v20200416, with the
following folders removed:

- examples
- unittests
CMake instructions to build [dfelibs](https://github.com/msmk0/dfelibs).

## nlohmann_json

A copy of [nlohmann::json](https://github.com/nlohmann/json) revision 84f19d6, with the
following folders removed:

- benchmarks
- doc
- test
- include
- third_party
CMake instructions to build [nlohmann::json](https://github.com/nlohmann/json).

## autodiff

A copy of [autodiff](https://github.com/autodiff/autodiff), v0.6.4 (however, the
version given in the `CMakeLists.txt` of autodiff has not been changed by the maintainers
and is still v0.6.3). In the `CMakeLists.txt` the commands `add_subdirectory(tests)` and
`add_subdirectory(examples)` have been commented out. All folders/files have been
removed except the following ones:

- autodiff (contains the header files)
- cmake
- CMakeLists.txt
- LICENSE
- README.md
CMake instructions to build [autodiff](https://github.com/autodiff/autodiff).

## boost

Expand All @@ -61,8 +40,4 @@ the minimum required version of [Eigen](https://eigen.tuxfamily.org)

## pybind11

[Pybind11](https://github.com/pybind/pybind11) is used to create python bindings for
the examples. The following files/directories are removed:
- docs
- tests
- .github
CMake instructions to build [Pybind11](https://github.com/pybind/pybind11), which is used to create python bindings for the examples.
91 changes: 29 additions & 62 deletions thirdparty/autodiff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,62 +1,29 @@
# The minimum required cmake version
cmake_minimum_required(VERSION 3.0)

# Add cmake modules of this project to the module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Use ccache to speed up repeated compilations
include(CCache)

# Name and details of the project
project(autodiff VERSION 0.6.3 LANGUAGES CXX)

# Enable parallel build if MSVC is used
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)

# Include the cmake variables with values for installation directories
include(GNUInstallDirs)

# Ensure proper configuration if in a conda environment
include(CondaAware)

# Define build options
option(AUTODIFF_BUILD_TESTS "Enable the compilation of the test files." ON)
option(AUTODIFF_BUILD_PYTHON "Enable the compilation of the python bindings." ON)
option(AUTODIFF_BUILD_EXAMPLES "Enable the compilation of the example files." ON)
option(AUTODIFF_BUILD_DOCS "Enable the build of the documentation and website." ON)

# Find eigen library
find_package(Eigen3 REQUIRED)

# autodiff requires a c++17 enabled compiler
set(CMAKE_CXX_STANDARD 17) # ensure cmake instructs compiler to use C++17
set(CMAKE_CXX_STANDARD_REQUIRED ON) # ensure the C++ standard given before is actually used
set(CMAKE_CXX_EXTENSIONS OFF) # avoid compile flags of the type -std=gnu++1z added by cmake

# Build the library (actually, just provide details about the library target, specify required compile options, etc. because autodiff is header-only)
add_subdirectory(autodiff)

# Build the tests
if(AUTODIFF_BUILD_TESTS)
add_subdirectory(tests)
endif()

# Build the python wrappers
if(AUTODIFF_BUILD_PYTHON)
set(PYBIND11_CPP_STANDARD -std=c++17) # Ensure pybind11 uses C++17 standard
find_package(pybind11 REQUIRED)
add_subdirectory(python)
endif()

# Build the examples
if(AUTODIFF_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Build the docs
if(AUTODIFF_BUILD_DOCS)
add_subdirectory(docs)
endif()

# Install the cmake config files that permit users to use find_package(autodiff)
include(autodiffInstallCMakeConfigFiles)
cmake_minimum_required( VERSION 3.11 )
include( FetchContent )

# Tell the user what's happening.
message( STATUS "Building autodiff as part of the ACTS project" )


# Declare where to get VecMem from.
set( ACTS_AUTODIFF_GIT_REPOSITORY "https://github.com/autodiff/autodiff.git"
CACHE STRING "Git repository to take autodiff from" )
set( ACTS_AUTODIFF_GIT_TAG "v0.6.4" CACHE STRING "Version of autodiff to build" )
mark_as_advanced( ACTS_AUTODIFF_GIT_REPOSITORY ACTS_AUTODIFF_GIT_TAG )
FetchContent_Declare( autodiff
GIT_REPOSITORY "${ACTS_AUTODIFF_GIT_REPOSITORY}"
GIT_TAG "${ACTS_AUTODIFF_GIT_TAG}" )

# Now set up its build.
# This policy allows to set the options outside without changing autodiff's CMakeLists.txt
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(AUTODIFF_BUILD_TESTS OFF CACHE INTERNAL "")
set(AUTODIFF_BUILD_PYTHON OFF CACHE INTERNAL "")
set(AUTODIFF_BUILD_EXAMPLES OFF CACHE INTERNAL "")
set(AUTODIFF_BUILD_DOCS OFF CACHE INTERNAL "")

FetchContent_MakeAvailable( autodiff )

# Mark autodiff as system include directories so that no warnings trigger
get_target_property(_autodiff_includes autodiff INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(autodiff PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_autodiff_includes}")
21 changes: 0 additions & 21 deletions thirdparty/autodiff/LICENSE

This file was deleted.

0 comments on commit c9a5b53

Please sign in to comment.