Skip to content

Commit

Permalink
integrate conan package manager
Browse files Browse the repository at this point in the history
Conan package manager is now added to R3BRoot. By default, it's disable.
Building the project with conan package manager can be achieved with
cmake preset and conan cmake wrapper as a git submodule.
  • Loading branch information
YanzhaoW authored and jose-luis-rs committed Aug 22, 2024
1 parent 10a9569 commit 78feb09
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 60 deletions.
3 changes: 1 addition & 2 deletions .github/actions/pre-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ runs:
echo "cacheSHA=$([[ ${{github.event_name}} = "push" ]] && git rev-parse --short HEAD || git rev-parse --short HEAD^)" >> $GITHUB_ENV
shell: bash


- name: mount cvmfs
run: |
apt-get update
apt-get install --fix-missing -y ccache sudo
conda install -y conda-forge::ninja
wget https://cernbox.cern.ch/remote.php/dav/public-files/RmnTeeOZpYjCJQb/masterkey.gsi.de.pub
mv masterkey.gsi.de.pub /etc/cvmfs/keys
cp .githubfiles/fairsoft.gsi.de.conf /etc/cvmfs/config.d
mkdir -p ${CVMDIR}
mount -t cvmfs fairsoft.gsi.de ${CVMDIR}
mkdir -p ${UCESB_DIR}
mkdir -p ${CCACHE_DIR}
echo $PATH
shell: bash
10 changes: 7 additions & 3 deletions .github/actions/r3bbuild-steps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ runs:
done
shell: bash

- name: cmake configure ${{ matrix.repos }}
- name: cmake config ${{ matrix.repos }}
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git submodule update --init --recursive
git clone https://github.com/R3BRootGroup/macros.git
cmake . -B build -C cmake/CI_CD/configure_options.cmake
echo ""
echo "path environment variable: $PATH\n"
echo ""
cmake --preset ${{ matrix.preset }} . -C "$GITHUB_WORKSPACE/cmake/CI_CD/configure_options.cmake"
shell: bash

- name: ctest ${{ matrix.repos }}
- name: build ${{ matrix.repos }}
if: inputs.build-needed == 'true'
run: |
cmake --build ./build -- -j ${NUM_THREADS}
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ jobs:
# any of them fail. By setting it to false, all jobs will be run
# undisruptively.
fail-fast: false
# Definition of the strategy matrix
# Definition of the strategy matrix. See
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
matrix:
# Here are the groups of repositories that need to be downloaded inside
# r3broot. Each group is used by only one job.
repos: [ r3broot, glad-tpc, sofia-frs-asy ]
repos: [ r3broot, glad-tpc, sofia-frs-asy, r3broot-conan ]

# The list under "include" defines some properties for each group:
#
# repos: the name of the group. It must exist in matrix.repos as
Expand All @@ -92,12 +94,15 @@ jobs:
# url: the github repository urls that need to be downloaded during the
# run
include:
# The R3BFileSource repo is used for testing unpacking.
- url: https://github.com/R3BRootGroup/R3BFileSource.git
- cache: r3broot
# disable conan build by default
- preset: simple

# This job is only for testing R3BRoot without downloading any
# dependencies.
- repos: r3broot
# The R3BFileSource repo is used for testing unpacking.
url: https://github.com/R3BRootGroup/R3BFileSource.git
cache: r3broot
# The job for testing with glad-tpc
- repos: glad-tpc
url: https://github.com/R3BRootGroup/glad-tpc.git
Expand All @@ -118,11 +123,15 @@ jobs:
# Using own cache file
cache: other-repos

# build with conan package manager
- repos: r3broot-conan
preset: default

# Jobs are run inside a Docker container, which provides different compiled
# tool-kits for the building, such as clang-tidy and cvmfs. For more
# information, please visit the Docker repository at Dockerhub.
container:
image: yanzhaowang/cvmfs_clang:v15
image: yanzhaowang/cvmfs_clang:latest
volumes:
- /tmp:/cvmfs
env:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:

clang-tidy:
runs-on: ubuntu-latest
strategy:
matrix:
preset: [ default ]
container:
image: yanzhaowang/cvmfs_clang:v15
image: yanzhaowang/cvmfs_clang:latest
volumes:
- /tmp:/cvmfs
env:
CVMDIR: /cvmfs/fairsoft.gsi.de
options: --user root --privileged --ulimit nofile=10000:10000 --cap-add SYS_ADMIN --device /dev/fuse
options: --user root --privileged --ulimit nofile=9999:10000 --cap-add SYS_ADMIN --device /dev/fuse
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -45,7 +48,7 @@ jobs:
id: restore-caching
uses: './.github/actions/install-deps'
with:
repo: 'false'
cache-name: 'false'

- name: configure r3broot
uses: './.github/actions/r3bbuild-steps'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ CMakeUserPresets.json

# Local configuration
c3w.conf
CMakeUserPresets.json
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cmake-conan"]
path = util/cmake-conan
url = https://github.com/conan-io/cmake-conan.git
branch = develop2
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ cmake_policy(VERSION 3.15...3.24)
# Set name of our project to "R3BROOT". Has to be done after check of cmake version
project(R3BROOT LANGUAGES C CXX Fortran)

# use default gnu install convention:
include(GNUInstallDirs)

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/macros")
message(STATUS " ")
message(
Expand Down Expand Up @@ -86,6 +89,7 @@ option(WITH_GTPC "Build GTPC" OFF)
option(WITH_FRS "Build FRS" OFF)
option(WITH_ASYEOS "Build ASYEOS" OFF)
option(BUILD_C3W "Build C3W" OFF)
option(CONAN_ENABLED "conan package is enabled. (Use CMakePreset to set it)" OFF)

find_package(FairCMakeModules 1.0.0 CONFIG REQUIRED)
if(NOT FairCMakeModules_FOUND)
Expand Down Expand Up @@ -281,6 +285,16 @@ else()
REQUIRED)
endif()

