From 0486f461da9fa9a77f2b660d8d136b8e1cf19933 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Fri, 8 May 2015 14:30:05 +0000 Subject: [PATCH] Cleanup DDRec CMakeLists: Rename target to DDRec, this required changes in many other CMakeLists to be consistent Re-arrange Gear dependent parts into single if scope Add SYSTEM to GEAR IncludeDirs Use variables to define libraries in one place and add optional ones (i.e., gear) to the list Create plugin_sources variable to create a DDRecPlugin independent of the DDRec library parts No Whitespace after and before parenthesis Assume ROOT_INCLUDE_DIRS is added in main CMakeLists file Comment Setting of CMAKE_CXX_FLAGS --- DDDetectors/CMakeLists.txt | 2 +- DDRec/CMakeLists.txt | 61 ++++++++++++++++--------------------- DDTest/CMakeLists.txt | 4 +-- UtilityApps/CMakeLists.txt | 10 +++--- cmake/DD4hepConfig.cmake.in | 4 +-- 5 files changed, 37 insertions(+), 44 deletions(-) diff --git a/DDDetectors/CMakeLists.txt b/DDDetectors/CMakeLists.txt index e6d14b1af..fd4231d78 100644 --- a/DDDetectors/CMakeLists.txt +++ b/DDDetectors/CMakeLists.txt @@ -23,7 +23,7 @@ include_directories(${CMAKE_SOURCE_DIR}/DDCore/include file(GLOB sources src/*.cpp ) add_library( DD4hepDetectors SHARED ${sources}) -target_link_libraries( DD4hepDetectors DD4hepCore DD4hepRec ${ROOT_LIBRARIES} ) +target_link_libraries( DD4hepDetectors DD4hepCore DDRec ${ROOT_LIBRARIES} ) # #---Rootmap generation-------------------------------------------------------------- dd4hep_generate_rootmap( DD4hepDetectors ) diff --git a/DDRec/CMakeLists.txt b/DDRec/CMakeLists.txt index 0da5652b1..3190337bd 100644 --- a/DDRec/CMakeLists.txt +++ b/DDRec/CMakeLists.txt @@ -2,67 +2,60 @@ cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) project(DDRec) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${DDSegmentation_INCLUDE_DIRS} - ${ROOT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/DDSurfaces/include + ${CMAKE_SOURCE_DIR}/DDSurfaces/include ${CMAKE_SOURCE_DIR}/DDCore/include) file(GLOB sources src/*.cpp) +set(rec_link_libraries DD4hepCore ${DDSegmentation_LIBRARIES} ${ROOT_LIBRARIES} Geom Reflex) #--------------------------- GEAR wrappers for backward compatibility ----------- if(DD4HEP_USE_GEAR) find_package(GEAR REQUIRED COMPONENTS geartgeo) + include_directories(SYSTEM ${GEAR_INCLUDE_DIRS}) + add_definitions("-D DD4HEP_USE_GEAR") - include_directories( ${GEAR_INCLUDE_DIRS} ) + list(APPEND sources src/gear/DDGear.cpp) + list(APPEND plugin_sources src/gear/createGearForILD.cpp src/gear/createGearForCLIC.cpp) + list(APPEND rec_link_libraries ${GEAR_LIBRARIES} ${GEAR_COMPONENT_LIBRARIES}) - set(sources ${sources} src/gear/DDGear.cpp src/gear/createGearForILD.cpp src/gear/createGearForCLIC.cpp) + add_executable(convertToGear src/convertToGear.cc) - add_definitions("-D DD4HEP_USE_GEAR") + target_link_libraries(convertToGear ${PackageName} ${DD4hep_LIBRARIES} DDRec + ${ROOT_LIBRARIES} ${ROOT_COMPONENT_LIBRARIES} ${GEAR_LIBRARIES} + ) + + install(TARGETS convertToGear + RUNTIME DESTINATION bin + ) endif() #------------------------------------------------------------------------------------- -add_library(DD4hepRec SHARED ${sources} ) - -if(DD4HEP_USE_GEAR) - target_link_libraries(DD4hepRec ${ROOT_LIBRARIES} ${DDSegmentation_LIBRARIES} DD4hepCore Geom Reflex ${libraries} ${GEAR_LIBRARIES} ${GEAR_COMPONENT_LIBRARIES}) - - #------ binary ---------- - - add_executable( convertToGear src/convertToGear.cc) - - target_link_libraries(convertToGear ${PackageName} ${DD4hep_LIBRARIES} DD4hepRec - ${ROOT_LIBRARIES} ${ROOT_COMPONENT_LIBRARIES} - ${GEAR_LIBRARIES} - ) +add_library(DDRec SHARED ${sources}) +target_link_libraries(DDRec ${rec_link_libraries}) -else() - target_link_libraries(DD4hepRec ${ROOT_LIBRARIES} ${DDSegmentation_LIBRARIES} DD4hepCore Geom Reflex ${libraries}) -endif(DD4HEP_USE_GEAR) +# Add the DDRecPlugin, as there are currently only gear plugins, we need to check if we want to create the plugin +if( plugin_sources ) + add_dd4hep_plugin(DDRecPlugins SHARED ${plugin_sources}) + target_link_libraries(DDRecPlugins ${rec_link_libraries}) +endif() -SET(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") -SET_TARGET_PROPERTIES( DD4hepRec PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) +#SET(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") +SET_TARGET_PROPERTIES(DDRec PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) #--- install target------------------------------------- install(DIRECTORY include/DDRec DESTINATION include PATTERN ".svn" EXCLUDE ) -if(DD4HEP_USE_GEAR) - install(TARGETS DD4hepRec convertToGear - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib +install(TARGETS DDRec + LIBRARY DESTINATION lib ) -else() - install(TARGETS DD4hepRec - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ) -endif() - # to do: add corresponding uninstall... #------------------------------------------------------- diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index 8bfd9565b..39096aafc 100644 --- a/DDTest/CMakeLists.txt +++ b/DDTest/CMakeLists.txt @@ -15,9 +15,9 @@ if(DD4HEP_USE_GEANT4) endif() if(DD4HEP_USE_GEANT4) - link_libraries(DD4hepG4 DD4hepCore DD4hepRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) + link_libraries(DD4hepG4 DD4hepCore DDRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) else() - link_libraries(DD4hepCore DD4hepRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) + link_libraries(DD4hepCore DDRec DDSegmentation ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES}) endif() #-------------------------------------------------- diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index a6c4bfc82..790766db8 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -18,13 +18,13 @@ add_executable(geoPluginRun src/plugin_runner.cpp) target_link_libraries(geoPluginRun DD4hepCore) #----------------------------------------------------------------------------------- add_executable( print_materials src/print_materials.cpp) -target_link_libraries(print_materials DD4hepCore DD4hepRec) +target_link_libraries(print_materials DD4hepCore DDRec) #----------------------------------------------------------------------------------- add_executable( materialScan src/materialScan.cpp) -target_link_libraries(materialScan DD4hepCore DD4hepRec) +target_link_libraries(materialScan DD4hepCore DDRec) #----------------------------------------------------------------------------------- add_executable( dumpdetector src/dumpdetector.cpp) -target_link_libraries(dumpdetector DD4hepCore DD4hepRec) +target_link_libraries(dumpdetector DD4hepCore DDRec) #----------------------------------------------------------------------------------- @@ -35,11 +35,11 @@ if(DD4HEP_USE_LCIO) add_executable(teveDisplay src/teve_display.cpp G__teve.cxx src/next_event_lcio.cpp) add_executable(test_surfaces src/test_surfaces.cpp ) - target_link_libraries(test_surfaces DD4hepCore DD4hepRec ${LCIO_LIBRARIES} ) + target_link_libraries(test_surfaces DD4hepCore DDRec ${LCIO_LIBRARIES} ) else() add_executable(teveDisplay src/teve_display.cpp G__teve.cxx src/next_event_dummy.cpp) endif() -target_link_libraries( teveDisplay DD4hepCore ${ROOT_EVE_LIBRARIES} DD4hepRec ${LCIO_LIBRARIES} ) +target_link_libraries( teveDisplay DD4hepCore ${ROOT_EVE_LIBRARIES} DDRec ${LCIO_LIBRARIES} ) #--- install target------------------------------------- diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index b459432e4..03b21f05c 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -50,7 +50,7 @@ INCLUDE( ${DD4hep_ROOT}/cmake/DD4hepMacros.cmake ) # additional components are set by cmake in variable PKG_FIND_COMPONENTS # first argument should be the package name if(@DD4HEP_USE_GEANT4@) - CHECK_PACKAGE_LIBS( DD4hep DD4hepCore DDSegmentation DD4hepRec DD4hepG4 ) + CHECK_PACKAGE_LIBS(DD4hep DD4hepCore DDSegmentation DDRec DD4hepG4) #--- if geant 4 was built with CLHEP we need to export this to client packages if( @GEANT4_USE_CLHEP@) @@ -60,7 +60,7 @@ if(@DD4HEP_USE_GEANT4@) set( Geant4_DIR @Geant4_DIR@) else() - CHECK_PACKAGE_LIBS( DD4hep DD4hepCore DDSegmentation DD4hepRec ) + CHECK_PACKAGE_LIBS(DD4hep DD4hepCore DDSegmentation DDRec) endif() -- GitLab