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

Fix CMake configuration to make Physsim usable as a library #2

Merged
merged 7 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/key4hep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: keyh4ep
on: [push, pull_request]

jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: cvmfs-contrib/github-action-cvmfs@v3
- uses: aidasoft/run-lcg-view@v4
with:
container: centos7
view-path: /cvmfs/sw-nightlies.hsf.org/key4hep
run: |
mkdir build
cd build
echo "::group::Run CMake"
cmake -GNinja \
-DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=../install \
..
echo "::endgroup::" && echo "::group::Build"
ninja -k0
echo "::endgroup::" && echo "::group::Install"
ninja install
echo "::endgroup::" && echo "::group::Build example processors"
cd ../install
export CMAKE_PREFIX_PATH=$(pwd):${CMAKE_PREFIX_PATH}
cd ../example_stdhep
mkdir build
cd build
cmake -GNinja \
-DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=../install \
..
ninja -k0
44 changes: 44 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: linux
on: [push, pull_request]

jobs:
centos7:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
COMPILER: [gcc10, clang11]
LCG: [100]

steps:
- uses: actions/checkout@v3
- uses: cvmfs-contrib/github-action-cvmfs@v3
- uses: aidasoft/run-lcg-view@v4
with:
view-path: "/cvmfs/clicdp.cern.ch/iLCSoft/lcg/${{ matrix.LCG }}/nightly/x86_64-centos7-${{ matrix.COMPILER }}-opt"
setup-script: "init_ilcsoft.sh"
run: |
mkdir build
cd build
echo "::group::Run CMake"
cmake -GNinja \
-C ${ILCSOFT}/ILCSoft.cmake \
-DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " \
-DCMAKE_INSTALL_PREFIX=../install \
..
echo "::endgroup::" && echo "::group::Build"
ninja -k0
echo "::endgroup::" && echo "::group::Install"
ninja install
echo "::endgroup::" && echo "::group::Build example processors"
cd ../install
export CMAKE_PREFIX_PATH=$(pwd):${CMAKE_PREFIX_PATH}
cd ../example_stdhep
mkdir build
cd build
cmake -GNinja \
-C ${ILCSOFT}/ILCSoft.cmake \
-DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " \
-DCMAKE_INSTALL_PREFIX=../install \
..
ninja -k0
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/install/
12 changes: 0 additions & 12 deletions .travis-ci.d/compile_and_test.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .travis-ci.d/coverity_scan.sh

This file was deleted.

66 changes: 0 additions & 66 deletions .travis.yml

This file was deleted.

31 changes: 7 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# cmake file for building KalFit libraries
# @author Jan Engels, DESY
# @author F. Gaede, DESY
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 FATAL_ERROR )
CMAKE_MINIMUM_REQUIRED( VERSION 3.15 FATAL_ERROR )
########################################################


# project name
PROJECT( Physsim )

Expand All @@ -14,11 +13,11 @@ SET( ${PROJECT_NAME}_VERSION_MAJOR 0 )
SET( ${PROJECT_NAME}_VERSION_MINOR 4 )
SET( ${PROJECT_NAME}_VERSION_PATCH 2 )

SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" )


# project version

cmake_policy(SET CMP0008 NEW)
#--- Define basic build settings -----------------------------------------------
# Provides install directory variables as defined for GNU software
include(GNUInstallDirs)
Copy link

