-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to target based cmake approach for LCIO targets
- Use SIO targets - Define LCIO targets and export them properly for downstream usage - Keep some package specific install variables to keep backwards compatibility
- Loading branch information
Showing
9 changed files
with
107 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,58 @@ | ||
############################################################################## | ||
# cmake configuration file for LCIO | ||
# | ||
# requires: | ||
# MacroCheckPackageLibs.cmake for checking package libraries | ||
# Exported Targets: | ||
# | ||
# returns following variables: | ||
# LCIO::lcio Base LCIO library | ||
# LCIO::lcioF77 Fortran77 bindings library | ||
# SIO::sio The SIO library (ONLY if builtin SIO is used) | ||
# | ||
# LCIO_FOUND : set to TRUE if LCIO found | ||
# if FIND_PACKAGE called with REQUIRED and COMPONENTS arguments | ||
# LCIO_FOUND is only set to TRUE if ALL components are also found | ||
# if REQUIRED is NOT set components may or may not be available | ||
# | ||
# LCIO_ROOT : path to this LCIO installation | ||
# LCIO_VERSION : package version | ||
# Exported Variables: | ||
# The following variables are exported to keep a bit of backward compatibility | ||
# | ||
# LCIO_LIBRARIES : list of LCIO libraries (NOT including COMPONENTS) | ||
# LCIO_INCLUDE_DIRS : list of paths to be used with INCLUDE_DIRECTORIES | ||
# LCIO_LIBRARY_DIRS : list of paths to be used with LINK_DIRECTORIES | ||
# LCIO_COMPONENT_LIBRARIES : list of LCIO component libraries | ||
# LCIO_${COMPONENT}_FOUND : set to TRUE or FALSE for each library | ||
# LCIO_${COMPONENT}_LIBRARY : path to individual libraries | ||
# LCIO_${COMPONENT}_LIB_DEPENDS : individual library dependencies | ||
# LCIO_LIBRARY_DIRS : list of paths to be used with LINK_DIRECTORIES# | ||
# | ||
# @author Jan Engels, Desy | ||
############################################################################## | ||
@PACKAGE_INIT@ | ||
|
||
SET( LCIO_ROOT "@CMAKE_INSTALL_PREFIX@" ) | ||
SET( LCIO_VERSION "@LCIO_VERSION@" ) | ||
|
||
|
||
# ---------- include dirs ----------------------------------------------------- | ||
# do not store find results in cache | ||
SET( LCIO_INCLUDE_DIRS LCIO_INCLUDE_DIRS-NOTFOUND ) | ||
MARK_AS_ADVANCED( LCIO_INCLUDE_DIRS ) | ||
|
||
FIND_PATH( LCIO_INCLUDE_DIRS | ||
NAMES EVENT/MCParticle.h | ||
PATHS ${LCIO_ROOT}/include | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
|
||
set_and_check(LCIO_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") | ||
mark_as_advanced( LCIO_INCLUDE_DIRS ) | ||
|
||
# ---------- libraries -------------------------------------------------------- | ||
INCLUDE( "${LCIO_ROOT}/@CMAKE_INSTALL_LIBDIR@/cmake/MacroCheckPackageLibs.cmake" ) | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(Threads) | ||
|
||
# only standard libraries should be passed as arguments to CHECK_PACKAGE_LIBS | ||
# additional components are set by cmake in variable PKG_FIND_COMPONENTS | ||
# first argument should be the package name | ||
CHECK_PACKAGE_LIBS( LCIO lcio @CHECK_PACKAGE_SIO_LIBRARY@ ) | ||
# Other dependencies depend on the configuration we are using | ||
if(@BUILD_ROOTDICT@) | ||
find_dependency(ROOT @ROOT_VERSION@) | ||
endif() | ||
|
||
if(@SIO_FOUND@) | ||
find_dependency(SIO) | ||
else() | ||
# If we have builtin SIO make the targets available | ||
if(NOT TARGET SIO::sio) | ||
include("${CMAKE_CURRENT_LIST_DIR}/SIOTargets.cmake") | ||
endif() | ||
endif() | ||
|
||
if(NOT TARGET LCIO::lcio) | ||
include("${CMAKE_CURRENT_LIST_DIR}/LCIOTargets.cmake") | ||
endif() | ||
|
||
check_required_components(LCIO) | ||
|
||
# ---------- libraries dependencies ------------------------------------------- | ||
# this sets LCIO_${COMPONENT}_LIB_DEPENDS variables | ||
#INCLUDE( "${LCIO_ROOT}/@CMAKE_INSTALL_LIBDIR@/cmake/LCIOLibDeps.cmake" ) | ||
|
||
|
||
|
||
## ------- zlib dependency --------------------------------------- | ||
# better to install zlib together with lcio libraries | ||
#FIND_PACKAGE( ZLIB QUIET ) | ||
#SET( LCIO_DEPENDS_LIBRARIES ${ZLIB_LIBRARIES} ) | ||
#INCLUDE( "@ILCSOFT_CMAKE_MODULES_ROOT@/MacroExportPackageDeps.cmake" ) | ||
#EXPORT_PACKAGE_DEPENDENCIES( LCIO ) # append ZLIB_LIBRARIES to LCIO_LIBRARIES unless FIND_PACKAGE_SKIP_DEPENDENCIES is set | ||
## --------------------------------------------------------------- | ||
|
||
|
||
|
||
# Make the target based approach backwards compatible by also exporting | ||
# something in LCIO_LIBRARIES | ||
get_target_property(LCIO_LIBRARY_DIRS TARGET LCIO::lcio PROPERTY LOCATION) | ||
set(LCIO_LIBRARIES LCIO::lcio) | ||
mark_as_advanced(LCIO_LIBRARIES LCIO_LIBRARY_DIRS) | ||
|
||
# ---------- final checking --------------------------------------------------- | ||
INCLUDE( FindPackageHandleStandardArgs ) | ||
# set LCIO_FOUND to TRUE if all listed variables are TRUE and not empty | ||
# LCIO_COMPONENT_VARIABLES will be set if FIND_PACKAGE is called with REQUIRED argument | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS( LCIO DEFAULT_MSG LCIO_ROOT LCIO_INCLUDE_DIRS LCIO_LIBRARIES ${LCIO_COMPONENT_VARIABLES} ) #ZLIB_LIBRARIES ) | ||
|
||
FIND_PACKAGE_HANDLE_STANDARD_ARGS( LCIO DEFAULT_MSG LCIO_INCLUDE_DIRS LCIO_LIBRARIES ${LCIO_COMPONENT_VARIABLES} ) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake") | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
# Write a version file | ||
write_basic_package_version_file( | ||
${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
VERSION ${LCIO_VERSION} | ||
# LCIO is fully backwards compatible, so any newer version should work | ||
COMPATIBILITY AnyNewerVersion) | ||
|
||
if(NOT SIO_FOUND) | ||
# Install the SIOTargets similarly to the standalone version to make it easy | ||
# to use them via the SIO::sio target in dependent projects | ||
install(EXPORT SIOTargets | ||
NAMESPACE SIO:: | ||
FILE SIOTargets.cmake | ||
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME}) | ||
endif() | ||
|
||
# Export the LCIO targets | ||
install(EXPORT LCIOTargets | ||
NAMESPACE LCIO:: | ||
FILE LCIOTargets.cmake | ||
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME}) | ||
|
||
# Build the package config file | ||
configure_package_config_file( | ||
${PROJECT_SOURCE_DIR}/cmake/LCIOConfig.cmake.in | ||
${PROJECT_BINARY_DIR}/cmake/LCIOConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME} | ||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR) | ||
|
||
|
||
# # install all the necessary config files | ||
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LCIOConfigVersion.cmake | ||
# INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_NAME} | ||
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters