Skip to content

Commit

Permalink
Add an EDM4HEP_WITH_JSON cmake option to be explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Oct 23, 2024
1 parent 3a4ef70 commit 5bb65d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ 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)
find_package(nlohmann_json 3.10.5 REQUIRED)
endif()

include(cmake/Key4hepConfig.cmake)

#--- Define basic build settings -----------------------------------------------
Expand Down Expand Up @@ -63,7 +68,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
2 changes: 1 addition & 1 deletion cmake/EDM4HEPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set_and_check(EDM4HEP_DATA_DIR "@PACKAGE_CMAKE_INSTALL_DATADIR@/edm4hep")
include(CMakeFindDependencyMacro)
find_dependency(podio REQUIRED)

set(EDM4HEP_WITH_JSON @nlohmann_json_FOUND@)
set(EDM4HEP_WITH_JSON @EDM4HEP_WITH_JSON@)
if (EDM4HEP_WITH_JSON)
find_dependency(nlohmann_json 3.10.5 REQUIRED)
endif()
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

0 comments on commit 5bb65d2

Please sign in to comment.