diff --git a/CMakeLists.txt b/CMakeLists.txt index d4b40e9d1fcd0ad347d8485e151fd49c837488db..387d48db4f8e642d2f761a4e43cbb29d2dcb095a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,11 @@ add_subdirectory(DDCore) if(DD4HEP_WITH_GEANT4) add_subdirectory(DDG4) add_subdirectory(DDSense) + + #--- create a geant4 variables for the thisdd4hep.sh script + find_package( Geant4 ) + get_filename_component(Geant4_ROOT "${Geant4_INCLUDE_DIR}/../../" ABSOLUTE) + endif() add_subdirectory(UtilityApps) diff --git a/ReadMe.txt b/ReadMe.txt index 5737a64fedd164a8749c4af003aec6ee2edba099..0857be8ae8e09167025175e1683c78d1e9e2239b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -68,6 +68,9 @@ To build and run the simulation examples Geant4 will be required. source /data/ilcsoft/root/5.34.03/bin/thisroot.sh + ( minimum is: export ROOTSYS=/data/ilcsoft/root/5.34.03 ) + + - configure and build: cd DD4hep @@ -101,30 +104,15 @@ To build and run the simulation examples Geant4 will be required. -DDD4HEP_USE_PYROOT=ON - - - - -- Setup the running environment - -. thisdd4hep.sh +- Setup the environment for running + + . ./bin/thisdd4hep.sh or -source thisdd4hep.csh +source ./bin/thisdd4hep.csh -### now call make ########### -make -j4 -- Run ILDEx display - -DDExamples/ILDExDisplay/ILDExDisplay file:../DD4hep/DDExamples/ILDExDet/compact/ILDEx.xml - -- Run CLICSiD display - -DDExamples/CLICSiD/CLICSiDtest file:../DD4hep/DDExamples/CLICSiD/compact/compact.xml - - 3) Extending ------------ @@ -143,11 +131,8 @@ DDExamples/CLICSiD/CLICSiDtest file:../DD4hep/DDExamples/CLICSiD/compact/compact Before any of the (new) examples in the ./examples directory can be build, one needs to set the environment: - source __path_where_ROOT_is_installed___/bin/thisroot.sh source __path_where_DD4hep_is_installed_/bin/thisdd4hep.sh - [note: possible other scripts need to be called, e.g. when using geant4 - see above ] - - then building the examples should be very straight forward. e.g: (check for additional instructions in example subdirectory) @@ -157,8 +142,9 @@ one needs to set the environment: cmake .. make -j install -- before running the example, again the (DY)LD_LIBRARY_PATH has to be updated: - export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$PWD/../lib +- before running the example, initialize the environment: + . ./bin/thisILDExDet.sh + - then you can for example display the ILD detector (toy model): @@ -172,8 +158,6 @@ one needs to set the environment: 6) run SLIC simulation on lccd file created with DD4Hep: -# create lcdd file from compact: -./bin/geoConverter -compact2lcdd -input file:../DD4hep/DDExamples/ILDExDet/compact/ILDEx.xml -output ILD_toy.lcdd # make sure slic is in the path and then: slic -g ./ILD_toy.lcdd -o ILD_toy.slcio -x -m ../DD4hep/DDExamples/ILDExSimu/run1.mac diff --git a/cmake/DD4hep.cmake b/cmake/DD4hep.cmake index 46328b4d14b3c4268c59d8a8a3514415b12b7c8a..540a305dd11d6738c062821bec4056c380ca6762 100644 --- a/cmake/DD4hep.cmake +++ b/cmake/DD4hep.cmake @@ -5,19 +5,40 @@ #--------------------------------------------------------------------------------------------------- function(dd4hep_generate_rootmap library) find_package(ROOT QUIET) + find_package(DD4hep QUIET) + set(rootmapfile ${CMAKE_SHARED_MODULE_PREFIX}${library}.rootmap) set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_LIBRARY_SUFFIX}) + + +#--------------------------------------------------------------------------------------- +if( DD4hep_FOUND ) + # we are building an external tool and need to source ${DD4hep_ROOT}/bin/thisdd4hep.sh + + add_custom_command(OUTPUT ${rootmapfile} + COMMAND cd ${LIBRARY_OUTPUT_PATH} && + . ${DD4hep_ROOT}/bin/thisdd4hep.sh && + genmap ${ROOT_genmap_CMD} -i ${libname} -o ${rootmapfile} + DEPENDS ${library}) + +else() # we are building DD4hep itself - only need thisroot.sh + add_custom_command(OUTPUT ${rootmapfile} - COMMAND ${CMAKE_COMMAND} -Dlibname=${libname} -Drootmapfile=${rootmapfile} - -Dgenmap_install_dir=${LIBRARY_OUTPUT_PATH} - -P ${CMAKE_SOURCE_DIR}/cmake/MakeRootMap.cmake - DEPENDS ${library}) - add_custom_target(${library}Rootmap ALL DEPENDS ${rootmapfile}) - - install(FILES ${LIBRARY_OUTPUT_PATH}/${rootmapfile} - DESTINATION lib + COMMAND cd ${LIBRARY_OUTPUT_PATH} && + . ${ROOT_ROOT}/bin/thisroot.sh && + genmap ${ROOT_genmap_CMD} -i ${libname} -o ${rootmapfile} + DEPENDS ${library}) +endif() + + +add_custom_target(${library}Rootmap ALL DEPENDS ${rootmapfile}) + +install(FILES ${LIBRARY_OUTPUT_PATH}/${rootmapfile} + DESTINATION lib ) +#-------------------------------------------------------------------------------------- + # Notify the project level target #gaudi_merge_files_append(Rootmap ${library}Rootmap ${CMAKE_CURRENT_BINARY_DIR}/${library}.rootmap) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 4b361539d59ebd31f283438eb7cf991f8d90378d..818f9cf2140642db9cdca6393526832807803afd 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -2,6 +2,7 @@ # This module sets up ROOT information # It defines: # ROOT_FOUND If the ROOT is found +# ROOT_ROOT the root directory ($ROOTSYS) # ROOT_INCLUDE_DIR PATH to the include directory # ROOT_LIBRARIES Most common libraries # ROOT_LIBRARY_DIR PATH to the library directory @@ -33,6 +34,8 @@ if(ROOT_CONFIG_EXECUTABLE) set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) + set(ROOT_ROOT ${ROOTSYS}) + # Make variables changeble to the advanced user mark_as_advanced(ROOT_CONFIG_EXECUTABLE) diff --git a/cmake/thisdd4hep.sh b/cmake/thisdd4hep.sh index 56628e5b9d971521f0f9c545fadfd36ea978661f..f9cda1946812c2b696b3974bb30fb9c1fd5e5583 100644 --- a/cmake/thisdd4hep.sh +++ b/cmake/thisdd4hep.sh @@ -16,6 +16,19 @@ else THIS=$(dirname ${BASH_ARGV[0]}) fi + +#----------- source the ROOT environment first +source @ROOT_ROOT@/bin/thisroot.sh + +if [ @DD4hep_WITH_GEANT4@ ] +then + export G4INSTALL=@Geant4_ROOT@/../../ + export G4ENV_INIT=@Geant4_ROOT@/../../bin/geant4.sh +# export G4SYSTEM="Darwin-g++" + test -r ${G4ENV_INIT} && { cd $(dirname ${G4ENV_INIT}) ; . ./$(basename ${G4ENV_INIT}) ; cd $OLDPWD ; } +fi + + #----PATH----------------------------------------------------------------- if [ -z "${PATH}" ]; then PATH=@CMAKE_INSTALL_PREFIX@/bin; export PATH # Linux, ELF HP-UX @@ -25,16 +38,16 @@ fi #----LD_LIBRARY_PATH----------------------------------------------------------------- if [ -z "${LD_LIBRARY_PATH}" ]; then - LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@ROOT_LIBRARY_DIR@:@Geant4_DIR@/..; export LD_LIBRARY_PATH # Linux, ELF HP-UX + LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@Geant4_DIR@/..; export LD_LIBRARY_PATH # Linux, ELF HP-UX else - LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@ROOT_LIBRARY_DIR@:@Geant4_DIR@/..:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH + LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@Geant4_DIR@/..:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH fi #----DYLD_LIBRARY_PATH--------------------------------------------------------------- if [ -z "${DYLD_LIBRARY_PATH}" ]; then - DYLD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@ROOT_LIBRARY_DIR@; export DYLD_LIBRARY_PATH # Mac OS X + DYLD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib; export DYLD_LIBRARY_PATH # Mac OS X else - DYLD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:@ROOT_LIBRARY_DIR@:$DYLD_LIBRARY_PATH; export DYLD_LIBRARY_PATH + DYLD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:@XERCESC_ROOT_DIR@/lib:$DYLD_LIBRARY_PATH; export DYLD_LIBRARY_PATH fi #----PYTHONPATH--------------------------------------------------------------- diff --git a/cmake/thisdd4hep_package.sh.in b/cmake/thisdd4hep_package.sh.in new file mode 100644 index 0000000000000000000000000000000000000000..69ffbf2767265cc304ee07201d943e0f8908d486 --- /dev/null +++ b/cmake/thisdd4hep_package.sh.in @@ -0,0 +1,19 @@ +################################################################################# +# +# environment script for DD4hep examples - initializes DD4hep (and ROOT) as well +# +# @author F.Gaede, DESY, 2013 +# +################################################################################# + + +source @DD4hep_ROOT@/bin/thisDD4hep.sh + +export PATH=$PATH:@CMAKE_INSTALL_PREFIX@/bin + +if [ @APPLE@ ] +then + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/lib +else + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/lib +fi \ No newline at end of file diff --git a/examples/ILDExDet/CMakeLists.txt b/examples/ILDExDet/CMakeLists.txt index ea17e196d70c9f05aa0493b9c72b77e7ce3e740e..4ac7caa3b0b6eb62c9c1cf8c1ef422d2e93ca338 100644 --- a/examples/ILDExDet/CMakeLists.txt +++ b/examples/ILDExDet/CMakeLists.txt @@ -69,6 +69,15 @@ target_link_libraries(${PackageName} ${DD4hep_LIBRARIES} ${ROOT_LIBRARIES} ${RO dd4hep_generate_rootmap(${PackageName} ) + +#---- configure run environment --------------- +configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) + +install(FILES ${CMAKE_BINARY_DIR}/this${PackageName}.sh + DESTINATION bin + ) + + #--- install target------------------------------------- install(TARGETS ${PackageName} diff --git a/examples/ILDExSimu/CMakeLists.txt b/examples/ILDExSimu/CMakeLists.txt index 7e8f1cc99c355f04091d72c56310784860f6facc..f67bb30d4488aca5b2a7d2c221b694913a349559 100644 --- a/examples/ILDExSimu/CMakeLists.txt +++ b/examples/ILDExSimu/CMakeLists.txt @@ -93,6 +93,14 @@ target_link_libraries(${PackageName} ${DD4hep_LIBRARIES} # fg: not needed here #dd4hep_generate_rootmap(${PackageName} ) +#---- configure run environment --------------- +configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) + +install(FILES ${CMAKE_BINARY_DIR}/this${PackageName}.sh + DESTINATION bin + ) + + #--- install target------------------------------------- install(TARGETS ${PackageName}