# ICEDUST_CREATE_SETUP_SCRIPT # ------------------------------ # # Macro to create the setup.sh scripts to set up environment variables # # Usage # ^^^^^ # #---ICEDUST_CREATE_SETUP_SCRIPT( # TYPE build [install]) # # TYPE specifies if setup.sh is created at CURRENT_BINARY_DIR or CMAKE_INSTALL_PREFIX # # Output # ^^^^^^ # # Creates: # setup.sh # at: CMAKE_INSTALL_PREFIX # BUILD_setup.sh # at: CURRENT_BINARY_DIR # # # manager COMET Software Group # author andreas.jansen@tu-dresden.de function(ICEDUST_CREATE_SETUP_SCRIPT) CMAKE_PARSE_ARGUMENTS(ARG "" "TYPE" "" ${ARGN}) # --- Warn if we have unused arguments ------------------ if(ARG_UNPARSED_ARGUMENTS) message(WARNING "Unknown / Unparsed Arguments: ${ARG_UNPARSED_ARGUMENTS}") endif() # --- Check TYPE, has to be "build" or "install" if(NOT ARG_TYPE) message(WARNING "ICEDUST_CREATE_SETUP_SCRIPT: Not existing TYPE argument (build/install). \ -- Return from ICEDUST_CREATE_SETUP_SCRIPT without creating setup.sh!") return() endif() string(TOLOWER "${ARG_TYPE}" ARG_TYPE_LOWER) if(${ARG_TYPE_LOWER} STREQUAL "build") set(INSTALL_OR_BUILD_PATH ${CMAKE_BINARY_DIR}) set(SETUP_FILE ${CMAKE_BINARY_DIR}/BUILD_setup.sh) elseif(${ARG_TYPE_LOWER} STREQUAL "install") set(INSTALL_OR_BUILD_PATH ${CMAKE_INSTALL_PREFIX}) set(SETUP_FILE ${CMAKE_INSTALL_PREFIX}/setup.sh) else() message(WARNING "ICEDUST_CREATE_SETUP_SCRIPT: Unknown TYPE argument: ${ARG_TYPE} \ -- Return from ICEDUST_CREATE_SETUP_SCRIPT without creating setup.sh!") return() endif() set(ICEDUST_PACKAGES AnalysisBase CalibECAL CalibGlobal CalibMagnet CalibOffline #cometAnalysis #cometBase #cometCalib #cometExternals #cometRecon #cometSim #cometTools DisplayCore IcedustControl #IcedustDoc #IcedustExternal #IcedustPolicy #IcedustTest IcedustValidate #IcedustVerify #monitor oaAlignTools oaAnalysis oaApplyAlign oaBeamData oaCalibReconBase oaCalibTables oaChanInfo oaCherryPicker oaControlSample oaDataQuality oaEMField oaEvent oaGeomInfo oaOfflineDatabase oaRawEvent oaRooTracker oaRuntimeParameters oaSlowControlDatabase oaUnpack oaUtility ReconCyDet ReconECAL ReconGlobal ReconStrawTrk ReconTools ReconTrackFinding ReconTrackFitting SimCosmicTrigger SimDetectorResponse SimFLUKA SimG4 SimHitMerger SimMARS SimPHITS SimBackwardMC ) # --- Create file + header file(WRITE ${SETUP_FILE} "\n#-----------------------------------------------------------------------\n") file(APPEND ${SETUP_FILE} "# Bourne shell environment setup script for ICEDUST \n") file(APPEND ${SETUP_FILE} "# This script will configure your environment for use with ICEDUST. \n") file(APPEND ${SETUP_FILE} "# \n") file(APPEND ${SETUP_FILE} "# a) Created/build ICEDUST packages are available under ROOT.\n") file(APPEND ${SETUP_FILE} "# b) ICEDUSTROOT, ICEDUSTINSTALLPATH and ICEDUST_CMAKE_BUILD are set up \n") file(APPEND ${SETUP_FILE} "# c) ICEDUST_SYMLINKS is added to PATH \n") file(APPEND ${SETUP_FILE} "# d) Set up of environment for Garfield: GARFIELD_HOME, HEED_DATABASE \n") file(APPEND ${SETUP_FILE} "# e) Set up of environment for Python: PYTHON_PATH added to PATH \n") file(APPEND ${SETUP_FILE} "# f) Set up of the environment for ROOT by sourcing 'thisroot.sh' and 'setxrd.sh' \n") file(APPEND ${SETUP_FILE} "# g) Set up of the environment for Geant4 by sourcing 'geant4.sh' \n") file(APPEND ${SETUP_FILE} "# h) Set up special package-related environment variables\n") file(APPEND ${SETUP_FILE} "# \n") file(APPEND ${SETUP_FILE} "# !!! This script is autogenerated by CMake - DO NOT EDIT !!! \n") file(APPEND ${SETUP_FILE} "# Further information: '../ICEDUST_packages/cmake/Modules/IcedustCreateSetupScript.cmake \n") file(APPEND ${SETUP_FILE} "#-----------------------------------------------------------------------\n\n") # Geant4 environment, use geant4.sh script provided by Geant4 file(APPEND ${SETUP_FILE} "# Set up environment for Geant4\n") file(APPEND ${SETUP_FILE} "# As G4 appends PATH everytime this script is called we remove the old PATH beforehand manually\n") file(APPEND ${SETUP_FILE} "PATH=$(echo :$PATH: | sed -e 's,:${GEANT4_ROOT}/bin:,:,g' -e 's/^://' -e 's/:$//')\n") file(APPEND ${SETUP_FILE} "source ${GEANT4_ROOT}/bin/geant4.sh\n") file(APPEND ${SETUP_FILE} "export G4UI_USE_TCSH=1\n\n") # ROOT environment, use thisroot.sh script provided by ROOT file(APPEND ${SETUP_FILE} "# Set up environment for ROOT\n") file(APPEND ${SETUP_FILE} "source ${ROOT_ROOT}/bin/thisroot.sh\n\n") # XROOTD environment required for use with ROOT5 if build external, use setxrd.sh script provided by ROOT if(XROOTD_FOUND) file(APPEND ${SETUP_FILE} "# Set up environment for XROOTD\n") file(APPEND ${SETUP_FILE} "source ${ROOT_ROOT}/bin/setxrd.sh ${XROOTD_ROOT}\n\n") endif() # Garfield environment, manually set up HEED_DATABASE and GARFIELD_HOME file(APPEND ${SETUP_FILE} "# Set up environment for Garfield\n") file(APPEND ${SETUP_FILE} "export GARFIELD_HOME=${GARFIELD_HOME}\n") file(APPEND ${SETUP_FILE} "export HEED_DATABASE=${GARFIELD_HEED_DATABASE}\n\n") # PYTHON environment to make sure we use our compiled python 2.7.15 file(APPEND ${SETUP_FILE} "# As PYTHON path appends PATH everytime this script is called we remove the old PATH beforehand manually\n") file(APPEND ${SETUP_FILE} "PATH=$(echo :$PATH: | sed -e 's,:${PYTHON_ROOT}/bin:,:,g' -e 's/^://' -e 's/:$//')\n") file(APPEND ${SETUP_FILE} "export PATH=${PYTHON_ROOT}/bin:$PATH\n\n") # General ICEDUST environment: ICEDUSTROOT, ICEDUSTINSTALLPATH and ICEDUST_CMAKE_BUILD file(APPEND ${SETUP_FILE} "# Set up environment for ICEDUST\n") get_filename_component(ICEDUSTROOT ${CMAKE_SOURCE_DIR}/../ ABSOLUTE) file(APPEND ${SETUP_FILE} "export ICEDUSTROOT=${ICEDUSTROOT}\n") file(APPEND ${SETUP_FILE} "export ICEDUSTINSTALLPATH=${CMAKE_INSTALL_PREFIX}\n") file(APPEND ${SETUP_FILE} "export ICEDUST_CMAKE_BUILD=1\n\n") # --- Add ICEDUST_SYMLINKS directory to PATH file(APPEND ${SETUP_FILE} "# Add symlink directory to PATH environment\n") file(APPEND ${SETUP_FILE} "# -----------------------------------------\n") file(APPEND ${SETUP_FILE} "# Remove old paths and append new location\n") # Remove old Paths file(APPEND ${SETUP_FILE} "PATH=$(echo :$PATH: | sed -e 's,:${SYMLINK_INSTALL_OUTPUT_FOLDER}:,:,g' -e 's/^://' -e 's/:$//')\n") file(APPEND ${SETUP_FILE} "PATH=$(echo :$PATH: | sed -e 's,:${SYMLINK_BUILD_OUTPUT_FOLDER}:,:,g' -e 's/^://' -e 's/:$//')\n") if(${ARG_TYPE_LOWER} STREQUAL "build") file(APPEND ${SETUP_FILE} "export PATH=$PATH:${SYMLINK_BUILD_OUTPUT_FOLDER}\n\n") elseif(${ARG_TYPE_LOWER} STREQUAL "install") file(APPEND ${SETUP_FILE} "export PATH=$PATH:${SYMLINK_INSTALL_OUTPUT_FOLDER}\n\n") endif() # --- Write ROOT environment variables file(APPEND ${SETUP_FILE} "# Write ROOT environment variables\n") file(APPEND ${SETUP_FILE} "# -----------------------------------------\n") foreach(PACKAGE ${ICEDUST_PACKAGES}) if(TARGET ${PACKAGE}) string(TOUPPER "${PACKAGE}" PACKAGE_UPPER) file(APPEND ${SETUP_FILE} "export ${PACKAGE_UPPER}ROOT=${INSTALL_OR_BUILD_PATH}/${PACKAGE}\n") else() file(APPEND ${SETUP_FILE} "# ${PACKAGE} not build in this project\n") endif() endforeach() # --- Write "special" environment variables file(APPEND ${SETUP_FILE} "\n# Write 'special' environment variables\n") file(APPEND ${SETUP_FILE} "# -----------------------------------------\n") # Special Env-Vars for oaEvent if (TARGET oaEvent) # Note: OAEVENTCONFIG HAS TO be set for IOADatabase or we will get Seg-Fault errors in our Tests! # This is duo to the gSystem->Getenv("OAEVENTCONFIG") call wich fails to NULL-check... ROOT... *sigh* # >> In CMT this was set to a path where all executables AND also the GEOMETRY.LIST file # (after executing /oaEvent/scripts/comet-get-geometry) was located. # >> In CMAKE I set this to the "scripts" directory of oaEvent where only GEOMETRY.LIST is located. # This file is requiered for our test to be executed. I hope we do not use this environment var to also # find the executables at one point because this will cause problems -- TODO / FIXME? file(APPEND ${SETUP_FILE} "export OAEVENTCONFIG=scripts\n") endif() # Special Env-Vars for SimHitMerger if (TARGET SimHitMerger) file(APPEND ${SETUP_FILE} "export SIMHITMERGERCONFIG=test\n") endif() # Special Env-Vars for IcedustControl # as it has no target to be build we just look in the list above if we want to build it atm... if ("IcedustControl" IN_LIST ICEDUST_PACKAGES) file(APPEND ${SETUP_FILE} "export ICEDUSTCONTROLROOT=${INSTALL_OR_BUILD_PATH}/IcedustControl\n") file(APPEND ${SETUP_FILE} "export PYTHONPATH=${INSTALL_OR_BUILD_PATH}/SimCDCGAN/src:${INSTALL_OR_BUILD_PATH}/IcedustControl/modules_cmake:$PYTHONPATH\n") endif() # Similarly for IcedustValidate if ("IcedustValidate" IN_LIST ICEDUST_PACKAGES) file(APPEND ${SETUP_FILE} "export ICEDUSTVALIDATEROOT=${INSTALL_OR_BUILD_PATH}/IcedustValidate\n") endif() # Special Env-Vars for SimG4 (and oaGeomInfo) if (TARGET SimG4) # Note: SIMG4CONFIG HAS TO be set for oaGeomInfo tests as we require the macros inside (e.g. SimG4-defaults-1.0.mac, etc) # >> In CMT this was set to a path where all executables AND also the macros were located. # >> In CMAKE I set this to the (copied) "src" directory of SimG4 where only those macros are located. # I hope we do not use this environment var to also find the executables at one point because this will cause problems # -- TODO / FIXME? file(APPEND ${SETUP_FILE} "export SIMG4CONFIG=src\n") endif() # Special Env-Vars for RunDisplayCore if (TARGET DisplayCore) file(APPEND ${SETUP_FILE} "export BROWSER_COMMAND=htmlview\n") file(APPEND ${SETUP_FILE} "export WIN32='C:/Program Files/Internet Explorer/iexplore.exe'\n") file(APPEND ${SETUP_FILE} "export OSX=open\n") endif() endfunction()