Skip to content

Commit d2c2db2

Browse files
authored
Edm4eic podio master build (#131)
### Briefly, what does this PR introduce? - A CMake option to turn off documentation generation (`GENERATE_DOCS`) - The inclusion of `CTest` to make sure that `BUILD_TESTING` is `ON` by default - Fixes that are necessary to build this against the current head version of podio and EDM4hep ### What kind of change does this PR introduce? - [x] Bug fix: Given that `BUILD_TESTING` has been `OFF` by default so far, quite a few of the tests needed fixes to compile - [x] New feature: `BUILD_TESTING=ON` by default and new `GENERATE_DOCS` cmake option - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? ### Does this PR change default behavior? Yes, `BUILD_TESTING` is `ON` by default now. Technically this might be three (or four) PRs instead of only one. I am happy to split them into more topical PRs if desired. I have also rather generously removed tests that were not applicable for EDM4eic or that could never work in the current setup. I can also bring a few of them back with appropriate content if desired / necessary.
1 parent d9fb5a5 commit d2c2db2

File tree

7 files changed

+52
-128
lines changed

7 files changed

+52
-128
lines changed

CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ endif(APPLE)
2828

2929
include(GNUInstallDirs)
3030

31+
include(CTest)
32+
3133
find_package(podio 0.15)
3234
if(NOT podio_FOUND)
3335
find_package(podio 1.0 REQUIRED)
@@ -93,16 +95,20 @@ configure_file(
9395
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
9496
@ONLY)
9597

96-
find_package(Doxygen COMPONENTS dot)
97-
if(DOXYGEN_FOUND)
98-
add_custom_target(docs ALL
99-
DEPENDS edm4eic.yaml ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
100-
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
101-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
102-
COMMENT "Generating API documentation with Doxygen"
98+
option(GENERATE_DOCS "Generate the doxygen base API reference" ON)
99+
100+
if (GENERATE_DOCS)
101+
find_package(Doxygen COMPONENTS dot)
102+
if(DOXYGEN_FOUND)
103+
add_custom_target(docs ALL
104+
DEPENDS edm4eic.yaml ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
105+
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
106+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
107+
COMMENT "Generating API documentation with Doxygen"
103108
VERBATIM)
104-
else()
105-
message(STATUS "Doxygen not found; no documentation will be built.")
109+
else()
110+
message(STATUS "Doxygen not found; no documentation will be built.")
111+
endif()
106112
endif()
107113

108114
# -------------------------

test/CMakeLists.txt

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ENDIF()
66

77
function(set_test_env _testname)
88
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
9-
LD_LIBRARY_PATH=$<TARGET_FILE_DIR:edm4hep>:$<TARGET_FILE_DIR:podio::podio>:$<$<TARGET_EXISTS:edm4hepRDF>:$<TARGET_FILE_DIR:edm4hepRDF>:>$<TARGET_FILE_DIR:ROOT::Core>:$ENV{LD_LIBRARY_PATH}
10-
ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/edm4hep:${PROJECT_SOURCE_DIR}/utils/include:$ENV{ROOT_INCLUDE_PATH}
9+
LD_LIBRARY_PATH=$<TARGET_FILE_DIR:edm4eic>:$<TARGET_FILE_DIR:EDM4HEP::edm4hep>:$<TARGET_FILE_DIR:podio::podio>:$<$<TARGET_EXISTS:EDM4HEP::edm4hepRDF>:$<TARGET_FILE_DIR:EDM4HEP::edm4hepRDF>:>$<TARGET_FILE_DIR:ROOT::Core>:$ENV{LD_LIBRARY_PATH}
10+
ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/utils/include:$ENV{ROOT_INCLUDE_PATH}
1111
)
1212
set_tests_properties(${_testname} PROPERTIES
1313
FAIL_REGULAR_EXPRESSION "[^a-z]Error;ERROR;error;Failed"
@@ -16,58 +16,15 @@ endfunction()
1616

1717
add_executable(write_events write_events.cc)
1818
target_include_directories(write_events PUBLIC ${PROJECT_SOURCE_DIR}/edm4hep )
19-
target_link_libraries(write_events edm4hep podio::podioRootIO)
19+
target_link_libraries(write_events edm4eic EDM4HEP::edm4hep podio::podioRootIO)
2020
add_test(NAME write_events COMMAND write_events)
2121
set_test_env(write_events)
2222

2323
add_executable(read_events read_events.cc)
2424
target_include_directories(read_events PUBLIC ${PROJECT_SOURCE_DIR}/edm4hep )
25-
target_link_libraries(read_events edm4hep podio::podioRootIO)
25+
target_link_libraries(read_events edm4eic EDM4HEP::edm4hep podio::podioRootIO)
2626
add_test(NAME read_events COMMAND read_events)
2727
set_property(TEST read_events PROPERTY
2828
DEPENDS write_events
2929
)
3030
set_test_env(read_events)
31-
32-
IF(TARGET ROOT::ROOTDataFrame)
33-
add_executable(test_rdf test_rdf.cc)
34-
target_include_directories(test_rdf PUBLIC ${PROJECT_SOURCE_DIR}/edm4hep ${PROJECT_SOURCE_DIR}/dataframe )
35-
target_link_libraries(test_rdf edm4hepRDF ROOT::ROOTDataFrame podio::podioRootIO)
36-
add_test(NAME test_rdf COMMAND test_rdf)
37-
set_test_env(test_rdf)
38-
set_property(TEST test_rdf PROPERTY
39-
DEPENDS write_events
40-
)
41-
42-
add_test(NAME py_test_rdf COMMAND python ${CMAKE_CURRENT_LIST_DIR}/test_rdf.py)
43-
set_test_env(py_test_rdf)
44-
get_property(ENVIRONMENT TEST py_test_rdf PROPERTY ENVIRONMENT)
45-
set_property(TEST py_test_rdf PROPERTY ENVIRONMENT
46-
${ENVIRONMENT}
47-
PYTHONPATH=${PROJECT_SOURCE_DIR}/python:$ENV{PYTHONPATH}
48-
)
49-
set_tests_properties(py_test_rdf PROPERTIES DEPENDS write_events)
50-
endif()
51-
52-
53-
find_package(HepMC3)
54-
find_package(HepPDT)
55-
56-
if(HepMC3_FOUND AND HepPDT_FOUND )
57-
add_executable(edm4hep_testhepmc hepmc/edm4hep_testhepmc.cc)
58-
target_include_directories(edm4hep_testhepmc PUBLIC ${HEPMC3_INCLUDE_DIR} ${HEPPDT_INCLUDE_DIR} )
59-
target_link_libraries(edm4hep_testhepmc edm4hep podio::podioRootIO ${HEPPDT_LIBRARIES} ${HEPMC3_LIBRARIES})
60-
add_test(NAME edm4hep_testhepmc COMMAND edm4hep_testhepmc)
61-
set_test_env(edm4hep_testhepmc)
62-
set_property(TEST edm4hep_testhepmc APPEND PROPERTY ENVIRONMENT
63-
ROOT_INCLUDE_PATH=${HEPMC3_INCLUDE_DIR}:$ENV{ROOT_INCLUDE_PATH}
64-
)
65-
endif()
66-
67-
if (nlohmann_json_FOUND)
68-
add_test(NAME convert_events COMMAND edm4hep2json edm4hep_events.root)
69-
set_property(TEST convert_events PROPERTY DEPENDS write_events)
70-
set_test_env(convert_events)
71-
endif()
72-
73-
add_subdirectory(utils)

test/read_events.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
#include "read_events.h"
4-
#include "podio/ROOTFrameReader.h"
4+
5+
#include <podio/podioVersion.h>
6+
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
7+
#include <podio/ROOTReader.h>
8+
#else
9+
#include <podio/ROOTFrameReader.h>
10+
namespace podio {
11+
using ROOTReader = podio::ROOTFrameReader;
12+
}
13+
#endif
514

615
int main() {
7-
read_events<podio::ROOTFrameReader>("edm4eic_events.root");
16+
read_events<podio::ROOTReader>("edm4eic_events.root");
817

918
return 0;
1019
}

test/read_events.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
// podio specific includes
1010
#include "podio/Frame.h"
11+
#include "podio/podioVersion.h"
1112

1213
// STL
1314
#include <cassert>
@@ -18,7 +19,11 @@
1819
void processEvent(const podio::Frame& event, bool verboser, unsigned eventNum) {
1920
auto& raw_hits = event.get<edm4eic::RawTrackerHitCollection>("RawTrackerHits");
2021

22+
#if PODIO_BUILD_VERSION >= PODIO_VERSION(1, 6, 0)
23+
if (raw_hits.hasID()) {
24+
#else
2125
if (raw_hits.isValid()) {
26+
#endif
2227

2328
//-------- print particles for debugging:
2429

@@ -40,7 +45,11 @@ void processEvent(const podio::Frame& event, bool verboser, unsigned eventNum) {
4045
//===============================================================================
4146

4247
const auto& evtType = event.getParameter<std::string>("EventType");
43-
std::cout << "Event Type: " << evtType << std::endl;
48+
#if PODIO_BUILD_VERSION >= PODIO_VERSION(1, 0, 0)
49+
std::cout << "Event Type: " << evtType.value_or("EventType does not exist in Frame as parameter") << std::endl;
50+
#else
51+
std::cout << "Event Type: " << evtType.value() << std::endl;
52+
#endif
4453
}
4554

4655
template <typename ReaderT>

test/test_rdf.cc

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/test_rdf.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/write_events.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
#include "write_events.h"
4-
#include "podio/ROOTFrameWriter.h"
54

6-
int main(int argc, char* argv[]) {
5+
#include <podio/podioVersion.h>
6+
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
7+
#include <podio/ROOTWriter.h>
8+
#else
9+
#include <podio/ROOTFrameWriter.h>
10+
namespace podio {
11+
using ROOTWriter = podio::ROOTFrameWriter;
12+
}
13+
#endif
14+
15+
int main(int argc, char *argv[]) {
716

8-
write<podio::ROOTFrameWriter>("edm4eic_events.root");
17+
write<podio::ROOTWriter>("edm4eic_events.root");
918
}

0 commit comments

Comments
 (0)