Skip to content

Commit e7118a2

Browse files
authored
Merge pull request #39 from JeffersonLab/rasool_FeatureCMakeInstallTargets
Add CMake target exports and install config for proper find_package support
2 parents d53b29a + 37ce525 commit e7118a2

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ if(NOT C_ONLY)
148148
/usr/local/include
149149
${Boost_INCLUDE_DIRS}
150150
${LZ4_INCLUDE_DIRS}
151-
${DISRUPTOR_INCLUDE_DIR}
151+
$<BUILD_INTERFACE:${DISRUPTOR_INCLUDE_DIR}>
152+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Disruptor>
152153
)
153154

154155
# Build utility programs
@@ -260,6 +261,7 @@ endif()
260261

261262
# Basic C library installation - minimal approach
262263
install(TARGETS evio
264+
EXPORT evioTargets
263265
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
264266
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
265267
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -271,7 +273,8 @@ install(FILES ${C_HEADER_FILES}
271273

272274
# C++ components if enabled
273275
if(NOT C_ONLY)
274-
install(TARGETS eviocc
276+
install(TARGETS eviocc ${DISRUPTOR_LIBRARY}
277+
EXPORT evioTargets
275278
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
276279
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
277280
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -282,15 +285,24 @@ if(NOT C_ONLY)
282285
)
283286
endif()
284287

285-
# Install config files for find_package
288+
# Export targets and install config for find_package()
289+
install(EXPORT evioTargets
290+
FILE evioTargets.cmake
291+
NAMESPACE evio::
292+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evio
293+
)
294+
295+
include(CMakePackageConfigHelpers)
296+
286297
configure_package_config_file(
287-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/evioConfig.cmake.in"
288-
"${CMAKE_CURRENT_BINARY_DIR}/evioConfig.cmake"
289-
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/evio/cmake"
298+
${CMAKE_SOURCE_DIR}/cmake/evioConfig.cmake.in
299+
${CMAKE_BINARY_DIR}/evioConfig.cmake
300+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evio
290301
)
291-
install(
292-
FILES "${CMAKE_CURRENT_BINARY_DIR}/evioConfig.cmake"
293-
DESTINATION "${CMAKE_INSTALL_PREFIX}/evio/cmake"
302+
303+
install(FILES
304+
${CMAKE_BINARY_DIR}/evioConfig.cmake
305+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evio
294306
)
295307

296308
# Unit testing setup

cmake/evioConfig.cmake.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ if(NOT DEFINED C_ONLY)
2525
message(WARNING "You may need to set DISRUPTOR_CPP_HOME environment variable.")
2626
endif()
2727
else()
28-
# If evio was built with FetchContent, we make no assumptions
29-
message(STATUS "evio was built with integrated Disruptor. You need to provide Disruptor separately.")
30-
endif()
28+
# Disruptor is built and exported together with evio
29+
message(STATUS "evio includes Disruptor internally; you do not need to provide it separately.")
30+
endif()
3131
endif()
3232

3333
# Include the targets file

0 commit comments

Comments
 (0)