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

Export targets and make sure they can be used by other projects #177

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,17 @@ MESSAGE( STATUS "" )
GENERATE_PACKAGE_CONFIGURATION_FILES( LCIOConfig.cmake LCIOConfigVersion.cmake )

INSTALL( FILES cmake/MacroCheckPackageLibs.cmake cmake/MacroCheckPackageVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)

install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
FILE "${PROJECT_NAME}Targets.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
)

IF( NOT SIO_FOUND )
install(EXPORT SIOTargets
NAMESPACE SIO::
FILE "SIOTargets.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SIO/"
)
andresailer marked this conversation as resolved.
Show resolved Hide resolved
ENDIF()
10 changes: 10 additions & 0 deletions cmake/LCIOConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ CHECK_PACKAGE_LIBS( LCIO lcio @CHECK_PACKAGE_SIO_LIBRARY@ )
## ---------------------------------------------------------------


include(CMakeFindDependencyMacro)
if("@CHECK_PACKAGE_SIO_LIBRARY@" STREQUAL "")
find_dependency(SIO REQUIRED)
else()
find_dependency(ZLIB REQUIRED)
jmcarcell marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Include the targets file to create the imported targets that a client can link
# to or execute
include("${CMAKE_CURRENT_LIST_DIR}/LCIOTargets.cmake")


# ---------- final checking ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions cmake/MacroGeneratePackageConfigFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MACRO( GENERATE_PACKAGE_CONFIGURATION_FILES )
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/cmake/${arg}.in"
"${PROJECT_BINARY_DIR}/${arg}" @ONLY
)
INSTALL( FILES "${PROJECT_BINARY_DIR}/${arg}" DESTINATION . )
INSTALL( FILES "${PROJECT_BINARY_DIR}/${arg}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} )
#IF( EXISTS "${_current_dir}/MacroCheckPackageLibs.cmake" )
# INSTALL( FILES "${_current_dir}/MacroCheckPackageLibs.cmake" DESTINATION cmake )
#ENDIF()
Expand All @@ -26,7 +26,7 @@ MACRO( GENERATE_PACKAGE_CONFIGURATION_FILES )
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/cmake/${arg}.in"
"${PROJECT_BINARY_DIR}/${arg}" @ONLY
)
INSTALL( FILES "${PROJECT_BINARY_DIR}/${arg}" DESTINATION . )
INSTALL( FILES "${PROJECT_BINARY_DIR}/${arg}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} )
#IF( EXISTS "${_current_dir}/MacroCheckPackageVersion.cmake" )
# INSTALL( FILES "${_current_dir}/MacroCheckPackageVersion.cmake" DESTINATION cmake )
#ENDIF()
Expand Down
6 changes: 3 additions & 3 deletions sio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ TARGET_INCLUDE_DIRECTORIES( sio PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
TARGET_INCLUDE_DIRECTORIES( sio SYSTEM PUBLIC ${ZLIB_INCLUDE_DIR} )
TARGET_LINK_LIBRARIES( sio ${ZLIB_LIBRARIES} )
INSTALL_SHARED_LIBRARY( sio DESTINATION ${CMAKE_INSTALL_LIBDIR} )
TARGET_LINK_LIBRARIES( sio PUBLIC ZLIB::ZLIB )
INSTALL_SHARED_LIBRARY( sio DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT SIOTargets )
ADD_LIBRARY( SIO::sio ALIAS sio )

# Install the sio headers as well. Necessary for the python bindings and also
# for cases where others want to link against LCIO / this version of SIO
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ ADD_SHARED_LIBRARY( lcio
${LCIO_SIO_SRCS}
${LCIO_MT_SRCS}
)
INSTALL_SHARED_LIBRARY( lcio DESTINATION ${CMAKE_INSTALL_LIBDIR} )
INSTALL_SHARED_LIBRARY( lcio DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT LCIOTargets )

TARGET_LINK_LIBRARIES( lcio ${CMAKE_THREAD_LIBS_INIT} )
TARGET_LINK_LIBRARIES( lcio ${SIO_LIBRARIES} )
jmcarcell marked this conversation as resolved.
Show resolved Hide resolved

ADD_CUSTOM_TARGET( lib DEPENDS lcio )
ADD_LIBRARY( LCIO::lcio ALIAS lcio )
# ----------------------------------------------------------------------------


Expand Down