if(CONAN_ENABLED)
find_package(range-v3 REQUIRED)
find_package(Microsoft.GSL REQUIRED)
find_package(nlohmann_json REQUIRED)
set(JSON_ImplicitConversions
OFF
CACHE BOOL "disable implicit conversion of JSON" FORCE)
endif()

find_package(GTest REQUIRED)
find_package2(PUBLIC Pythia6)
find_package2(PUBLIC Pythia8)
find_package2(PUBLIC Protobuf)
Expand Down Expand Up @@ -335,7 +349,7 @@ if(USE_PATH_INFO)
else(APPLE)
set(LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
endif(APPLE)
endif(USE_PATH_INFO)
endif()

# Check if the user wants to build the project in the source directory
check_out_of_source_build()
Expand Down Expand Up @@ -378,7 +392,7 @@ if(yaml-cpp_FOUND
"${YAML_CPP_INCLUDE_DIR}")
endif()

include(${CMAKE_SOURCE_DIR}/cmake/scripts/fetchGTest.cmake)
# include(${CMAKE_SOURCE_DIR}/cmake/scripts/fetchGTest.cmake)

setbasicvariables()

Expand Down
42 changes: 42 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "simple",
"displayName": "simple Config for R3BRoot without conan",
"description": "simple build with conan package manager",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_GEOMETRY": "OFF",
"USE_DIFFERENT_COMPILER": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "default",
"displayName": "Default Config for R3BRoot",
"description": "Default build with conan package manager",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_GEOMETRY": "OFF",
"USE_DIFFERENT_COMPILER": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "util/cmake-conan/conan_provider.cmake",
"CONAN_ENABLED": "ON"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ export FAIRROOTPATH=%PATH_TO_FAIRROOT%
# from %R3BRoot_DIRECTORY%
mkdir build
cmake -S . -B ./build
cmake --build ./build
cmake --build ./build -- -j${number_of_threads}
source build/config.sh
~~~

For the building with Conan package manager, see [this instruction](doc/conan_usage.md).

To run the detector tests do:

~~~bash
Expand Down
7 changes: 0 additions & 7 deletions cmake/CI_CD/configure_options.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
set(BUILD_GEOMETRY
OFF
CACHE BOOL "disable build geo")
set(USE_DIFFERENT_COMPILER
ON
CACHE BOOL "use different compiler")

find_program(CCACHE "ccache")
if(CCACHE)
message("enable ccache for cmake build")
Expand Down
10 changes: 4 additions & 6 deletions cmake/modules/WriteConfigFile_r3b.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ macro(WRITE_CONFIG_FILE filename)

if(FAIRSOFT_EXTERN)
set(PYTHIA8DATA "${SIMPATH}/share/pythia8/xmldoc")
else(FAIRSOFT_EXTERN)
else()
set(PYTHIA8DATA "${SIMPATH}/generators/pythia8/xmldoc")
endif(FAIRSOFT_EXTERN)
endif()

convert_list_to_string($ENV{NEW_CLASSPATH})
set(MY_CLASSPATH ${output})
Expand All @@ -187,7 +187,7 @@ macro(WRITE_CONFIG_FILE filename)
${CMAKE_CURRENT_BINARY_DIR}/${filename})
endif(R3BROOTPATH)

else(${filename} MATCHES "[.]csh.*$")
else()
if(R3BROOTPATH)
configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/config.sh.in
${CMAKE_CURRENT_BINARY_DIR}/${filename})
Expand All @@ -196,12 +196,11 @@ macro(WRITE_CONFIG_FILE filename)
${CMAKE_CURRENT_BINARY_DIR}/${filename})
endif(R3BROOTPATH)

endif(${filename} MATCHES "[.]csh.*$")
endif()

endmacro(WRITE_CONFIG_FILE)

macro(CONVERT_LIST_TO_STRING)

set(tmp "")
foreach(_current ${ARGN})

Expand All @@ -215,5 +214,4 @@ macro(CONVERT_LIST_TO_STRING)
else(tmp)
set(output "")
endif(tmp)

endmacro(CONVERT_LIST_TO_STRING LIST)
28 changes: 0 additions & 28 deletions cmake/scripts/fetchGTest.cmake

This file was deleted.

19 changes: 19 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain


class CompressorRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"

def requirements(self):
self.requires("ms-gsl/4.0.0")
self.requires("range-v3/0.12.0")
self.requires("gtest/cci.20210126")
self.requires("nlohmann_json/3.11.2")
self.requires("yaml-cpp/0.8.0")

def generate(self):
tc = CMakeToolchain(self)
tc.user_presets_path = False
tc.generate()
9 changes: 8 additions & 1 deletion config/clang_tidy/neuland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Checks: >
hicpp-*,
-hicpp-vararg,
misc-*,
-misc-no-recursion,
modernize-*,
performance-*,
readability-*
Expand All @@ -36,8 +37,14 @@ CheckOptions:
value: 1
- key: readability-identifier-length.IgnoredVariableNames
value: '^it$'
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
value: "0.5;1.0;2.0;10.0;100.0;1000.0;"
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;2.0;10.0;100.0;1000.0'
value: "0.5;1.0;2.0;10.0;100.0;1000.0;"
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
value: "1;2;3;4;5;6;7;8;"
- key: readability-magic-numbers.IgnoredIntegerValues
value: "1;2;3;4;5;6;7;8;"
- key: readability-function-cognitive-complexity.Threshold
value: 40
- key: readability-function-cognitive-complexity.IgnoreMacros
Expand Down
Loading

0 comments on commit 78feb09

Please sign in to comment.