From d0e8d3e8e538b4f4601dff1b3d6bdfd2a170cfc7 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Thu, 17 Jul 2014 09:47:42 +0000 Subject: [PATCH] Unify cmake option variables, small cmake corrections Change options _WITH_ to _USE_ Print Warning that variables with _WITH_ are deprecated Change Defintions to _USE_ as well Add REQUIRED to find_package geant4 and xercesc if they are turned on Updated documentation Updated ILDExDet example --- CMakeLists.txt | 40 ++++++++++++++++++++------ DDRec/CMakeLists.txt | 10 +++---- DDTest/CMakeLists.txt | 4 +-- ReadMe.txt | 8 +++--- cmake/DD4hepConfig.cmake.in | 6 ++-- cmake/thisdd4hep.sh | 4 +-- doc/build.sh | 2 +- doc/cmake.cmds | 8 +++--- examples/ILDExDet/CMakeLists.txt | 4 +-- examples/ILDExDet/src/ILDExSIT_geo.cpp | 6 ++-- examples/ILDExDet/src/ILDExTPC_geo.cpp | 4 +-- examples/ILDExDet/src/ILDExVXD_geo.cpp | 6 ++-- examples/noviceN04/README | 2 +- 13 files changed, 63 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 498eec13b..8152ced1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,11 +24,23 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) #---Options------------------------------------------------------------------------- + +#For backward compatibility for now +IF( DEFINED DD4HEP_WITH_GEANT4 ) + SET ( DD4HEP_USE_GEANT4 ${DD4HEP_WITH_GEANT4} ) +ENDIF() + +IF( DEFINED DD4HEP_WITH_GEAR ) + SET ( DD4HEP_USE_GEAR ${DD4HEP_WITH_GEAR} ) +ENDIF() + + + option(DD4HEP_USE_XERCESC "Enable 'Detector Builders' based on XercesC" OFF) option(DD4HEP_USE_PYROOT "Enable 'Detector Builders' based on PyROOT" OFF) # does not work (compile error) -option(DD4HEP_WITH_GEANT4 "Enable the simulation part based on Geant4" OFF) - -option(DD4HEP_WITH_GEAR "Build gear wrapper for backward compatibility" OFF) +option(DD4HEP_USE_GEANT4 "Enable the simulation part based on Geant4" OFF) +option(DD4HEP_USE_GEAR "Build gear wrapper for backward compatibility" OFF) +option(DD4HEP_USE_LCIO "Build lcio extensions" OFF) #--------------------------------------------------------------------------------------- @@ -43,8 +55,9 @@ include( DD4hepMacros ) #----------------------------- find_package(ROOT REQUIRED) + if(DD4HEP_USE_XERCESC) - find_package(XercesC) + find_package(XercesC REQUIRED) endif() #---Testing------------------------------------------------------------------------- @@ -81,11 +94,11 @@ add_subdirectory(DDSurfaces) add_subdirectory(DDRec) add_subdirectory(DDSense) -if(DD4HEP_WITH_GEANT4) +if(DD4HEP_USE_GEANT4) add_subdirectory(DDG4) #--- create a geant4 variables for the thisdd4hep.sh script - find_package( Geant4 ) + find_package( Geant4 REQUIRED ) get_filename_component(Geant4_ROOT "${Geant4_INCLUDE_DIR}/../../" ABSOLUTE) #----- if geant4 is build with external CLHEP we also need to export this fact @@ -94,7 +107,7 @@ if(DD4HEP_WITH_GEANT4) if( NOT "${CLHEP_POS}" STREQUAL "-1" ) - set( GEANT4_WITH_CLHEP 1 ) + set( GEANT4_USE_CLHEP 1 ) #---- use FindCLHEP shipped with geant4 ----------- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${Geant4_ROOT}/cmake/Modules ) @@ -103,13 +116,13 @@ if(DD4HEP_WITH_GEANT4) set( CLHEP_ROOT_DIR ${CLHEP_DIR} ) endif() - find_package( CLHEP REQUIRED) + find_package( CLHEP REQUIRED ) get_filename_component(CLHEP_LIBRARY_PATH "${CLHEP_LIBRARIES}" PATH) message( STATUS " *** geant4 was build with external CLHEP *** CLHEP_LIBRARY_PATH = ${CLHEP_LIBRARY_PATH}" ) else() - set( GEANT4_WITH_CLHEP 0 ) + set( GEANT4_USE_CLHEP 0 ) endif() endif() @@ -139,6 +152,15 @@ install(PROGRAMS ${CMAKE_BINARY_DIR}/run_test.sh #----------------------------------------------------------------------------------- display_std_variables() +IF( DEFINED DD4HEP_WITH_GEANT4) + MESSAGE ( WARNING "DD4HEP_WITH_GEANT4 is deprecated use DD4HEP_USE_GEANT4") +ENDIF() + +IF( DEFINED DD4HEP_WITH_GEAR ) + MESSAGE (WARNING "DD4HEP_WITH_GEAR is deprecated use DD4HEP_USE_GEAR") +ENDIF() + + ############################################################################## # generate and install following configuration files diff --git a/DDRec/CMakeLists.txt b/DDRec/CMakeLists.txt index e8dc9e11c..a04d2005a 100644 --- a/DDRec/CMakeLists.txt +++ b/DDRec/CMakeLists.txt @@ -11,7 +11,7 @@ file(GLOB sources src/*.cpp) #--------------------------- GEAR wrappers for backward compatibility ----------- -if(DD4HEP_WITH_GEAR) +if(DD4HEP_USE_GEAR) find_package(GEAR REQUIRED COMPONENTS geartgeo) @@ -19,14 +19,14 @@ if(DD4HEP_WITH_GEAR) set(sources ${sources} src/gear/DDGear.cpp) - add_definitions("-D DD4HEP_WITH_GEAR") + add_definitions("-D DD4HEP_USE_GEAR") endif() #------------------------------------------------------------------------------------- add_library(DD4hepRec SHARED ${sources} ) -if(DD4HEP_WITH_GEAR) +if(DD4HEP_USE_GEAR) target_link_libraries(DD4hepRec ${ROOT_LIBRARIES} ${DDSegmentation_LIBRARIES} DD4hepCore Geom Reflex ${libraries} ${GEAR_LIBRARIES} ${GEAR_COMPONENT_LIBRARIES}) #------ binary ---------- @@ -40,7 +40,7 @@ if(DD4HEP_WITH_GEAR) else() target_link_libraries(DD4hepRec ${ROOT_LIBRARIES} ${DDSegmentation_LIBRARIES} DD4hepCore Geom Reflex ${libraries}) -endif(DD4HEP_WITH_GEAR) +endif(DD4HEP_USE_GEAR) SET(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") @@ -51,7 +51,7 @@ install(DIRECTORY include/DDRec DESTINATION include PATTERN ".svn" EXCLUDE ) -if(DD4HEP_WITH_GEAR) +if(DD4HEP_USE_GEAR) install(TARGETS DD4hepRec convertToGear RUNTIME DESTINATION bin LIBRARY DESTINATION lib diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index 21e4a03f4..85b3c8927 100644 --- a/DDTest/CMakeLists.txt +++ b/DDTest/CMakeLists.txt @@ -10,11 +10,11 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${ROOT_INCLUDE_DIR} ) -if(DD4HEP_WITH_GEANT4) +if(DD4HEP_USE_GEANT4) include_directories( ${CMAKE_SOURCE_DIR}/DDG4/include ) endif() -if(DD4HEP_WITH_GEANT4) +if(DD4HEP_USE_GEANT4) link_libraries(DD4hepG4 DD4hepCore DD4hepRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) else() link_libraries(DD4hepCore DD4hepRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) diff --git a/ReadMe.txt b/ReadMe.txt index aa78b9618..f3f6e929e 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -25,7 +25,7 @@ on the C++ XercesC parser, and another one based on Python and using the PyROOT Is the package that contains the conversion of DD4hep geometry into Geant4 geometry to be used for simulation. The conversion is currently based on the Virtual Geometry Modeler (VGM) package that is build internally when required. - The option DD4HEP_WITH_GEANT4:BOOL controls the building or not of this package that has the dependency + The option DD4HEP_USE_GEANT4:BOOL controls the building or not of this package that has the dependency to Geant4. The Geant4 installation needs to be located using the variable -DGeant4_DIR=<path to Geant4Config.cmake> - examples @@ -91,7 +91,7 @@ To build and run the simulation examples Geant4 will be required. -D INSTALL_DOC=on * build with geant4 support: - -D DD4HEP_WITH_GEANT4=on -D Geant4_DIR=__path_to_Geant4Config.cmake__ + -D DD4HEP_USE_GEANT4=on -D Geant4_DIR=__path_to_Geant4Config.cmake__ [note: you might have to update your environment beforehand to have all needed libraries in the shared lib search path (this will vary with OS, shell, etc.) e.g @@ -108,9 +108,9 @@ To build and run the simulation examples Geant4 will be required. -DDD4HEP_USE_PYROOT=ON - examples for building a 'complete' DD4hep: - cmake -D DD4HEP_WITH_GEANT4=1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On .. + cmake -D DD4HEP_USE_GEANT4=1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On .. (if geant4 was built with external CLHEP, add: -D CLHEP_DIR=_path_to_CLHEP ) - cmake -D DD4HEP_WITH_GEANT4=1 -DGeant4_DIR=/data/ilcsoft/geant4/9.6.p01/lib/Geant4-9.6.1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On -D CLHEP_DIR=/data/ilcsoft/HEAD/CLHEP/2.1.3.1 .. + cmake -D DD4HEP_USE_GEANT4=1 -DGeant4_DIR=/data/ilcsoft/geant4/9.6.p01/lib/Geant4-9.6.1 -DDD4HEP_USE_BOOST=ON -DDD4HEP_USE_LCIO=ON -DBOOST_ROOT=/data/ilcsoft/boost/1.55.0 -DBUILD_TESTING=On -D CLHEP_DIR=/data/ilcsoft/HEAD/CLHEP/2.1.3.1 .. - Setup the environment for running diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index 1d469348e..03cd342e0 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -45,12 +45,12 @@ INCLUDE( ${DD4hep_ROOT}/cmake/DD4hepMacros.cmake ) # 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 -if(@DD4HEP_WITH_GEANT4@) +if(@DD4HEP_USE_GEANT4@) CHECK_PACKAGE_LIBS( DD4hep DD4hepCore DDSegmentation DD4hepRec DD4hepPlugins DD4hepG4 ) #--- if geant 4 was built with CLHEP we need to export this to client packages - if( @GEANT4_WITH_CLHEP@) - set(GEANT4_WITH_CLHEP 1 ) + if( @GEANT4_USE_CLHEP@) + set(GEANT4_USE_CLHEP 1 ) endif() else() diff --git a/cmake/thisdd4hep.sh b/cmake/thisdd4hep.sh index 12bbc741d..adb14da5d 100644 --- a/cmake/thisdd4hep.sh +++ b/cmake/thisdd4hep.sh @@ -22,7 +22,7 @@ fi #----------- source the ROOT environment first source @ROOT_ROOT@/bin/thisroot.sh -if [ @DD4HEP_WITH_GEANT4@ ] +if [ @DD4HEP_USE_GEANT4@ ] then export G4INSTALL=@Geant4_ROOT@ export G4ENV_INIT=@Geant4_ROOT@/bin/geant4.sh @@ -32,7 +32,7 @@ then #---- if geant4 was built with external CLHEP we have to extend the dynamic search path - if [ @GEANT4_WITH_CLHEP@ ] ; then + if [ @GEANT4_USE_CLHEP@ ] ; then if [ @USE_DYLD@ ] then export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:@CLHEP_LIBRARY_PATH@ diff --git a/doc/build.sh b/doc/build.sh index 4570fe22f..e552f8aa1 100644 --- a/doc/build.sh +++ b/doc/build.sh @@ -37,7 +37,7 @@ then echo "`pwd`"; mkdir ${BUILD_DIR}; cd ${BUILD_DIR}; - cmake -DCMAKE_BUILD_TYPE=Debug -DDD4HEP_WITH_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF ${BUILD_DIR}/DD4hep; + cmake -DCMAKE_BUILD_TYPE=Debug -DDD4HEP_USE_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF ${BUILD_DIR}/DD4hep; make -j 5; . thisdd4hep.sh; export LD_LIBRARY_PATH=${BUILD_DIR}/lib:${BUILD_DIR}/../DD4hep/examples/CLICSiD/lib:$LD_LIBRARY_PATH; diff --git a/doc/cmake.cmds b/doc/cmake.cmds index c80469a5c..42db771fc 100644 --- a/doc/cmake.cmds +++ b/doc/cmake.cmds @@ -1,12 +1,12 @@ # # ++++ Build DD4hep (simplest) # -cmake -DCMAKE_BUILD_TYPE=Debug -DDD4HEP_WITH_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF ../DD4hep +cmake -DCMAKE_BUILD_TYPE=Debug -DDD4HEP_USE_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF ../DD4hep # # ++++ Build DD4hep with XERCES # cmake -DCMAKE_BUILD_TYPE=Debug \ --DDD4HEP_WITH_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF \ +-DDD4HEP_USE_GEANT4=OFF -DDD4HEP_USE_PYROOT=OFF \ -DDD4HEP_USE_XERCESC=ON -DXERCESC_ROOT_DIR=${XERCESCSYS} \ ../DD4hep # @@ -14,7 +14,7 @@ cmake -DCMAKE_BUILD_TYPE=Debug \ # ++++ Build DD4hep with XERCES and GEANT4 # cmake -DCMAKE_BUILD_TYPE=Debug \ --DDD4HEP_WITH_GEANT4=ON -DGeant4_ROOT_DIR=${G4SYS} -DCLHEP_ROOT_DIR=${CLHEPSYS} \ +-DDD4HEP_USE_GEANT4=ON -DGeant4_ROOT_DIR=${G4SYS} -DCLHEP_ROOT_DIR=${CLHEPSYS} \ -DDD4HEP_USE_XERCESC=ON -DXERCESC_ROOT_DIR=${XERCESCSYS} \ -DDD4HEP_USE_PYROOT=OFF \ ../DD4hep @@ -23,7 +23,7 @@ cmake -DCMAKE_BUILD_TYPE=Debug \ # ++++ Build DD4hep with GEANT4 (no Xerces) # cmake -DCMAKE_BUILD_TYPE=Debug \ --DDD4HEP_WITH_GEANT4=ON -DGeant4_ROOT_DIR=${G4SYS} \ +-DDD4HEP_USE_GEANT4=ON -DGeant4_ROOT_DIR=${G4SYS} \ -DCLHEP_ROOT_DIR=${CLHEPSYS} -DDD4HEP_USE_PYROOT=OFF \ ../DD4hep # diff --git a/examples/ILDExDet/CMakeLists.txt b/examples/ILDExDet/CMakeLists.txt index d4245ba8b..4cea53236 100644 --- a/examples/ILDExDet/CMakeLists.txt +++ b/examples/ILDExDet/CMakeLists.txt @@ -43,7 +43,7 @@ set( ROOT_COMPONENT_LIBRARIES Geom Reflex) -if(DD4HEP_WITH_GEAR) +if(DD4HEP_USE_GEAR) find_package( GEAR REQUIRED COMPONENTS ) @@ -53,7 +53,7 @@ if(DD4HEP_WITH_GEAR) endforeach(lp) #message( STATUS " *** pathes : ${External_LIBRARY_DIRS} " ) - add_definitions("-D DD4HEP_WITH_GEAR") + add_definitions("-D DD4HEP_USE_GEAR") endif() diff --git a/examples/ILDExDet/src/ILDExSIT_geo.cpp b/examples/ILDExDet/src/ILDExSIT_geo.cpp index b5ef41891..52a04be4b 100644 --- a/examples/ILDExDet/src/ILDExSIT_geo.cpp +++ b/examples/ILDExDet/src/ILDExSIT_geo.cpp @@ -9,7 +9,7 @@ #include "DD4hep/DetFactoryHelper.h" -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR #include "DDRec/DDGear.h" #include "gearimpl/ZPlanarParametersImpl.h" #endif @@ -30,7 +30,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { PlacedVolume pv; -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR //--------------- gear: create gear::ZPlanarParameters and add them as Extension gear::ZPlanarParametersImpl* gearZPlanar = new gear::ZPlanarParametersImpl( gear::ZPlanarParameters::HYBRID , 0.0, 0.0, 0.0, 0.0, 0.0 ) ; // ZPlanarParametersImpl( int type, double shellInnerRadius, double shellOuterRadius, double shellHalfLength, double shellGap, double shellRadLength ) ; @@ -136,7 +136,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { } -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR //----------------- gear --------------------------------------------- double ladderRadLength = suppmat->GetMaterial()->GetRadLen() /dd4hep::mm ; double sensitiveRadLength = sensmat->GetMaterial()->GetRadLen() /dd4hep::mm ; diff --git a/examples/ILDExDet/src/ILDExTPC_geo.cpp b/examples/ILDExDet/src/ILDExTPC_geo.cpp index 353b3ba72..041b7135e 100644 --- a/examples/ILDExDet/src/ILDExTPC_geo.cpp +++ b/examples/ILDExDet/src/ILDExTPC_geo.cpp @@ -19,7 +19,7 @@ #include "TPCData.h" -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR #include "DDRec/DDGear.h" #include "gearimpl/TPCParametersImpl.h" #include "gearimpl/FixedPadSizeDiskLayout.h" @@ -256,7 +256,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { }//subdetectors tpc_vol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr()); -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR //--------------- create gear::TPCParameters and add them as Extension // GearTPCParameters* gearTPC = new GearTPCParameters( g_driftlength , gear::PadRowLayout2D::POLAR ) ; gear::TPCParametersImpl* gearTPC = new gear::TPCParametersImpl( g_driftlength , gear::PadRowLayout2D::POLAR ) ; diff --git a/examples/ILDExDet/src/ILDExVXD_geo.cpp b/examples/ILDExDet/src/ILDExVXD_geo.cpp index 1240eff0a..485593b67 100644 --- a/examples/ILDExDet/src/ILDExVXD_geo.cpp +++ b/examples/ILDExDet/src/ILDExVXD_geo.cpp @@ -9,7 +9,7 @@ #include "DD4hep/DetFactoryHelper.h" #include "VXDData.h" -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR #include "DDRec/DDGear.h" #include "gearimpl/ZPlanarParametersImpl.h" #endif @@ -43,7 +43,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { vxd_data->id = x_det.id(); -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR //--------------- gear: create gear::ZPlanarParameters and add them as Extension gear::ZPlanarParametersImpl* gearZPlanar = new gear::ZPlanarParametersImpl( gear::ZPlanarParameters::CCD , 0.0, 0.0, 0.0, 0.0, 0.0 ) ; // ZPlanarParametersImpl( int type, double shellInnerRadius, double shellOuterRadius, double shellHalfLength, double shellGap, double shellRadLength ) ; @@ -254,7 +254,7 @@ static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sens) { } vxd.setVisAttributes(lcdd, x_det.visStr(),laddervol); -#ifdef DD4HEP_WITH_GEAR +#ifdef DD4HEP_USE_GEAR //----------------- gear --------------------------------------------- double ladderRadLength = suppmat->GetMaterial()->GetRadLen() /dd4hep::mm ; double sensitiveRadLength = sensmat->GetMaterial()->GetRadLen() /dd4hep::mm ; diff --git a/examples/noviceN04/README b/examples/noviceN04/README index 85a4256ee..31ef6506d 100644 --- a/examples/noviceN04/README +++ b/examples/noviceN04/README @@ -19,7 +19,7 @@ Run: geoDisplay ../compact/N04.xml -#simulate w/ ILD example (needs DD4HEP_WITH_GEANT4 ) +#simulate w/ ILD example (needs DD4HEP_USE_GEANT4 ) ILDExSimu file:../compact/N04.xml file:../compact/geant4.xml ../run1.mac -- GitLab