Back to home page

EIC code displayed by LXR

 
 

    


Warning, /DD4hep/cmake/DD4hep.cmake is written in an unsupported language. File is not indexed.

0001 #=================================================================================
0002 #
0003 #  AIDA Detector description implementation 
0004 #---------------------------------------------------------------------------------
0005 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0006 # All rights reserved.
0007 #
0008 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0009 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0010 #
0011 #=================================================================================
0012 
0013 #---------------------------------------------------------------------------------------------------
0014 if ( DD4hep_DIR )
0015   set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_DIR}/cmake ) 
0016 endif()
0017 if(CMAKE_INSTALL_PREFIX)
0018   set ( CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} )
0019 endif()
0020 
0021 #---------------------------------------------------------------------------------------------------
0022 # Main functional include file
0023 if (NOT DD4hepBuild_included)
0024   include ( DD4hepBuild )
0025 endif()
0026 
0027 ##---------------------------------------------------------------------------------------------------
0028 ##
0029 ##  OLDER STUFF: To be kept for backwards compatibility ....
0030 ##
0031 #---------------------------------------------------------------------------------------------------
0032 # add_dd4hep_plugin ( libraryName )
0033 #
0034 # generates the rootmap and installs the library
0035 # all other arguments ( SHARED, ${sources} ) are collected in ${ARGN}
0036 #---------------------------------------------------------------------------------------------------
0037 
0038 function( add_dd4hep_plugin libraryName )
0039   ADD_LIBRARY ( ${libraryName}  ${ARGN} )
0040   dd4hep_generate_rootmap( ${libraryName} )
0041   install( TARGETS ${libraryName} LIBRARY DESTINATION lib )
0042 endfunction()
0043 
0044 #---------------------------------------------------------------------------------------------------
0045 # dd4hep_instantiate_package
0046 # calls all the function/includes/configurations that are needed to be done to create dd4hep plugins
0047 #---------------------------------------------------------------------------------------------------
0048 function ( dd4hep_instantiate_package PackageName )
0049   MESSAGE (STATUS "Instantiating the DD4hep package ${PackageName}" )
0050 
0051   IF ( NOT ${DD4hep_FOUND} )
0052     MESSAGE ( FATAL "DD4HEP was not found" )
0053   ENDIF()
0054 
0055   INCLUDE( DD4hepMacros )
0056 
0057   #---- configure run environment ---------------
0058   set(DD4HEP_INSTALL_LIBDIR lib)
0059   if(CMAKE_INSTALL_LIBDIR)
0060     set(DD4HEP_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
0061   endif()
0062 
0063   configure_file( ${DD4hep_DIR}/cmake/thisdd4hep_package.sh.in  this${PackageName}.sh @ONLY)
0064   unset(DD4HEP_INSTALL_LIBDIR)
0065 
0066   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/this${PackageName}.sh
0067     DESTINATION bin
0068     )
0069 
0070 
0071 endfunction()
0072 #---------------------------------------------------------------------------------------------------
0073 # dd4hep_generate_rootmap(library)
0074 #
0075 # Create the .components file needed by the plug-in system.
0076 #---------------------------------------------------------------------------------------------------
0077 function(dd4hep_generate_rootmap library)
0078 
0079   if(APPLE)
0080     set(ENV_VAR DYLD_LIBRARY_PATH)
0081   else()
0082     set(ENV_VAR LD_LIBRARY_PATH)
0083   endif()
0084 
0085   set(DD4HEP_${ENV_VAR} "$ENV{${ENV_VAR}}"
0086     CACHE STRING
0087     "Set ${ENV_VAR} when adding DD4hep plugins"
0088   )
0089   set(DD4HEP_ROOT_LIBRARY_PATH "$ENV{ROOT_LIBRARY_PATH}"
0090     CACHE STRING
0091     "Set ROOT_LIBRARY_PATH when adding DD4hep plugins"
0092   )
0093 
0094   string(JOIN ":" _ld_path
0095     "$<TARGET_FILE_DIR:${library}>"
0096     "$<TARGET_FILE_DIR:DD4hep::DD4hepGaudiPluginMgr>"
0097     "${DD4HEP_${ENV_VAR}}"
0098   )
0099   set(rootmapfile ${CMAKE_SHARED_MODULE_PREFIX}${library}.components)
0100 
0101   add_custom_command(OUTPUT ${rootmapfile}
0102                      DEPENDS ${library}
0103                      VERBATIM COMMAND
0104                      "${CMAKE_COMMAND}" -E env
0105                      "${ENV_VAR}=${_ld_path}"
0106                      "ROOT_LIBRARY_PATH=${DD4HEP_ROOT_LIBRARY_PATH}"
0107                      $<TARGET_FILE:DD4hep::listcomponents> -o ${rootmapfile} $<TARGET_FILE_NAME:${library}>
0108                      WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
0109                      )
0110 
0111   add_custom_target(Components_${library} ALL DEPENDS ${rootmapfile})
0112   SET( install_destination "lib" )
0113   if( CMAKE_INSTALL_LIBDIR )
0114     SET( install_destination ${CMAKE_INSTALL_LIBDIR} )
0115   endif()
0116   install(FILES $<TARGET_FILE_DIR:${library}>/${rootmapfile}
0117     DESTINATION ${install_destination}
0118   )
0119 endfunction()