From 33af4ea0fe54dcdf2df558754933dc111beea5b3 Mon Sep 17 00:00:00 2001 From: Marko Petric <marko.petric@cern.ch> Date: Fri, 18 Oct 2019 17:26:21 +0200 Subject: [PATCH] call find_package in examples if DD4hep targets are not found --- cmake/DD4hepBuild.cmake | 2 +- examples/AlignDet/CMakeLists.txt | 9 +++++++-- examples/CLICSiD/CMakeLists.txt | 14 +++++++------- examples/CMakeLists.txt | 14 +++----------- examples/ClientTests/CMakeLists.txt | 10 +++++++--- examples/Conditions/CMakeLists.txt | 9 +++++++-- examples/DDCMS/CMakeLists.txt | 8 +++++++- examples/DDCMS/data/dd4hep-config.xml | 2 +- examples/DDCMS/scripts/CMSTrackerSim.py | 2 +- examples/DDCodex/CMakeLists.txt | 8 +++++++- examples/DDDB/CMakeLists.txt | 8 +++++++- examples/DDDigi/CMakeLists.txt | 8 +++++++- examples/DDDigi/scripts/TestFramework.py | 2 +- examples/DDG4/CMakeLists.txt | 10 +++++++--- examples/DDG4_MySensDet/CMakeLists.txt | 8 +++++++- examples/LHeD/CMakeLists.txt | 9 +++++++-- examples/OpticalSurfaces/CMakeLists.txt | 8 +++++++- examples/Persistency/CMakeLists.txt | 8 +++++++- examples/Segmentation/CMakeLists.txt | 18 +++++++++--------- examples/SimpleDetector/CMakeLists.txt | 8 +++++++- 20 files changed, 114 insertions(+), 51 deletions(-) diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 789a1eb18..929781268 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -556,7 +556,7 @@ function(dd4hep_add_dictionary dictionary ) if ( NOT "${ARG_OUTPUT}" STREQUAL "" ) set ( output_dir ${ARG_OUTPUT} ) endif() - + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${output_dir}) SET(COMP_DEFS ) file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}_arguments CONTENT "${ROOT_rootcling_CMD} -cint -f ${dictionary}.cxx -s ${output_dir}/${dictionary} -inlineInputHeader -c -p ${ARG_OPTIONS} -std=c++${CMAKE_CXX_STANDARD} \ diff --git a/examples/AlignDet/CMakeLists.txt b/examples/AlignDet/CMakeLists.txt index b83ba0357..27eb9e128 100644 --- a/examples/AlignDet/CMakeLists.txt +++ b/examples/AlignDet/CMakeLists.txt @@ -9,11 +9,16 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -dd4hep_configure_output() set(AlignDet_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/AlignDet) dd4hep_add_plugin(AlignDetExample SOURCES src/*.cpp diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index 51b12caac..8b6cb1c94 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -9,17 +9,17 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) - -dd4hep_set_compiler_flags() -#========================================================================== -dd4hep_configure_output () IF(NOT TARGET DD4hep::DDCore) - find_package(DD4hep) - find_package(ROOT REQUIRED COMPONENTS Geom) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() ENDIF() +dd4hep_set_compiler_flags() +#========================================================================== + set(CLICSiDEx_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/CLICSiD) dd4hep_install_dir( scripts sim DESTINATION ${CLICSiDEx_INSTALL} ) #-------------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8a3be21eb..f915b3df2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,20 +28,12 @@ project( DD4hep_Examples ) include(CTest) option(BUILD_TESTING "Enable and build tests" ON) -option(CMAKE_MACOSX_RPATH "Build with rpath on macos" ON) -# +SET( ENV{DD4hepExamplesINSTALL} ${CMAKE_INSTALL_PREFIX} ) + IF(NOT TARGET DD4hep::DDCore) find_package ( DD4hep REQUIRED ) - include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) - include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) - find_package ( ROOT REQUIRED COMPONENTS Geom GenVector ) - dd4hep_set_compiler_flags() ENDIF() -# -#include(${ROOT_USE_FILE}) -# -SET( ENV{DD4hepExamplesINSTALL} ${CMAKE_INSTALL_PREFIX} ) -# + dd4hep_configure_output() add_subdirectory(CLICSiD) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index b515c788c..5da5b90e6 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -9,12 +9,16 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -dd4hep_configure_output() - if(TARGET XercesC::XercesC) SET(OPT_XERCESC XercesC::XercesC) endif() diff --git a/examples/Conditions/CMakeLists.txt b/examples/Conditions/CMakeLists.txt index feb5a720b..0b0dafe01 100644 --- a/examples/Conditions/CMakeLists.txt +++ b/examples/Conditions/CMakeLists.txt @@ -9,11 +9,16 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -dd4hep_configure_output () if(TARGET XercesC::XercesC) SET(OPT_XERCESC XercesC::XercesC) diff --git a/examples/DDCMS/CMakeLists.txt b/examples/DDCMS/CMakeLists.txt index 35df0a714..7fb71f1d4 100644 --- a/examples/DDCMS/CMakeLists.txt +++ b/examples/DDCMS/CMakeLists.txt @@ -13,7 +13,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/DDCMS/data/dd4hep-config.xml b/examples/DDCMS/data/dd4hep-config.xml index df94f931d..5d1a72836 100644 --- a/examples/DDCMS/data/dd4hep-config.xml +++ b/examples/DDCMS/data/dd4hep-config.xml @@ -106,7 +106,7 @@ </display> <plugin name="DD4hep_XMLLoader"> - <arg value="file:${DD4hepINSTALL}/examples/DDCMS/data/cms_tracker.xml"/> + <arg value="file:${DD4hepExamplesINSTALL}/examples/DDCMS/data/cms_tracker.xml"/> </plugin> <plugin name="DD4hep_PlacedVolumeProcessor"> diff --git a/examples/DDCMS/scripts/CMSTrackerSim.py b/examples/DDCMS/scripts/CMSTrackerSim.py index 3fca5215e..5abe2dac9 100644 --- a/examples/DDCMS/scripts/CMSTrackerSim.py +++ b/examples/DDCMS/scripts/CMSTrackerSim.py @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) def run(): kernel = DDG4.Kernel() - install_dir = os.environ['DD4hepINSTALL'] + install_dir = os.environ['DD4hepExamplesINSTALL'] kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG) kernel.setOutputLevel(str('Gun'), Output.INFO) kernel.detectorDescription().fromXML(str("file:" + install_dir + "/examples/DDCMS/data/dd4hep-config.xml")) diff --git a/examples/DDCodex/CMakeLists.txt b/examples/DDCodex/CMakeLists.txt index 92a344e0b..7cc5f54ee 100755 --- a/examples/DDCodex/CMakeLists.txt +++ b/examples/DDCodex/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/DDDB/CMakeLists.txt b/examples/DDDB/CMakeLists.txt index 9855432cd..027880018 100644 --- a/examples/DDDB/CMakeLists.txt +++ b/examples/DDDB/CMakeLists.txt @@ -17,7 +17,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/DDDigi/CMakeLists.txt b/examples/DDDigi/CMakeLists.txt index 0f9cb0db0..e6b7cf089 100644 --- a/examples/DDDigi/CMakeLists.txt +++ b/examples/DDDigi/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/DDDigi/scripts/TestFramework.py b/examples/DDDigi/scripts/TestFramework.py index e1ebc88d6..e2d731fff 100644 --- a/examples/DDDigi/scripts/TestFramework.py +++ b/examples/DDDigi/scripts/TestFramework.py @@ -6,7 +6,7 @@ import DDDigi DDDigi.setPrintFormat(str('%-32s %5s %s')) kernel = DDDigi.Kernel() -install_dir = os.environ['DD4hepINSTALL'] +install_dir = os.environ['DD4hepExamplesINSTALL'] fname = "file:" + install_dir + "/examples/ClientTests/compact/MiniTel.xml" kernel.loadGeometry(str(fname)) kernel.printProperties() diff --git a/examples/DDG4/CMakeLists.txt b/examples/DDG4/CMakeLists.txt index 53920b643..0986e1564 100644 --- a/examples/DDG4/CMakeLists.txt +++ b/examples/DDG4/CMakeLists.txt @@ -9,11 +9,16 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -dd4hep_configure_output () set(DDG4examples_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/DDG4) # @@ -24,7 +29,6 @@ if (DD4HEP_USE_GEANT4) dd4hep_add_dictionary(G__DDG4UserDict SOURCES ${DD4hep_DIR}/include/ROOT/Warnings.h src/Dictionary.h LINKDEF ${DD4hep_DIR}/include/ROOT/LinkDef.h - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib ) #---- Example of a client library with user defined plugins -------------------- dd4hep_add_plugin( DDG4UserLib diff --git a/examples/DDG4_MySensDet/CMakeLists.txt b/examples/DDG4_MySensDet/CMakeLists.txt index fabf3bbdf..e5fb199c0 100644 --- a/examples/DDG4_MySensDet/CMakeLists.txt +++ b/examples/DDG4_MySensDet/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/LHeD/CMakeLists.txt b/examples/LHeD/CMakeLists.txt index e0824b165..a6635bf1f 100644 --- a/examples/LHeD/CMakeLists.txt +++ b/examples/LHeD/CMakeLists.txt @@ -9,11 +9,16 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -dd4hep_configure_output () set(LHeDEx_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/LHeD) dd4hep_install_dir( src compact scripts sim DESTINATION ${LHeDEx_INSTALL} ) #----------------------------------------------------------------------------------- diff --git a/examples/OpticalSurfaces/CMakeLists.txt b/examples/OpticalSurfaces/CMakeLists.txt index ea721df54..78e3d99eb 100644 --- a/examples/OpticalSurfaces/CMakeLists.txt +++ b/examples/OpticalSurfaces/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/Persistency/CMakeLists.txt b/examples/Persistency/CMakeLists.txt index bab156054..f9e5c58db 100644 --- a/examples/Persistency/CMakeLists.txt +++ b/examples/Persistency/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== diff --git a/examples/Segmentation/CMakeLists.txt b/examples/Segmentation/CMakeLists.txt index 3160929d8..3b6d5a0aa 100644 --- a/examples/Segmentation/CMakeLists.txt +++ b/examples/Segmentation/CMakeLists.txt @@ -9,16 +9,21 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== + #--------------------------- set( PackageName Segmentation ) #--------------------------- -project(${PackageName}) - # project version SET( ${PackageName}_VERSION_MAJOR 0 ) SET( ${PackageName}_VERSION_MINOR 0 ) @@ -44,13 +49,8 @@ ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -find_package( DD4hep ) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${dd4hep_ROOT}/cmake ) -include( dd4hep ) find_package( ROOT REQUIRED ) -#find_package( ROOT REQUIRED COMPONENTS Geom Reflex) set( ROOT_COMPONENT_LIBRARIES Geom Reflex) #------------------------------------------------------------- @@ -88,7 +88,7 @@ target_link_libraries(Segmentation ${dd4hep_LIBRARIES} ) #---- configure run environment --------------- -configure_file( ${dd4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) +configure_file( ${DD4hep_ROOT}/cmake/thisdd4hep_package.sh.in this${PackageName}.sh @ONLY) install(FILES ${CMAKE_BINARY_DIR}/this${PackageName}.sh DESTINATION bin diff --git a/examples/SimpleDetector/CMakeLists.txt b/examples/SimpleDetector/CMakeLists.txt index b84c1c0af..e8ef9f598 100644 --- a/examples/SimpleDetector/CMakeLists.txt +++ b/examples/SimpleDetector/CMakeLists.txt @@ -9,7 +9,13 @@ # #========================================================================== cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +IF(NOT TARGET DD4hep::DDCore) + find_package ( DD4hep REQUIRED ) + include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + include ( ${DD4hep_DIR}/cmake/DD4hepBuild.cmake ) + dd4hep_configure_output() +ENDIF() dd4hep_set_compiler_flags() #========================================================================== -- GitLab