diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt index e15a966bb8c9bc71a5abcffc1121882569e53966..32b9cfe489126db7dbe0a8423efc231ae2e1a0dc 100644 --- a/FullSimLight/CMakeLists.txt +++ b/FullSimLight/CMakeLists.txt @@ -28,9 +28,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) # Set up how the project handle some of its dependenices. Either by picking them # up from the environment, or building them itself. include( SetupJSON ) - if( NOT TARGET XercesCBuiltIn ) - include( SetupXercesC ) - endif() + include( SetupXercesC ) # Find the base GeoModel packages, which must be installed on the target system already find_package( GeoModelCore REQUIRED ${GeoModel_VERSION} ) find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} ) @@ -136,15 +134,7 @@ add_executable(gm2gdml geoModel2GDML.cc ${sources} ${headers}) #---------------------------------------------------------------------------- # Add extra 'include' directories # -# If the in-house build of the Xerces-C library is used, add explicit dependency: for Geant4 -if( GEOMODEL_USE_BUILTIN_XERCESC ) - add_dependencies( fullSimLight XercesCBuiltIn ) - add_dependencies( gmclash XercesCBuiltIn ) - add_dependencies( gmmasscalc XercesCBuiltIn ) - add_dependencies( fillHistogramExample XercesCBuiltIn ) - add_dependencies( gmgeantino XercesCBuiltIn ) - add_dependencies( gm2gdml XercesCBuiltIn ) -endif() + #---------------------------------------------------------------------------- # Link all needed libraries # diff --git a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/DummyUserActionsPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/DummyUserActionsPlugin/CMakeLists.txt index e34aaa7b160e32b5a242a932b8578f0ee12bbd5a..617b3e584f677bbb1b40118bd207ff18a39decd0 100644 --- a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/DummyUserActionsPlugin/CMakeLists.txt +++ b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/DummyUserActionsPlugin/CMakeLists.txt @@ -23,9 +23,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) "Framework finding behaviour on macOS" ) # Set up how the project handle some of its dependenices. Either by picking them # up from the environment, or building them itself. - if( NOT TARGET XercesCBuiltIn ) - include( SetupXercesC ) - endif() + include( SetupXercesC ) # Find the base GeoModelATLAS packages, which must be installed on the target system already find_package( GeoModelDataManagers REQUIRED ${GeoModelATLAS_VERSION} ) else() diff --git a/GeoModelG4/GeoMaterial2G4/CMakeLists.txt b/GeoModelG4/GeoMaterial2G4/CMakeLists.txt index 024665666172ea340934104dc11cea9987e5f636..99fccefa3b8153ba6fdf782b105f9929d3afd991 100644 --- a/GeoModelG4/GeoMaterial2G4/CMakeLists.txt +++ b/GeoModelG4/GeoMaterial2G4/CMakeLists.txt @@ -18,10 +18,7 @@ include(${Geant4_USE_FILE}) # Set target and properties add_library( GeoMaterial2G4 SHARED ${HEADERS} ${SOURCES} ) -# If the in-house build of the nlohmann_json library is used, add explicit dependency -if( GEOMODEL_USE_BUILTIN_XERCESC ) - add_dependencies( GeoMaterial2G4 XercesCBuiltIn ) -endif() + # Check if we are building FullSimLight individually, # or as a part of the main GeoModel. # In the first case, we link against the imported targets, which are taken diff --git a/GeoModelTools/CMakeLists.txt b/GeoModelTools/CMakeLists.txt index 9fd5840b4561a3cf08e3462914b48c7ef7818941..df0994d672bb2ab9e0f7517c1c193f388bd407cb 100644 --- a/GeoModelTools/CMakeLists.txt +++ b/GeoModelTools/CMakeLists.txt @@ -28,9 +28,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) # Set up how the project handle some of its dependenices. Either by picking them # up from the environment, or building them itself. include( SetupJSON ) - if( NOT TARGET XercesCBuiltIn ) - include( SetupXercesC ) - endif() + include( SetupXercesC ) # Find the base GeoModel packages, which must be installed on the target system already find_package( GeoModelCore REQUIRED ${GeoModel_VERSION} ) find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} ) diff --git a/GeoModelTools/GDMLtoGM/CMakeLists.txt b/GeoModelTools/GDMLtoGM/CMakeLists.txt index 7b57447e2f0762924643acc92e139b67e66dfc92..16a10e98a3d781bfdc14440563a99f50c31f68c5 100644 --- a/GeoModelTools/GDMLtoGM/CMakeLists.txt +++ b/GeoModelTools/GDMLtoGM/CMakeLists.txt @@ -6,12 +6,6 @@ file( GLOB HEADERS GDMLInterface/*.h ) # Create the library. add_library( GDMLtoGM SHARED ${HEADERS} ${SOURCES} ) - -# If the in-house build of the Xerces-C library is used, add explicit dependency -if( GEOMODEL_USE_BUILTIN_XERCESC ) - add_dependencies( GDMLtoGM XercesCBuiltIn ) -endif() - target_link_libraries( GDMLtoGM PUBLIC XercesC::XercesC ExpressionEvaluator GeoModelXMLParser GeoModelCore::GeoModelKernel ) target_include_directories( GDMLtoGM PUBLIC diff --git a/GeoModelTools/GeoModelXMLParser/CMakeLists.txt b/GeoModelTools/GeoModelXMLParser/CMakeLists.txt index e61982075c20300de6f7e400fa14b21fc89cf45f..4ec001e6c47b49d9bdbfda6bfc1f61f02ebdb365 100644 --- a/GeoModelTools/GeoModelXMLParser/CMakeLists.txt +++ b/GeoModelTools/GeoModelXMLParser/CMakeLists.txt @@ -6,10 +6,6 @@ file( GLOB HEADERS GeoModelXMLParser/*.h ) # Create the library. add_library( GeoModelXMLParser SHARED ${HEADERS} ${SOURCES} ) -# If the in-house build of the Xerces-C library is used, add explicit dependency -if( GEOMODEL_USE_BUILTIN_XERCESC ) - add_dependencies( GeoModelXMLParser XercesCBuiltIn ) -endif() target_link_libraries( GeoModelXMLParser PUBLIC XercesC::XercesC ExpressionEvaluator ) target_include_directories( GeoModelXMLParser PUBLIC diff --git a/cmake/SetupXercesC.cmake b/cmake/SetupXercesC.cmake index e42cb94c00759e9fee3fbecd9a3145cfcca74ce4..c03ef2722fe3b910e5e9a943da1e43aaca6b465a 100644 --- a/cmake/SetupXercesC.cmake +++ b/cmake/SetupXercesC.cmake @@ -4,74 +4,63 @@ # it on the build machine, or by downloading it during the build itself. # -# Make sure that this file is only included once. -get_property( _xercescSetUp GLOBAL PROPERTY GEOMODEL_XERCESC_SET_UP SET ) -if( _xercescSetUp ) - unset( _xercescSetUp ) - return() -endif() -set_property( GLOBAL PROPERTY GEOMODEL_XERCESC_SET_UP TRUE ) +# Make sure that this file is only included once.] +include_guard(GLOBAL) # Configuration option for how XercesC should be used. -option( GEOMODEL_USE_BUILTIN_XERCESC - "Download/build a version of XercesC during the build" FALSE ) +option( GEOMODEL_USE_BUILTIN_XERCESC "Download/build a version of XercesC during the build" OFF) # Now do what was requested. -if( GEOMODEL_USE_BUILTIN_XERCESC ) +if(GEOMODEL_USE_BUILTIN_XERCESC) - # Tell the user what's happening. - message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_XERCESC' was set to 'true' ==> Building XercesC as part of the project${ColourReset}" ) + # Tell the user what's happening. + message( STATUS "${BoldMagenta}'GEOMODEL_USE_BUILTIN_XERCESC' was set to 'true' ==> Building XercesC as part of the project${ColourReset}" ) - # The include directory and library that will be produced. - set( XercesC_INCLUDE_DIR - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Path to the Xerces-C include directory" FORCE ) - set( XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}" ) - set( XercesC_LIBRARY - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/${CMAKE_SHARED_LIBRARY_PREFIX}xerces-c${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE PATH "Path to the Xerces-C library file" FORCE ) - set( XercesC_LIBRARIES "${XercesC_LIBRARY}" ) - set( XercesC_LIBRARY_RELEASE "${XercesC_LIBRARY}" CACHE PATH "Path to the Xerces-C library" FORCE ) - set( XercesC_VERSION "3.2.3" ) + # The include directory and library that will be produced. + set(XercesC_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Path to the Xerces-C include directory" FORCE ) + set(XercesC_INCLUDE_DIRS "${XercesC_INCLUDE_DIR}" ) + set(XercesC_LIBRARY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/${CMAKE_SHARED_LIBRARY_PREFIX}xerces-c${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE PATH "Path to the Xerces-C library file" FORCE ) + set(XercesC_LIBRARIES "${XercesC_LIBRARY}" ) + set(XercesC_LIBRARY_RELEASE "${XercesC_LIBRARY}" CACHE PATH "Path to the Xerces-C library" FORCE ) + set(XercesC_VERSION "3.2.3" ) - # Create the include directory already, otherwise CMake refuses to - # create the imported target. - file( MAKE_DIRECTORY "${XercesC_INCLUDE_DIR}" ) + # Create the include directory already, otherwise CMake refuses to + # create the imported target. + file( MAKE_DIRECTORY "${XercesC_INCLUDE_DIR}" ) - # Build/install Eigen3 using ExternalProject_Add(...). - include( ExternalProject ) - ExternalProject_Add( XercesCBuiltIn - PREFIX "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCBuild" - INSTALL_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall" - URL "https://cern.ch/lcgpackages/tarFiles/sources/xerces-c-${XercesC_VERSION}.tar.gz" - URL_MD5 "a5fa4d920fce31c9ca3bfef241644494" - CONFIGURE_COMMAND - ${CMAKE_COMMAND} -E env CXXFLAGS=-std=c++${CMAKE_CXX_STANDARD} - <SOURCE_DIR>/configure --disable-static --prefix=<INSTALL_DIR> - INSTALL_COMMAND make install - COMMAND ${CMAKE_COMMAND} -E remove -f - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/${CMAKE_SHARED_LIBRARY_PREFIX}xerces-c.la" - COMMAND ${CMAKE_COMMAND} -E remove_directory - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/pkgconfig" - BUILD_BYPRODUCTS "${XercesC_INCLUDE_DIR}" "${XercesC_LIBRARY}" ) - install( DIRECTORY - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/bin" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib" - DESTINATION . - COMPONENT Runtime - USE_SOURCE_PERMISSIONS ) - install( DIRECTORY "${XercesC_INCLUDE_DIR}" - DESTINATION . - COMPONENT Development - USE_SOURCE_PERMISSIONS ) + # Build/install XercesC using ExternalProject_Add(...). + include(ExternalProject) + ExternalProject_Add( XercesCBuiltIn + PREFIX "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCBuild" + INSTALL_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall" + URL "https://cern.ch/lcgpackages/tarFiles/sources/xerces-c-${XercesC_VERSION}.tar.gz" + URL_MD5 "a5fa4d920fce31c9ca3bfef241644494" + CONFIGURE_COMMAND + ${CMAKE_COMMAND} -E env CXXFLAGS=-std=c++${CMAKE_CXX_STANDARD} <SOURCE_DIR>/configure --disable-static --prefix=<INSTALL_DIR> + INSTALL_COMMAND make install + COMMAND ${CMAKE_COMMAND} -E remove -f "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/${CMAKE_SHARED_LIBRARY_PREFIX}xerces-c.la" + COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib/pkgconfig" + BUILD_BYPRODUCTS "${XercesC_INCLUDE_DIR}" "${XercesC_LIBRARY}" ) + install(DIRECTORY + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/bin" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/XercesCInstall/lib" + DESTINATION . + COMPONENT Runtime + USE_SOURCE_PERMISSIONS ) + install(DIRECTORY "${XercesC_INCLUDE_DIR}" + DESTINATION . + COMPONENT Development + USE_SOURCE_PERMISSIONS ) - # Set up XercesC's imported target. - add_library( XercesC::XercesC UNKNOWN IMPORTED ) - set_target_properties( XercesC::XercesC PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${XercesC_INCLUDE_DIR}" - IMPORTED_LOCATION "${XercesC_LIBRARY}" ) + # Set up local XercesC "imported" target. + add_library(XercesC::XercesC UNKNOWN IMPORTED) + set_target_properties( XercesC::XercesC PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${XercesC_INCLUDE_DIR}" + IMPORTED_LOCATION "${XercesC_LIBRARY}") + # Handle dependency to underlying external project + add_dependencies(XercesC::XercesC XercesCBuiltIn) else() - - # Just find an existing installation of XercesC. - find_package( XercesC REQUIRED ) - + # Just find an existing installation of XercesC. + find_package(XercesC REQUIRED) endif()