@andresailer andresailer Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the libraries now go to lib64, which breaks the check in ilcsoft-install
(And the assignment of the library to MARLIN_DLL, which happens because of how physsim is done in ilcsoft install https://github.com/iLCSoft/iLCInstall/blob/b32418db68960110ade0270a7ce37fbe32241983/releases/HEAD/release-ilcsoft.cfg#L167-L168 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true. I have made a PR to iLCInstall to accomodate for the lib[64] changes. MARLIN_DLL should not really matter for Physsim, because it does not build processors. Those need to be explicitly built from the examples directory.


### DEPENDENCIES ############################################################

Expand All @@ -28,24 +27,12 @@ FIND_PACKAGE( ILCUTIL COMPONENTS ILCSOFT_CMAKE_MODULES REQUIRED )
INCLUDE( ilcsoft_default_settings )


FIND_PACKAGE( ROOT REQUIRED )

FIND_PACKAGE( ROOT 6.14 REQUIRED COMPONENTS Physics )

# macros for generating root dict sources with rootcint
SET( ROOT_DICT_CINT_DEFINITIONS "-DHANDLE_DICT_EXCEPTIONS=IGNORED_FOR_CINT" )
INCLUDE( "${ILCUTIL_ROOT}/cmakemodules/MacroRootDict.cmake" )



### LIBRARY AND TOOLS #######################################################


# require proper c++
#ADD_DEFINITIONS( "-Wall -ansi -pedantic" )
#----- need long long for int64 for now ------
#ADD_DEFINITIONS( "-Wno-long-long -fno-strict-aliasing" )


# Physsim library
ADD_SUBDIRECTORY( ./src )

Expand All @@ -58,11 +45,7 @@ ADD_SUBDIRECTORY( ./src )
#ADD_SUBDIRECTORY( ./examples/kaltest )
# ----------------------------------------------------------------------------



# display some variables and write them to cache
DISPLAY_STD_VARIABLES()

# generate and install following configuration files
GENERATE_PACKAGE_CONFIGURATION_FILES( PhyssimConfig.cmake PhyssimConfigVersion.cmake PhyssimLibDeps.cmake )

include(cmake/PhyssimCreateConfig.cmake)
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,48 @@ Physsim is distributed under the [GPLv3 License](http://www.gnu.org/licenses/gpl

[![License](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)

## Building Physsim and the example processors

In order to build Physsim the easiest way to satisfy all dependencies is to either use a Key4hep or a recent iLCSoft release. The instructions are very similar for both, the major difference is in the invokation of the `cmake` command, where `-C ${ILCSOFT}/ILCSoft.cmake` has to be replaced by `-DCMAKE_CXX_STANDARD=17` when using a Key4hep release.

- Setup a recent iLCSoft release, e.g.
```bash
source /cvmfs/ilc.desy.de/sw/x86_64_gcc103_centos7/v02-03-01/init_ilcsoft.sh
```

- Clone the Physsim repository
```bash
git clone https://github.com/iLCSoft/Physsim
cd Physsim
```

- Build and install Physsim
```bash
mkdir build
cd build
cmake -C ${ILCSOFT}/ILCSoft.cmake -DCMAKE_INSTALL_PREFIX=../install ..
make install # use -j<N> to build with N proceses in parallel
```

- Setup the environment to use the Physsim that you have just built (assuming you are still in the build directory). **Note that the `lib64` folder might be called `lib` depending on the OS you are using, please change accordingly**
```bash
cd ../install
export CMAKE_PREFIX_PATH=$(pwd):$CMAKE_PREFIX_PATH
export LD_LIBRARY_PATH=$(pwd)/lib64:$LD_LIBRARY_PATH
cd ..
```

- Build the example processors (assuming that you start from the `Physsim` top-level directory)
```bash
cd example_stdhep
mkdir build
cd build
cmake -C ${ILCSOFT}/ILCSoft.cmake -DCMAKE_INSTALL_PREFIX=../install ..
make install # use -j<N> to build with N processes in parallel
```

- Afterwards, the usual steps of adding the processors to `MARLIN_DLL` are necessary in order for Marlin to be able to find them

## License and Copyright
Copyright (C) 2005-2017, Physsim Authors

Expand Down
25 changes: 25 additions & 0 deletions cmake/PhyssimConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
###############################################################
# Physsim CMAKE CONFIG
#
# Exported Targets
#
# Physsim::Physsim The Physsim library
###############################################################
@PACKAGE_INIT@

# set_and_check(Physsim_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
# set_and_check(Physsim_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")

include(CMakeFindDependencyMacro)
find_dependency(ROOT @ROOT_VERSION@)

if (NOT TARGET Physsim::Physsim)
include("${CMAKE_CURRENT_LIST_DIR}/PhyssimTargets.cmake")
endif()

check_required_components(Physsim)

# Print the default "Found" message and check library location
include(FindPackageHandleStandardArgs)
get_property(TEST_PHYSSIM_LIBRARY TARGET Physsim::Physsim PROPERTY LOCATION)
find_package_handle_standard_args(Physsim DEFAULT_MSG CMAKE_CURRENT_LIST_FILE TEST_PHYSSIM_LIBRARY)
25 changes: 25 additions & 0 deletions cmake/PhyssimCreateConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

include(CMakePackageConfigHelpers)

# Version file is same wherever we are
write_basic_package_version_file(${PROJECT_BINARY_DIR}/PhyssimConfigVersion.cmake
VERSION ${Physsim_VERSION}
COMPATIBILITY SameMajorVersion )

# Build tree config
# export(EXPORT PhyssimTargets NAMESPACE Physsim:: FILE ${PROJECT_BINARY_DIR}/PhyssimTargets.cmake)

# Install tree config
configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/PhyssimConfig.cmake.in
${PROJECT_BINARY_DIR}/PhyssimConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PhyssimConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PhyssimConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR})

install(EXPORT PhyssimTargets
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
NAMESPACE Physsim::)
Loading