Skip to content

Commit a16a629

Browse files
benedikt-voelkelsawenzel
authored andcommitted
Split libraries (#14)
* Split library into Core, Intercept and Analysis * Remove CMake target namespace, update lib names * Update README This step is needed in order to used some headers (StepInfo) in other packages without the monitoring features.
1 parent d89551d commit a16a629

File tree

5 files changed

+134
-24
lines changed

5 files changed

+134
-24
lines changed

CMakeLists.txt

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ SET(LIBRARY_NAME ${MODULE_NAME})
2929
SET(EXECUTABLE_NAME mcStepAnalysis)
3030

3131
# Required source files to build the library.
32-
set(SRCS
32+
set(SRCS_CORE
33+
${IMP_SRC_DIR}/StepInfo.cxx
34+
)
35+
36+
set(SRCS_INTERCEPT
3337
${IMP_SRC_DIR}/MCStepInterceptor.cxx
3438
${IMP_SRC_DIR}/MCStepLoggerImpl.cxx
35-
${IMP_SRC_DIR}/StepInfo.cxx
39+
)
40+
41+
set(SRCS_ANALYSIS
3642
${IMP_SRC_DIR}/MCAnalysis.cxx
3743
${IMP_SRC_DIR}/BasicMCAnalysis.cxx
3844
${IMP_SRC_DIR}/SimpleStepAnalysis.cxx
@@ -43,9 +49,15 @@ set(SRCS
4349
)
4450

4551
# Requried headers to build the library.
46-
set(HEADERS
52+
set(HEADERS_CORE
4753
${INC_SRC_DIR}/StepInfo.h
4854
${INC_SRC_DIR}/MetaInfo.h
55+
)
56+
57+
set(HEADERS_INTERCEPT
58+
)
59+
60+
set(HEADERS_ANALYSIS
4961
${INC_SRC_DIR}/MCAnalysis.h
5062
${INC_SRC_DIR}/BasicMCAnalysis.h
5163
${INC_SRC_DIR}/SimpleStepAnalysis.h
@@ -109,34 +121,90 @@ message(STATUS "Build with CXX STD ${CMAKE_CXX_STANDARD}")
109121

110122
# Build a library from the sources specified above together with generated ROOT
111123
# dictionary
112-
add_library(${MODULE_NAME} SHARED ${SRCS} "${ROOT_DICT_NAME}.cxx" ${HEADERS})
113124

114-
# Link together with ROOT libs
125+
####################
126+
# Add main library #
127+
####################
128+
set(lib_core "${MODULE_NAME}Core")
129+
130+
# Generate ROOT dictionary
131+
SET(ROOT_DICT_LINKDEF_FILE_CORE "${IMP_SRC_DIR}/${lib_core}LinkDef.h")
132+
SET(ROOT_DICT_NAME_CORE "G__${lib_core}")
133+
ROOT_GENERATE_DICTIONARY(${ROOT_DICT_NAME_CORE} ${HEADERS_CORE} LINKDEF ${ROOT_DICT_LINKDEF_FILE_CORE})
134+
# Files produced by the dictionary generation
135+
SET(ROOT_DICT_LIB_FILES_CORE
136+
"${PROJECT_BINARY_DIR}/lib${lib_core}_rdict.pcm"
137+
"${PROJECT_BINARY_DIR}/lib${lib_core}.rootmap")
138+
139+
add_library(${lib_core} SHARED ${SRCS_CORE} "${ROOT_DICT_NAME_CORE}.cxx")
115140
set(LIB_DEPS ROOT::Core ROOT::Hist ROOT::Graf ROOT::Gpad ROOT::Tree ROOT::VMC ROOT::RIO ROOT::Geom ROOT::EG)
116-
target_link_libraries(${MODULE_NAME} ${LIB_DEPS})
117-
set_target_properties(${MODULE_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES "${LIB_DEPS}")
118-
target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
141+
target_link_libraries(${lib_core} ${LIB_DEPS})
142+
set_target_properties(${lib_core} PROPERTIES INTERFACE_LINK_LIBRARIES "${LIB_DEPS}")
143+
target_include_directories(${lib_core} INTERFACE $<INSTALL_INTERFACE:include>)
144+
145+
146+
#########################
147+
# Add intercept library #
148+
#########################
149+
set(lib_intercept "${MODULE_NAME}Intercept")
150+
151+
# Generate ROOT dictionary
152+
SET(ROOT_DICT_LINKDEF_FILE_INTERCEPT "${IMP_SRC_DIR}/${lib_intercept}LinkDef.h")
153+
SET(ROOT_DICT_NAME_INTERCEPT "G__${lib_intercept}")
154+
ROOT_GENERATE_DICTIONARY(${ROOT_DICT_NAME_INTERCEPT} ${HEADERS_INTERCEPT} LINKDEF ${ROOT_DICT_LINKDEF_FILE_INTERCEPT})
155+
# Files produced by the dictionary generation
156+
SET(ROOT_DICT_LIB_FILES_INTERCEPT
157+
"${PROJECT_BINARY_DIR}/lib${lib_intercept}_rdict.pcm"
158+
"${PROJECT_BINARY_DIR}/lib${lib_intercept}.rootmap")
159+
160+
add_library(${lib_intercept} SHARED ${SRCS_INTERCEPT} "${ROOT_DICT_NAME_INTERCEPT}.cxx")
161+
target_link_libraries(${lib_intercept} ${lib_core})
162+
set_target_properties(${lib_intercept} PROPERTIES INTERFACE_LINK_LIBRARIES "${lib_core}")
163+
target_include_directories(${lib_intercept} INTERFACE $<INSTALL_INTERFACE:include>)
164+
165+
########################
166+
# Add analysis library #
167+
########################
168+
set(lib_analysis "${MODULE_NAME}Analysis")
169+
170+
# Generate ROOT dictionary
171+
SET(ROOT_DICT_LINKDEF_FILE_ANALYSIS "${IMP_SRC_DIR}/${lib_analysis}LinkDef.h")
172+
SET(ROOT_DICT_NAME_ANALYSIS "G__${lib_analysis}")
173+
ROOT_GENERATE_DICTIONARY(${ROOT_DICT_NAME_ANALYSIS} ${HEADERS_ANALYSIS} LINKDEF ${ROOT_DICT_LINKDEF_FILE_ANALYSIS})
174+
# Files produced by the dictionary generation
175+
SET(ROOT_DICT_LIB_FILES_ANALYSIS
176+
"${PROJECT_BINARY_DIR}/lib${lib_analysis}_rdict.pcm"
177+
"${PROJECT_BINARY_DIR}/lib${lib_analysis}.rootmap")
178+
179+
add_library(${lib_analysis} SHARED ${SRCS_ANALYSIS} "${ROOT_DICT_NAME_ANALYSIS}.cxx")
180+
target_link_libraries(${lib_analysis} ${lib_core})
181+
set_target_properties(${lib_analysis} PROPERTIES INTERFACE_LINK_LIBRARIES "${lib_core}")
182+
target_include_directories(${lib_analysis} INTERFACE $<INSTALL_INTERFACE:include>)
183+
119184

120185
# Install headers
121-
install(FILES ${HEADERS} DESTINATION ${INSTALL_INC_DIR})
186+
install(FILES ${HEADERS_CORE} ${HEADERS_INTERCEPT} ${HEADERS_ANALYSIS} DESTINATION ${INSTALL_INC_DIR})
122187

123188
# Install libraries (and add to export such that we can easily find its dependencies later)
124-
install(TARGETS ${MODULE_NAME} DESTINATION ${INSTALL_LIB_DIR} EXPORT ${CMAKE_PROJECT_NAME}Exports)
189+
install(TARGETS ${lib_core} DESTINATION ${INSTALL_LIB_DIR} EXPORT ${CMAKE_PROJECT_NAME}Exports)
190+
install(TARGETS ${lib_intercept} DESTINATION ${INSTALL_LIB_DIR} EXPORT ${CMAKE_PROJECT_NAME}Exports)
191+
install(TARGETS ${lib_analysis} DESTINATION ${INSTALL_LIB_DIR} EXPORT ${CMAKE_PROJECT_NAME}Exports)
125192

126193
# Install the ROOT dictionary files
127-
install(FILES ${ROOT_DICT_LIB_FILES} DESTINATION ${INSTALL_LIB_DIR})
194+
install(FILES ${ROOT_DICT_LIB_FILES_CORE} DESTINATION ${INSTALL_LIB_DIR})
195+
install(FILES ${ROOT_DICT_LIB_FILES_INTERCEPT} DESTINATION ${INSTALL_LIB_DIR})
196+
install(FILES ${ROOT_DICT_LIB_FILES_ANALYSIS} DESTINATION ${INSTALL_LIB_DIR})
128197

129198
# Install executables (and add to export such that we can easily find its dependencies later)
130199
add_executable(${EXECUTABLE_NAME} ${EXE_SRCS})
131-
set(EXE_DEPS ${MODULE_NAME} Boost::program_options Boost::chrono Boost::unit_test_framework)
132-
target_link_libraries(${EXECUTABLE_NAME} ${EXE_DEPS})
200+
target_link_libraries(${EXECUTABLE_NAME} ${lib_core} ${lib_analysis} Boost::program_options Boost::chrono Boost::unit_test_framework)
133201
install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${INSTALL_BIN_DIR} EXPORT ${CMAKE_PROJECT_NAME}Exports)
134202

135203
# Install macros
136204
install(FILES ${MACROS} DESTINATION ${INSTALL_MACRO_DIR})
137205

138206
# Install exports to find targets and dependencies later
139-
install(EXPORT ${CMAKE_PROJECT_NAME}Exports NAMESPACE MCStepLogger:: FILE MCStepLoggerTargets.cmake DESTINATION ${INSTALL_CMAKE_DIR})
207+
install(EXPORT ${CMAKE_PROJECT_NAME}Exports FILE MCStepLoggerTargets.cmake DESTINATION ${INSTALL_CMAKE_DIR})
140208

141209
# Configure and install the config to be used by CMake of depending package
142210
configure_file(

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ Note that some of the instructions below especially apply to the usage together
1919

2020
## MCStepLogger
2121

22-
Detailed debug information about stepping can be directed to standard output using the `LD_PRELOAD` env variable, which "injects" a
23-
special logging library (which intercepts some calls) in the executable that follows in the command line.
22+
3 libraries are built
23+
24+
1. MCStepLoggerCore
25+
2. MCStepLoggerIntercept
26+
3. MCStepLoggerAnalysis
27+
28+
The first one contains core classes like `o2::StepInfo` to be used in depending packages and the same is true for the third one which contains analysis specific code.
29+
30+
The second library `MCStepLoggerIntercept` allows for detailed debug information where stepping can be directed to standard output using the `LD_PRELOAD` env variable, which "injects" this library (which intercepts some calls) in the executable that follows in the command line.
2431

2532
```bash
26-
LD_PRELOAD=path_to/libMCStepLogger.so o2sim -m MCH -n 10
33+
LD_PRELOAD=path_to/libMCStepLoggerIntercept.so o2sim -m MCH -n 10
2734
```
2835

2936

src/MCStepLoggerAnalysisLinkDef.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
12+
#ifdef __CLING__
13+
#pragma link off all globals;
14+
#pragma link off all classes;
15+
#pragma link off all functions;
16+
17+
#pragma link C++ class o2::mcstepanalysis::MCAnalysis + ;
18+
#pragma link C++ class o2::mcstepanalysis::BasicMCAnalysis + ;
19+
#pragma link C++ class o2::mcstepanalysis::SimpleStepAnalysis + ;
20+
#pragma link C++ class o2::mcstepanalysis::MCAnalysisMetaInfo + ;
21+
#pragma link C++ class o2::mcstepanalysis::MCAnalysisManager + ;
22+
#pragma link C++ class o2::mcstepanalysis::MCAnalysisFileWrapper + ;
23+
#pragma link C++ class o2::mcstepanalysis::ROOTIOUtilities + ;
24+
25+
#endif
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,5 @@
2424
#pragma link C++ class std::vector<std::vector<TGeoVolume const *> *>+;
2525
#pragma link C++ class o2::VolInfoContainer+;
2626
#pragma link C++ class o2::StepLookups+;
27-
#pragma link C++ class o2::mcstepanalysis::MCAnalysis + ;
28-
#pragma link C++ class o2::mcstepanalysis::BasicMCAnalysis + ;
29-
#pragma link C++ class o2::mcstepanalysis::SimpleStepAnalysis + ;
30-
#pragma link C++ class o2::mcstepanalysis::MCAnalysisMetaInfo + ;
31-
#pragma link C++ class o2::mcstepanalysis::MCAnalysisManager + ;
32-
#pragma link C++ class o2::mcstepanalysis::MCAnalysisFileWrapper + ;
33-
#pragma link C++ class o2::mcstepanalysis::ROOTIOUtilities + ;
3427

3528
#endif

src/MCStepLoggerInterceptLinkDef.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
12+
#ifdef __CLING__
13+
#pragma link off all globals;
14+
#pragma link off all classes;
15+
#pragma link off all functions;
16+
17+
#endif

0 commit comments

Comments
 (0)