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

Find nlohmann_json downstream if EDM4hep has support #379

Merged
merged 3 commits into from
Oct 23, 2024
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
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME
find_package(podio 1.1 REQUIRED HINTS $ENV{PODIO})
find_package(ROOT REQUIRED COMPONENTS RIO Tree Physics)

option(EDM4HEP_WITH_JSON "Whether or not to build EDM4HEP with JSON support (and edm4hep2json)" ON)
if (EDM4HEP_WITH_JSON)
set(EDM4HEP_NLOHMANN_JSON_VERSION 3.10.5)
find_package(nlohmann_json ${EDM4HEP_NLOHMANN_JSON_VERSION} REQUIRED)
endif()

include(cmake/Key4hepConfig.cmake)

#--- Define basic build settings -----------------------------------------------
Expand Down Expand Up @@ -63,7 +69,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
${CMAKE_CURRENT_SOURCE_DIR}/NOTICE
DESTINATION ${CMAKE_INSTALL_DOCDIR})

find_package(nlohmann_json 3.10.5)

add_subdirectory(edm4hep)
add_subdirectory(utils)
Expand Down
5 changes: 5 additions & 0 deletions cmake/EDM4HEPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ set_and_check(EDM4HEP_DATA_DIR "@PACKAGE_CMAKE_INSTALL_DATADIR@/edm4hep")
include(CMakeFindDependencyMacro)
find_dependency(podio REQUIRED)

set(EDM4HEP_WITH_JSON @EDM4HEP_WITH_JSON@)
if (EDM4HEP_WITH_JSON)
find_dependency(nlohmann_json @EDM4HEP_NLOHMANN_JSON_VERSION@ REQUIRED)
endif()

# - Include the targets file to create the imported targets that a client can
# link to (libraries) or execute (programs)
include("${CMAKE_CURRENT_LIST_DIR}/EDM4HEPTargets.cmake")
Expand Down
2 changes: 1 addition & 1 deletion edm4hep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ add_library(EDM4HEP::edm4hep ALIAS edm4hep)
file(GLOB_RECURSE top_headers ${PROJECT_SOURCE_DIR}/include/*.h)
target_sources(edm4hep PUBLIC FILE_SET headers TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR}/include FILES ${top_headers})

if (nlohmann_json_FOUND)
if (EDM4HEP_WITH_JSON)
target_compile_definitions(edm4hep PUBLIC PODIO_JSON_OUTPUT)
target_link_libraries(edm4hep PUBLIC nlohmann_json::nlohmann_json)
endif()
Expand Down
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
list( APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )

if (nlohmann_json_FOUND)
if (EDM4HEP_WITH_JSON)
add_executable(edm4hep2json src/edm4hep2json.cxx)

set(EDM4HEP_SET_RPATH TRUE)
Expand Down
Loading