diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index e89de84a47289fba1c96ba15087771d1bf5eea35..a8a260f11a138a085fbeba4f65e8ed02c6fc1576 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -43,6 +43,38 @@ function ( dd4hep_debug msg ) endif() endfunction( dd4hep_debug ) +#--------------------------------------------------------------------------------------------------- +# dd4hep_print +# +# +# \author M.Frank +# \version 1.0 +# +#--------------------------------------------------------------------------------------------------- +function ( dd4hep_print msg ) + message ( STATUS ${msg} ) +endfunction ( dd4hep_print ) + +function ( dd4hep_skipmsg msg ) + message ( STATUS "SKIPPED !!!!!!!!!!!!!! ${msg}" ) +endfunction ( dd4hep_skipmsg ) + +#--------------------------------------------------------------------------------------------------- +# dd4hep_fatal +# +# +# \author M.Frank +# \version 1.0 +# +#--------------------------------------------------------------------------------------------------- +function ( dd4hep_fatal msg ) + get_property(pkg DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_NAME) + if ( "${pkg}" STREQUAL "" ) + message ( FATAL_ERROR "++> ${msg}" ) + else() + message ( FATAL_ERROR "++> [${pkg}] ${msg}" ) + endif() +endfunction ( dd4hep_fatal ) #--------------------------------------------------------------------------------------------------- # dd4hep_set_version @@ -58,7 +90,7 @@ function ( dd4hep_set_version packageName ) if ( NOT "${packageName}" STREQUAL "" ) project ( ${packageName} ) else() - message(FATAL_ERROR " !!! Attempt to define a DD4hep project without a name !!!") + dd4hep_fatal ( "${packageName}: !!! Attempt to define a DD4hep project without a name !!!" ) endif() set ( major ${ARG_MAJOR} ) set ( minor ${ARG_MINOR} ) @@ -75,14 +107,13 @@ function ( dd4hep_set_version packageName ) endif() if ( NOT ("${major}" STREQUAL "" OR "${minor}" STREQUAL "" OR "${patch}" STREQUAL "") ) - #message ( STATUS "dd4hep_set_version(${packageName} MAJOR ${major} MINOR ${minor} PATCH ${patch})" ) set( ${packageName}_VERSION_MAJOR ${major} PARENT_SCOPE ) set( ${packageName}_VERSION_MINOR ${minor} PARENT_SCOPE ) set( ${packageName}_VERSION_PATCH ${patch} PARENT_SCOPE ) set( ${packageName}_VERSION "${major}.${minor}" PARENT_SCOPE ) set( ${packageName}_SOVERSION "${major}.${minor}" PARENT_SCOPE ) else() - message( FATAL_ERROR "|++> ${packageName}: No Package versions specified.....-> ( ${major}.${minor}.${patch} )" ) + dd4hep_fatal ( "${packageName}: No Package versions specified.....-> ( ${major}.${minor}.${patch} )" ) endif() endfunction( dd4hep_set_version ) @@ -95,21 +126,21 @@ endfunction( dd4hep_set_version ) # \version 1.0 #--------------------------------------------------------------------------------------------------- function ( dd4hep_print_options ) - message ( STATUS "+-------------------------------------------------------------------------------" ) - message ( STATUS "| DD4hep build setup: " ) - message ( STATUS "| " ) - message ( STATUS "| CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH} " ) - message ( STATUS "| DD4HEP_USE_BOOST: ${DD4HEP_USE_BOOST} DD4HEP_USE_Boost:${DD4HEP_USE_Boost}" ) - message ( STATUS "| DD4HEP_USE_XERCESC: ${DD4HEP_USE_XERCESC} " ) - message ( STATUS "| XERCESC_ROOT_DIR: ${XERCESC_ROOT_DIR} " ) - message ( STATUS "| DD4HEP_USE_LCIO: ${DD4HEP_USE_LCIO} " ) - message ( STATUS "| LCIO_DIR: ${LCIO_DIR} " ) - message ( STATUS "| DD4HEP_USE_GEANT4: ${DD4HEP_USE_GEANT4} " ) - message ( STATUS "| Geant4_DIR: ${Geant4_DIR} " ) - message ( STATUS "| DD4HEP_USE_PYROOT: ${DD4HEP_USE_PYROOT} " ) - message ( STATUS "| BUILD_TESTING: ${BUILD_TESTING} " ) - message ( STATUS "| " ) - message ( STATUS "+-------------------------------------------------------------------------------" ) + dd4hep_print ( "+-------------------------------------------------------------------------------" ) + dd4hep_print ( "| DD4hep build setup: " ) + dd4hep_print ( "| " ) + dd4hep_print ( "| CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH} " ) + dd4hep_print ( "| DD4HEP_USE_BOOST: ${DD4HEP_USE_BOOST} DD4HEP_USE_Boost:${DD4HEP_USE_Boost}" ) + dd4hep_print ( "| DD4HEP_USE_XERCESC: ${DD4HEP_USE_XERCESC} " ) + dd4hep_print ( "| XERCESC_ROOT_DIR: ${XERCESC_ROOT_DIR} " ) + dd4hep_print ( "| DD4HEP_USE_LCIO: ${DD4HEP_USE_LCIO} " ) + dd4hep_print ( "| LCIO_DIR: ${LCIO_DIR} " ) + dd4hep_print ( "| DD4HEP_USE_GEANT4: ${DD4HEP_USE_GEANT4} " ) + dd4hep_print ( "| Geant4_DIR: ${Geant4_DIR} " ) + dd4hep_print ( "| DD4HEP_USE_PYROOT: ${DD4HEP_USE_PYROOT} " ) + dd4hep_print ( "| BUILD_TESTING: ${BUILD_TESTING} " ) + dd4hep_print ( "| " ) + dd4hep_print ( "+-------------------------------------------------------------------------------" ) endfunction ( dd4hep_print_options ) #--------------------------------------------------------------------------------------------------- @@ -123,28 +154,28 @@ endfunction ( dd4hep_print_options ) function( dd4hep_print_cmake_options ) cmake_parse_arguments ( ARG "" "ERROR" "OPTIONAL" ${ARGN} ) if ( NOT "${ARG_OPTIONAL}" STREQUAL "" ) - message ( STATUS "+---------------------------------------------------------------------------+") + dd4hep_print ( "+---------------------------------------------------------------------------+") foreach ( opt ${ARG_OPTIONAL} ) - message ( STATUS "| ${opt}" ) + dd4hep_print ( "| ${opt}" ) endforeach() endif() - message ( STATUS "+--Option name ------Description ----------------------------------Default-+") - message ( STATUS "| DD4HEP_USE_XERCESC Enable 'Detector Builders' based on XercesC OFF |") - message ( STATUS "| Requires XERCESC_ROOT_DIR to be set |") - message ( STATUS "| or XercesC in CMAKE_MODULE_PATH |") - message ( STATUS "| DD4HEP_USE_GEANT4 Enable the simulation part based on Geant4 OFF |") - message ( STATUS "| Requires Geant_DIR to be set |") - message ( STATUS "| or Geant4 in CMAKE_MODULE_PATH |") - message ( STATUS "| DD4HEP_USE_LCIO Build lcio extensions OFF |") - message ( STATUS "| Requires LCIO_DIR to be set |") - message ( STATUS "| or LCIO in CMAKE_MODULE_PATH |") - message ( STATUS "| DD4HEP_USE_GEAR Build gear wrapper for backward compatibility OFF |") - message ( STATUS "| DD4HEP_USE_CXX11 Build DD4hep using c++11 OFF |") - message ( STATUS "| BUILD_TESTING Enable and build tests ON |") - message ( STATUS "| DD4HEP_USE_PYROOT Enable 'Detector Builders' based on PyROOT OFF |") - message ( STATUS "+---------------------------------------------------------------------------+") + dd4hep_print ( "+--Option name ------Description ----------------------------------Default-+") + dd4hep_print ( "| DD4HEP_USE_XERCESC Enable 'Detector Builders' based on XercesC OFF |") + dd4hep_print ( "| Requires XERCESC_ROOT_DIR to be set |") + dd4hep_print ( "| or XercesC in CMAKE_MODULE_PATH |") + dd4hep_print ( "| DD4HEP_USE_GEANT4 Enable the simulation part based on Geant4 OFF |") + dd4hep_print ( "| Requires Geant_DIR to be set |") + dd4hep_print ( "| or Geant4 in CMAKE_MODULE_PATH |") + dd4hep_print ( "| DD4HEP_USE_LCIO Build lcio extensions OFF |") + dd4hep_print ( "| Requires LCIO_DIR to be set |") + dd4hep_print ( "| or LCIO in CMAKE_MODULE_PATH |") + dd4hep_print ( "| DD4HEP_USE_GEAR Build gear wrapper for backward compatibility OFF |") + dd4hep_print ( "| DD4HEP_USE_CXX11 Build DD4hep using c++11 OFF |") + dd4hep_print ( "| BUILD_TESTING Enable and build tests ON |") + dd4hep_print ( "| DD4HEP_USE_PYROOT Enable 'Detector Builders' based on PyROOT OFF |") + dd4hep_print ( "+---------------------------------------------------------------------------+") if ( NOT "${ARG_ERROR}" STREQUAL "" ) - message ( FATAL_ERROR "Invalid cmake options supplied!" ) + dd4hep_fatal ( "Invalid cmake options supplied!" ) endif() endfunction( dd4hep_print_cmake_options ) @@ -173,7 +204,7 @@ macro ( dd4hep_configure_output ) elseif ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set( CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH "install prefix path - overwrite with -D CMAKE_INSTALL_PREFIX = ..." FORCE ) - message(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" ) + dd4hep_print ( "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" ) endif() dd4hep_debug("|++> Installation goes to: ${CMAKE_INSTALL_PREFIX} <${ARG_INSTALL}>" ) endmacro ( dd4hep_configure_output ) @@ -199,6 +230,8 @@ function ( dd4hep_make_unique_list name ) set( ${name} ${vals} PARENT_SCOPE ) endfunction( dd4hep_make_unique_list ) +#--------------------------------------------------------------------------------------------------- +# dd4hep_find_packageEx # # \author M.Frank # \version 1.0 @@ -218,7 +251,7 @@ function ( dd4hep_find_packageEx PKG_NAME ) set (pkg "DD4hep" ) endif() dd4hep_debug( "Call find_package( ${pkg}/${PKG_NAME} ${ARGN})" ) - ##message(STATUS "Call find_package( ${pkg}/${PKG_NAME} ${ARGN})" ) + ##dd4hep_print ( "Call find_package( ${pkg}/${PKG_NAME} ${ARGN})" ) if ( "${${pkg}_LIBRARIES}" STREQUAL "" ) cmake_parse_arguments(ARG "" "" "ARGS" ${ARGN} ) find_package( ${pkg} ${ARG_ARGS} ) @@ -228,12 +261,11 @@ function ( dd4hep_find_packageEx PKG_NAME ) endif() # Propagate values to caller string ( TOUPPER "${pkg}" PKG ) - if ( "${pkg}" STREQUAL "${PKG}" ) - set ( libs ${${PKG}_LIBRARIES} ${${pkg}_LIBRARY} ${${pkg}_LIBRARIES} ${${pkg}_COMPONENT_LIBRARIES} ) - set ( incs ${${PKG}_INCLUDE_DIRS} ${${pkg}_INCLUDE_DIR} ${${pkg}_INCLUDE_DIRS} ) - else() - set ( libs ${${PKG}_LIBRARIES} ${${pkg}_LIBRARY} ${${pkg}_LIBRARIES} ${${PKG}_LIBRARY} ${${PKG}_LIBRARIES} ${${pkg}_COMPONENT_LIBRARIES} ${${PKG}_COMPONENT_LIBRARIES}) - set ( incs ${${PKG}_INCLUDE_DIRS} ${${pkg}_INCLUDE_DIR} ${${pkg}_INCLUDE_DIRS} ${${PKG}_INCLUDE_DIR} ${${PKG}_INCLUDE_DIRS} ) + set ( libs ${${pkg}_LIBRARY} ${${pkg}_LIBRARIES} ${${pkg}_COMPONENT_LIBRARIES} ) + set ( incs ${${pkg}_INCLUDE_DIR} ${${pkg}_INCLUDE_DIRS} ) + if ( NOT "${pkg}" STREQUAL "${PKG}" ) + set ( libs ${libs} ${${PKG}_LIBRARIES} ${${PKG}_LIBRARY} ${${PKG}_COMPONENT_LIBRARIES} ) + set ( incs ${incs} ${${PKG}_INCLUDE_DIRS} ${${PKG}_INCLUDE_DIR} ) endif() dd4hep_make_unique_list ( libs VALUES ${libs} ) dd4hep_make_unique_list ( incs VALUES ${incs} ) @@ -242,11 +274,10 @@ function ( dd4hep_find_packageEx PKG_NAME ) set ( ${PKG}_LIBRARIES ${libs} PARENT_SCOPE ) set ( ${PKG}_INCLUDE_DIRS ${incs} PARENT_SCOPE ) if ( "${incs}" STREQUAL "" ) - message(FATAL_ERROR "Unknown package ${pkg}") + dd4hep_fatal ( "Unknown package ${pkg}" ) endif() endfunction( dd4hep_find_packageEx ) - #--------------------------------------------------------------------------------------------------- # dd4hep_find_package # @@ -356,19 +387,6 @@ function( dd4hep_install_dir ) endif() endfunction( dd4hep_install_dir ) -#--------------------------------------------------------------------------------------------------- -# dd4hep_install_examples -# -# -# \author M.Frank -# \version 1.0 -# -#--------------------------------------------------------------------------------------------------- -function(dd4hep_install_examples dir_names) - cmake_parse_arguments(ARG "" "DESTINATION" "" ${ARGN} ) - dd4hep_install_dir( ${dir_names} DESTINATION ${ARG_DESTINATION} ) -endfunction(dd4hep_install_examples) - #--------------------------------------------------------------------------------------------------- # dd4hep_install_includes # @@ -380,7 +398,7 @@ endfunction(dd4hep_install_examples) # #--------------------------------------------------------------------------------------------------- function( dd4hep_install_includes package ) - message( STATUS "dd4hep_install_includes[${package}]: ${ARGN}" ) + dd4hep_print ( "dd4hep_install_includes[${package}]: ${ARGN}" ) dd4hep_install_dir( ${ARGN} DESTINATION include ) endfunction() @@ -529,16 +547,16 @@ function (dd4hep_handle_optional_sources tag optionals missing uses sources ) ARGS ${USE_REQUIRED} ${USE_COMPONENT} ${USE_COMPONENTS} TYPE ${USE_TYPE} ) if ( "{pkg_found}" STREQUAL "OFF" ) - message( STATUS "| ${tag} ...optional: Skip sources ${USE_SOURCES} [requires ${USE_NAME}]" ) + dd4hep_print ( "| ${tag} ...optional: Skip sources ${USE_SOURCES} [requires ${USE_NAME}]" ) elseif ( "${pkg_found}" STREQUAL "ON" ) - message( STATUS "| ${tag} ...optional: ADD sources ${USE_SOURCES} [dependent on ${USE_NAME}]" ) + dd4hep_print ( "| ${tag} ...optional: ADD sources ${USE_SOURCES} [dependent on ${USE_NAME}]" ) file ( GLOB opt_sources ${USE_SOURCES} ) set ( src ${src} ${opt_sources} ) set ( use ${use} ${opt} ) elseif ( "${USE_REQUIRED}" STREQUAL "REQUIRED" ) set (miss ${miss} ${USE_NAME} ) else() - message( STATUS "| ${tag} ...optional: Skip sources ${USE_SOURCES} [requires ${USE_NAME}]" ) + dd4hep_print ( "| ${tag} ...optional: Skip sources ${USE_SOURCES} [requires ${USE_NAME}]" ) endif() endforeach() set ( ${missing} ${miss} PARENT_SCOPE ) @@ -580,14 +598,14 @@ function( dd4hep_use_package print_prefix inName outName ) dd4hep_debug ( "${print_prefix} package_libs: ${${use}_LIBRARIES}" ) set ( use ${use} ) elseif ( "{pkg_found}" STREQUAL "OFF" ) - message ( STATUS "|++> ${print_prefix} ...Missing package: ${use} [Ignored]" ) + dd4hep_print ( "|++> ${print_prefix} ...Missing package: ${use} [Ignored]" ) unset ( use ) elseif ( "${USE_REQUIRED}" STREQUAL "REQUIRED" ) - message ( FATAL_ERROR "|++> ${print_prefix} ...Missing package: ${use} [Fatal REQUIRED]" ) + dd4hep_fatal ( "${print_prefix} ...Missing package: ${use} [Fatal REQUIRED]" ) set ( missing ${missing} ${use} ) unset ( use ) else() - message( STATUS "| ${print_prefix} ...optional: Skip sources ${USE_SOURCES} [Usage ${use} not defined]" ) + dd4hep_print ( "| ${print_prefix} ...optional: Skip sources ${USE_SOURCES} [Usage ${use} not defined]" ) unset ( use ) endif() set ( used_uses ${used_uses} ${use} ) @@ -606,7 +624,7 @@ function( dd4hep_use_package print_prefix inName outName ) set ( src ${use} ) endif() if ( NOT "${pkg_found}" STREQUAL "ON" ) - message ( STATUS "| ${print_prefix} ...optional: Skip optional ${src} [${use} Not defined]" ) + dd4hep_print ( "| ${print_prefix} ...optional: Skip optional ${src} [${use} Not defined]" ) unset ( use ) endif() set ( used_uses ${used_uses} ${use} ) @@ -644,9 +662,9 @@ function( dd4hep_use_package print_prefix inName outName ) dd4hep_make_unique_list ( missing VALUES ${missing} ) # if ( "${used_uses}" STREQUAL "" AND "${missing}" STREQUAL "" ) - message(STATUS "|++> ${print_prefix} Uses DEFAULTS" ) + dd4hep_print ( "|++> ${print_prefix} Uses DEFAULTS" ) elseif ( "${missing}" STREQUAL "" ) - message(STATUS "|++> ${print_prefix} Uses: ${used_uses}" ) + dd4hep_print ( "|++> ${print_prefix} Uses: ${used_uses}" ) else() dd4hep_debug ( "${print_prefix} Uses: ${used_uses} " ) dd4hep_debug ( "${print_prefix} Missing:${missing} " ) @@ -707,9 +725,9 @@ function( dd4hep_package packageName ) endforeach() if ( NOT "${missing_uses}" STREQUAL "" ) - message(STATUS "!!!!!!!!!!!! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") - message(STATUS "!!!!!!!!!!!! PACKAGE ${packageName} / ${PKG_NAME} SKIPPED! Missing dependency: ${missing_uses}" ) - message(STATUS "!!!!!!!!!!!! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + dd4hep_skipmsg ( "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + dd4hep_skipmsg ( "PACKAGE ${packageName} / ${PKG_NAME} SKIPPED! Missing dependency: ${missing_uses}" ) + dd4hep_skipmsg ( "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") set ( use "OFF" ) set_property ( GLOBAL PROPERTY DD4HEP_USE_${PKG_NAME} ${use} ) else() @@ -720,7 +738,7 @@ function( dd4hep_package packageName ) dd4hep_to_parent_scope ( ${packageName}_VERSION ) dd4hep_to_parent_scope ( ${packageName}_SOVERSION ) set ( vsn "Version: ( ${${packageName}_VERSION_MAJOR}.${${packageName}_VERSION_MINOR}.${${packageName}_VERSION_PATCH} )" ) - message(STATUS "+------------------------------------------- <<<< PACKAGE ${packageName} >>>> ${vsn}" ) + dd4hep_print ( "+------------------------------------------- <<<< PACKAGE ${packageName} >>>> ${vsn}" ) dd4hep_use_package ( "Package[${packageName}]" PACKAGE PACKAGE USES ${ARG_USES} @@ -776,7 +794,7 @@ function( dd4hep_package packageName ) # dd4hep_install_dir ( ${ARG_INSTALL_INCLUDES} DESTINATION include ) else() - message (FATAL_ERROR "Missing package dependencies: ${PACKAGE_MISSING}" ) + dd4hep_fatal ( "Missing package dependencies: ${PACKAGE_MISSING}" ) endif() endif() # @@ -813,7 +831,7 @@ function( dd4hep_add_library binary building ) endif() if ( "${enabled}" STREQUAL "OFF" ) - message( STATUS "!!!!!!!!!!!! ${tag} DISBALED -- package is not built!" ) + dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() dd4hep_debug( "+------------------------------------------- <<<< LIBRARY ${pkg}:${binary} >>>> Version: ${${pkg}_VERSION}" ) set ( building_binary "OFF" ) @@ -823,14 +841,14 @@ function( dd4hep_add_library binary building ) endif() if ( NOT "${optional_missing}" STREQUAL "" ) - message( STATUS "|++> ${tag} (optional) skipped. Missing dependency: ${optional_missing}" ) + dd4hep_print ( "|++> ${tag} (optional) skipped. Missing dependency: ${optional_missing}" ) else() dd4hep_use_package( "${tag}" PACKAGE LOCAL USES ${ARG_USES} ${optional_uses} OPTIONAL ${ARG_OPTIONAL} ) if ( NOT "${LOCAL_MISSING}" STREQUAL "" ) - message( STATUS "|++> ${tag} skipped. Missing dependency: ${missing}" ) + dd4hep_print ( "|++> ${tag} skipped. Missing dependency: ${missing}" ) endif() set (pkg_incs ${LOCAL_INCLUDE_DIRS} ) set (pkg_libs ${LOCAL_LINK_LIBRARIES} ) @@ -863,9 +881,9 @@ function( dd4hep_add_library binary building ) add_library ( ${binary} SHARED ${sources} ) target_link_libraries ( ${binary} ${pkg_libs} ) if ( "${${pkg}_VERSION}" STREQUAL "" OR "${${pkg}_SOVERSION}" STREQUAL "" ) - message(FATAL_ERROR " BAD Package versions: VERSION[${pkg}_VERSION] ${${pkg}_VERSION} SOVERSION[${pkg}_SOVERSION] ${${pkg}_SOVERSION} " ) + dd4hep_fatal ( "BAD Package versions: VERSION[${pkg}_VERSION] ${${pkg}_VERSION} SOVERSION[${pkg}_SOVERSION] ${${pkg}_SOVERSION} " ) endif() - ##message(STATUS "set_target_properties ( ${binary} PROPERTIES VERSION ${${pkg}_VERSION} SOVERSION ${${pkg}_SOVERSION})") + ##dd4hep_print ( "set_target_properties ( ${binary} PROPERTIES VERSION ${${pkg}_VERSION} SOVERSION ${${pkg}_SOVERSION})") set_target_properties ( ${binary} PROPERTIES VERSION ${${pkg}_VERSION} SOVERSION ${${pkg}_SOVERSION}) # install ( TARGETS ${binary} @@ -873,7 +891,7 @@ function( dd4hep_add_library binary building ) RUNTIME DESTINATION bin) set ( building_binary "ON" ) else() - message( STATUS "|++> ${tag} Skipped. No sources to be compiled [Use constraint]" ) + dd4hep_print ( "|++> ${tag} Skipped. No sources to be compiled [Use constraint]" ) endif() endif() endif() @@ -897,7 +915,7 @@ function( dd4hep_add_package_library library ) dd4hep_package_properties( pkg PKG enabled ) set ( tag "Package library[${pkg}] -> ${library}" ) if ( "${enabled}" STREQUAL "OFF" ) - message( STATUS "!!!!!!!!!!!! ${tag} DISBALED -- package is not built!" ) + dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() dd4hep_add_library( ${library} building ${ARGN} PRINT ${tag} ) if ( "${building}" STREQUAL "ON" ) @@ -908,7 +926,7 @@ function( dd4hep_add_package_library library ) get_property(pkg_libs GLOBAL PROPERTY PROPERTY ${PKG}_LIBRARIES ) dd4hep_debug ( "add_package_library -> ${library} ${PKG}_LIBRARIES:${pkg_libs}" ) else() - message( FATAL_ERROR "|++> Package library[${pkg}] -> ${binary} Cannot be built! This is an ERROR condition." ) + dd4hep_fatal ( "Package library[${pkg}] -> ${binary} Cannot be built! This is an ERROR condition." ) endif() endif() endfunction(dd4hep_add_package_library) @@ -940,7 +958,7 @@ function( dd4hep_add_plugin binary ) dd4hep_package_properties( pkg PKG enabled ) set ( tag "Plugin[${pkg}] -> ${binary}" ) if ( "${enabled}" STREQUAL "OFF" ) - message( STATUS "!!!!!!!!!!!! ${tag} DISBALED -- package is not built!" ) + dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() cmake_parse_arguments(ARG "" "" "SOURCES;GENERATED;LINK_LIBRARIES;INCLUDE_DIRS;USES;OPTIONAL;DEFINITIONS" ${ARGN}) get_property(pkg_lib GLOBAL PROPERTY ${PKG}_LIBRARIES ) @@ -987,7 +1005,7 @@ function ( dd4hep_add_executable binary ) dd4hep_package_properties( pkg PKG enabled ) set ( tag "Executable[${pkg}] -> ${binary}" ) if ( "${enabled}" STREQUAL "OFF" ) - message( STATUS "!!!!!!!!!!!! ${tag} DISBALED -- package is not built!" ) + dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() cmake_parse_arguments ( ARG "" "" "SOURCES;GENERATED;LINK_LIBRARIES;INCLUDE_DIRS;USES;OPTIONAL" ${ARGN}) dd4hep_debug( "+------------------------------------------- <<<< EXECUTABLE ${pkg}:${binary} >>>> Version: ${${pkg}_VERSION}" ) @@ -996,7 +1014,7 @@ function ( dd4hep_add_executable binary ) endif() # if ( NOT "${optional_missing}" STREQUAL "" ) - message( STATUS "|++> ${tag} SKIPPED. Missing optional dependencies: ${optional_missing}" ) + dd4hep_print ( "|++> ${tag} SKIPPED. Missing optional dependencies: ${optional_missing}" ) else() set ( uses ${ARG_USES} ${optional_uses} ) dd4hep_use_package ( ${tag} PACKAGE LOCAL @@ -1032,10 +1050,10 @@ function ( dd4hep_add_executable binary ) LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) else() - message( STATUS "|++> ${tag} SKIPPED. No sources to build [Use constraint]" ) + dd4hep_print ( "|++> ${tag} SKIPPED. No sources to build [Use constraint]" ) endif() else() - message( FATAL_ERROR "|++> ${tag} SKIPPED. Missing dependencies: ${LOCAL_MISSING}" ) + dd4hep_fatal ( "${tag} SKIPPED. Missing dependencies: ${LOCAL_MISSING}" ) endif() endif() endif() @@ -1053,10 +1071,10 @@ function( dd4hep_add_dictionary dictionary ) dd4hep_package_properties( pkg PKG enabled ) set ( tag "Dictionary[${pkg}] -> ${dictionary}" ) if ( "${enabled}" STREQUAL "OFF" ) - message( STATUS "!!!!!!!!!!!! ${tag} DISBALED -- package is not built!" ) + dd4hep_skipmsg ( "${tag} DISBALED -- package is not built!" ) else() cmake_parse_arguments(ARG "" "" "SOURCES;EXCLUDE;LINKDEF;OPTIONS" ${ARGN} ) - message( STATUS "|++> ${tag} Building dictionary ..." ) + dd4hep_print ( "|++> ${tag} Building dictionary ..." ) if("${ARG_LINKDEF}" STREQUAL "") set(ARG_LINKDEF "${CMAKE_SOURCE_DIR}/DDCore/include/ROOT/LinkDef.h") endif() @@ -1065,7 +1083,7 @@ function( dd4hep_add_dictionary dictionary ) file( GLOB excl_headers ${ARG_EXCLUDE} ) foreach( f ${excl_headers} ) list( REMOVE_ITEM headers ${f} ) - message( STATUS "|++ exclude: ${f}" ) + dd4hep_print ( "|++ exclude: ${f}" ) endforeach() # get_property(incs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_INCLUDE_DIRS) @@ -1103,13 +1121,12 @@ function( dd4hep_add_dictionary dictionary ) endif() endfunction() - #--------------------------------------------------------------------------------------------------- macro ( dd4hep_configure_scripts _pkg ) cmake_parse_arguments(MACRO_ARG "DEFAULT_SETUP;WITH_TESTS" "RUN_SCRIPT" "" ${ARGV} ) - message ( STATUS "|++> Setting up test environment: ${ARGV}" ) set( PackageName ${_pkg} ) - if ( ${MACRO_ARG_DEFAULT_SETUP} ) + dd4hep_print ( "|++> Setting up test environment for ${PackageName}: Testing:${BUILD_TESTING} Setup:${MACRO_ARG_DEFAULT_SETUP} With Tests(${WITH_TESTS}): ${MACRO_ARG_UPARSED_ARGUMENTS}" ) + if ( (NOT "${MACRO_ARG_DEFAULT_SETUP}" STREQUAL "") OR (NOT "${PackageName}" STREQUAL "") ) configure_file( ${DD4hep_DIR}/cmake/run_test_package.sh ${EXECUTABLE_OUTPUT_PATH}/run_test_${_pkg}.sh @ONLY) INSTALL(PROGRAMS ${EXECUTABLE_OUTPUT_PATH}/run_test_${_pkg}.sh DESTINATION bin ) #---- configure run environment --------------- @@ -1119,22 +1136,20 @@ macro ( dd4hep_configure_scripts _pkg ) if ( IS_DIRECTORY scripts ) dd4hep_install_dir ( compact scripts DESTINATION examples/${_pkg} ) endif() - if (IS_DIRECTORY compact ) + if ( IS_DIRECTORY compact ) dd4hep_install_dir ( compact DESTINATION examples/${_pkg} ) endif() endif() - if ( ${MACRO_ARG_WITH_TESTS} ) - if ( BUILD_TESTING ) + if ( BUILD_TESTING ) + set ( BUILDNAME "${CMAKE_SYSTEM}-${CMAKE_CXX_COMPILER}-${CMAKE_BUILD_TYPE}" CACHE STRING "set build string for cdash") + if ( NOT "${MACRO_ARG_UPARSED_ARGUMENTS}" STREQUAL "" ) include(CTest) enable_testing () - if ( NOT "${MACRO_ARG_UPARSED_ARGUMENTS}" STREQUAL "" ) - foreach ( dir ${MACRO_ARG_UPARSED_ARGUMENTS} ) - add_subdirectory ( ${dir} ) - endforeach() - endif() - endif(BUILD_TESTING) - set ( BUILDNAME "${CMAKE_SYSTEM}-${CMAKE_CXX_COMPILER}-${CMAKE_BUILD_TYPE}" CACHE STRING "set build string for cdash") - endif() + foreach ( dir ${MACRO_ARG_UPARSED_ARGUMENTS} ) + add_subdirectory ( ${dir} ) + endforeach() + endif() + endif(BUILD_TESTING) unset( PackageName ) endmacro( dd4hep_configure_scripts ) @@ -1146,9 +1161,9 @@ endmacro( dd4hep_configure_scripts ) #--------------------------------------------------------------------------------------------------- macro( dd4hep_enable_tests ) cmake_parse_arguments(MACRO_ARG "" "" "" ${ARGV} ) - #message ( "***|++> Test environment: BUILD_TESTING:${BUILD_TESTING} DIRS:${MACRO_ARG_UNPARSED_ARGUMENTS}" ) + #dd4hep_print ( "***|++> Test environment: BUILD_TESTING:${BUILD_TESTING} DIRS:${MACRO_ARG_UNPARSED_ARGUMENTS}" ) if (BUILD_TESTING) - message ( "***|++> Enable CTest environment....BUILD:${BUILD_TESTING} DIRS:${MACRO_ARG_UNPARSED_ARGUMENTS}" ) + dd4hep_print ( "***|++> Enable CTest environment....BUILD:${BUILD_TESTING} DIRS:${MACRO_ARG_UNPARSED_ARGUMENTS}" ) include(CTest) enable_testing () if ( NOT "${MACRO_ARG_UNPARSED_ARGUMENTS}" STREQUAL "" ) @@ -1179,6 +1194,7 @@ function ( dd4hep_add_test_reg test_name ) cmake_parse_arguments(ARG "BUILD_EXEC" "OUTPUT" "COMMAND;EXEC_ARGS;REGEX_PASS;REGEX_PASSED;REGEX_FAIL;REGEX_FAILED;REQUIRES" ${ARGN} ) set ( missing ) set ( use_test 1 ) + #foreach(opt ${ARG_REQUIRES} ) # dd4hep_unpack_package_opts ( USE ${opt} ) # dd4hep_find_package( ${USE_NAME} pkg_found @@ -1189,11 +1205,12 @@ function ( dd4hep_add_test_reg test_name ) # unset ( use_test ) # endif() #endforeach() + if ( "${use_test}" STREQUAL "" ) - message( STATUS "*** Will not build/execute test ${test_name}. Missing dependencies: ${missing} ") + dd4hep_print ( "*** Will not build/execute test ${test_name}. Missing dependencies: ${missing} ") else() if ( ${ARG_BUILD_EXEC} ) - #message(STATUS "Building executable: ${test_name} SOURCES src/${test_name}.cc") + #dd4hep_print ( "Building executable: ${test_name} SOURCES src/${test_name}.cc") dd4hep_add_executable ( ${test_name} SOURCES src/${test_name}.cc ) endif() diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index 1922bb1a59463c3a5bba58aa1a29cd59987ebac7..ef0f6ebc5749b0cf88f0b491eadb04322334d8f8 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -13,20 +13,27 @@ # @author Jan Engels, Desy ############################################################################## -SET( DD4hep_DIR "@CMAKE_INSTALL_PREFIX@" ) -SET( DD4hep_ROOT "@CMAKE_INSTALL_PREFIX@" ) -SET( DD4hep_VERSION "@DD4hep_VERSION@" ) +set ( DD4hep_DIR "@CMAKE_INSTALL_PREFIX@" ) +set ( DD4hep_ROOT "@CMAKE_INSTALL_PREFIX@" ) +set ( DD4hep_VERSION "@DD4hep_VERSION@" ) +set ( DD4HEP_USE_BOOST "@DD4HEP_USE_BOOST@" ) +set ( DD4HEP_USE_GEANT4 "@DD4HEP_USE_GEANT4@" ) +set ( DD4HEP_USE_XERCESC "@DD4HEP_USE_XERCESC@" ) -INCLUDE( ${DD4hep_DIR}/cmake/DD4hep.cmake ) +set ( Geant4_DIR "@Geant4_DIR@" ) +set ( GEANT4_USE_CLHEP "@GEANT4_USE_CLHEP@" ) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_DIR}/cmake/ ) +include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) + +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_DIR}/cmake ) # ---------- include dirs ----------------------------------------------------- # do not store find results in cache -SET( DD4hep_INCLUDE_DIRS DD4hep_INCLUDE_DIRS-NOTFOUND ) -MARK_AS_ADVANCED( DD4hep_INCLUDE_DIRS ) +set( DD4hep_INCLUDE_DIRS DD4hep_INCLUDE_DIRS-NOTFOUND ) + +mark_as_advanced( DD4hep_INCLUDE_DIRS ) -FIND_PATH( DD4hep_INCLUDE_DIRS +find_path( DD4hep_INCLUDE_DIRS NAMES DD4hep/Detector.h PATHS ${DD4hep_DIR}/include NO_DEFAULT_PATH @@ -39,21 +46,21 @@ endif() # ---------- libraries -------------------------------------------------------- # do not store find results in cache -SET( DD4hep_LIBRARY_DIRS ${DD4hep_DIR}/lib ) -SET( DD4hep_LIBRARIES DD4hep_LIBRARIES-NOTFOUND ) -MARK_AS_ADVANCED( DD4hep_LIBRARY_DIRS DD4hep_LIBRARIES ) +set( DD4hep_LIBRARY_DIRS ${DD4hep_DIR}/lib ) +set( DD4hep_LIBRARIES DD4hep_LIBRARIES-NOTFOUND ) +mark_as_advanced( DD4hep_LIBRARY_DIRS DD4hep_LIBRARIES ) -INCLUDE( ${DD4hep_DIR}/cmake/DD4hepMacros.cmake ) +include( ${DD4hep_DIR}/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_USE_GEANT4@) +if ( ${DD4HEP_USE_GEANT4} ) #--- if geant 4 was built with CLHEP we need to export this to client packages - if( @GEANT4_USE_CLHEP@) - set(GEANT4_USE_CLHEP 1 ) + if( ${GEANT4_USE_CLHEP} ) + set( GEANT4_USE_CLHEP 1 ) endif() - set(Geant4_DIR @Geant4_DIR@) + set(Geant4_DIR ${Geant4_DIR} ) endif() CHECK_PACKAGE_LIBS(DD4hep DDCore) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3946646b53d2924e2e50e94d4ba23d60f4043f04..cb2c22ab4502e047bf042becd8be032c9c6bac55 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,15 +19,16 @@ # cmake .. # # F.Gaede, DESY, 2013 -# +# +# M.Frank, CERN, 2015: Adapt to new cmake scripts #========================================================================== cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) option(BUILD_TESTING "Enable and build tests" ON) +find_package ( DD4hep REQUIRED ) # include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) # -dd4hep_package ( DD4hepExample MAJOR 0 MINOR 0 PATCH 1 ) +dd4hep_package ( DD4hepExample MAJOR 0 MINOR 0 PATCH 1 + USES [ROOT REQUIRED COMPONENTS Geom] ) # -dd4hep_enable_tests ( - AlignDet CLICSiD ClientTests SimpleDetector -) +dd4hep_enable_tests ( AlignDet CLICSiD ClientTests SimpleDetector )