diff --git a/cmake/MacroRootDict.cmake b/cmake/MacroRootDict.cmake index 385ee8a53..c66846a6c 100644 --- a/cmake/MacroRootDict.cmake +++ b/cmake/MacroRootDict.cmake @@ -45,6 +45,27 @@ ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) +# Convert an absolute dictionary input header to the path used to include it. +MACRO( ROOT_DICT_HEADER_INCLUDE_PATH _header _output ) + + SET( ${_output} "${_header}" ) + + IF( IS_ABSOLUTE "${_header}" ) + FOREACH( _include_dir ${ROOT_DICT_INCLUDE_DIRS} ) + IF( IS_ABSOLUTE "${_include_dir}" ) + FILE( RELATIVE_PATH _relative_header "${_include_dir}" "${_header}" ) + IF( NOT _relative_header MATCHES "^\\.\\." ) + SET( ${_output} "${_relative_header}" ) + BREAK() + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + +ENDMACRO( ROOT_DICT_HEADER_INCLUDE_PATH ) + + + # ============================================================================ # helper macro to generate Linkdef.h files for rootcint # @@ -108,13 +129,22 @@ MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) #SET( _dict_includes ${_dict_includes} -I${_inc} ) ENDFOREACH() + # Use relative paths when invoking rootcint. Keep + # ROOT_DICT_INPUT_HEADERS unchanged below because CMake dependencies must + # refer to the original files. + SET( _dict_headers ) + FOREACH( _header ${ROOT_DICT_INPUT_HEADERS} ) + ROOT_DICT_HEADER_INCLUDE_PATH( "${_header}" _dict_header ) + LIST( APPEND _dict_headers "${_dict_header}" ) + ENDFOREACH() + STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} ) SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} ) STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" ) ADD_CUSTOM_COMMAND( OUTPUT ${_dict_src_file} ${_dict_hdr_file} COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR} - COMMAND ${ROOT_rootcint_CMD} -f "${_dict_src_file}" -c ${ROOT_DICT_CINT_DEFINITIONS} ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS} + COMMAND ${ROOT_rootcint_CMD} -f "${_dict_src_file}" -c ${ROOT_DICT_CINT_DEFINITIONS} ${_dict_includes} ${_dict_headers} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" DEPENDS ${ROOT_DICT_INPUT_HEADERS} COMMENT "generating: ${_dict_src_file} ${_dict_hdr_file}" @@ -123,4 +153,3 @@ MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) ENDMACRO() # ============================================================================ - diff --git a/setup.sh b/setup.sh index f4380f226..ced478483 100644 --- a/setup.sh +++ b/setup.sh @@ -13,5 +13,4 @@ for d in lib lib64; do done export PYTHONPATH=$LCIO/python:$PYTHONPATH alias pylcio='python $LCIO/python/pylcio.py' -# Necessary for python bindings to work properly -export CPATH=$LCIO:$LCIO/include:$CPATH +export ROOT_INCLUDE_PATH="$LCIO/include${ROOT_INCLUDE_PATH:+:$ROOT_INCLUDE_PATH}"