Commit cbfdd163 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Merge branch 'cherry-pick-b3c2a937-2' into '2.0.15-patches'

Cherry-pick "Merge branch 'DictionaryDepImprovements-master-20181127' into 'master'" into 2.0.15-patches

See merge request !406
parents f6fbbaa6 324f2b8f
......@@ -141,16 +141,16 @@ function( atlas_add_dictionary libName libHeader libSelection )
string( REPLACE " " "_" typeSanitised ${typeSanitised} )
# Generate the header file:
configure_file( ${_dataLinkHeader}
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}.h @ONLY )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}.h @ONLY )
# Generate the selection file:
configure_file( ${_dataLinkSelection}
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}_selection.xml
@ONLY )
# And now remember their names:
list( APPEND _headerComponents
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}.h )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}.h )
list( APPEND _selectionComponents
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}_selection.xml )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}_selection.xml )
endforeach()
# If the user asked for additional ElementLink<T> types to generate
......@@ -164,30 +164,30 @@ function( atlas_add_dictionary libName libHeader libSelection )
string( REPLACE " " "_" typeSanitised ${typeSanitised} )
# Generate the header files:
configure_file( ${_dataLinkHeader}
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}.h @ONLY )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}.h @ONLY )
configure_file( ${_elementLinkHeader}
${CMAKE_CURRENT_BINARY_DIR}/ElementLink${typeSanitised}.h @ONLY )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLink${typeSanitised}.h @ONLY )
configure_file( ${_elementLinkVectorHeader}
${CMAKE_CURRENT_BINARY_DIR}/ElementLinkVector${typeSanitised}.h @ONLY )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLinkVector${typeSanitised}.h @ONLY )
# Generate the selection file:
configure_file( ${_dataLinkSelection}
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}_selection.xml
@ONLY )
configure_file( ${_elementLinkSelection}
${CMAKE_CURRENT_BINARY_DIR}/ElementLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLink${typeSanitised}_selection.xml
@ONLY )
configure_file( ${_elementLinkVectorSelection}
${CMAKE_CURRENT_BINARY_DIR}/ElementLinkVector${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLinkVector${typeSanitised}_selection.xml
@ONLY )
# And now remember their names:
list( APPEND _headerComponents
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}.h
${CMAKE_CURRENT_BINARY_DIR}/ElementLink${typeSanitised}.h
${CMAKE_CURRENT_BINARY_DIR}/ElementLinkVector${typeSanitised}.h )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}.h
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLink${typeSanitised}.h
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLinkVector${typeSanitised}.h )
list( APPEND _selectionComponents
${CMAKE_CURRENT_BINARY_DIR}/DataLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}/ElementLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}/ElementLinkVector${typeSanitised}_selection.xml )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DataLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLink${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ElementLinkVector${typeSanitised}_selection.xml )
endforeach()
# If the user asked for additional Navigable<T> types to generate dictionaries
......@@ -200,26 +200,31 @@ function( atlas_add_dictionary libName libHeader libSelection )
string( REPLACE " " "_" typeSanitised ${typeSanitised} )
# Generate the header file:
configure_file( ${_navigableHeader}
${CMAKE_CURRENT_BINARY_DIR}/Navigable${typeSanitised}.h @ONLY )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Navigable${typeSanitised}.h
@ONLY )
# Generate the selection file:
configure_file( ${_navigableSelection}
${CMAKE_CURRENT_BINARY_DIR}/Navigable${typeSanitised}_selection.xml
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Navigable${typeSanitised}_selection.xml
@ONLY )
# And now remember their names:
list( APPEND _headerComponents
${CMAKE_CURRENT_BINARY_DIR}/Navigable${typeSanitised}.h )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Navigable${typeSanitised}.h )
list( APPEND _selectionComponents
${CMAKE_CURRENT_BINARY_DIR}/Navigable${typeSanitised}_selection.xml )
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Navigable${typeSanitised}_selection.xml )
endforeach()
# Prepare the header file:
set( _dictHeader ${CMAKE_CURRENT_SOURCE_DIR}/${libHeader} )
set( _originalDictHeader )
if( _headerComponents )
# Remove the possible duplicates:
list( REMOVE_DUPLICATES _headerComponents )
# The name of the file to produce:
get_filename_component( _headerName ${libHeader} NAME )
set( _dictHeader ${CMAKE_CURRENT_BINARY_DIR}/${_headerName} )
set( _dictHeader
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_headerName} )
set( _originalDictHeader ORIGINAL_HEADER
${CMAKE_CURRENT_SOURCE_DIR}/${libHeader} )
unset( _headerName )
# Generate a text file with the names of the files to merge:
set( _listFileName
......@@ -245,7 +250,8 @@ function( atlas_add_dictionary libName libHeader libSelection )
list( REMOVE_DUPLICATES _selectionComponents )
# The name of the file to produce:
get_filename_component( _selectionName ${libSelection} NAME )
set( _dictSelection ${CMAKE_CURRENT_BINARY_DIR}/${_selectionName} )
set( _dictSelection
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_selectionName} )
unset( _selectionName )
# Describe how to produce this merged selection file:
add_custom_command( OUTPUT ${_dictSelection}
......@@ -280,7 +286,7 @@ function( atlas_add_dictionary libName libHeader libSelection )
HEADER ${_dictHeader} SELECTION ${_dictSelection}
LINK_LIBRARIES ${pkgName}Pkg ${ARG_LINK_LIBRARIES}
INCLUDE_DIRS ${ARG_INCLUDE_DIRS}
${_rootmapOpt} )
${_rootmapOpt} ${_originalDictHeader} )
# The library needs to be linked to the core ROOT libraries:
find_package( ROOT QUIET REQUIRED COMPONENTS Core )
......@@ -627,12 +633,14 @@ endfunction( atlas_add_root_dictionary )
# SELECTION <pkgName>/selection.xml
# [LINK_LIBRARIES Library1...]
# [INCLUDE_DIRS Include1...]
# [ORIGINAL_HEADER <header.h>]
# [NO_ROOTMAP_MERGE] )
#
function( atlas_generate_reflex_dictionary dictfile dictname )
# Parse all options:
cmake_parse_arguments( ARG "NO_ROOTMAP_MERGE" "HEADER;SELECTION"
cmake_parse_arguments( ARG "NO_ROOTMAP_MERGE"
"HEADER;SELECTION;ORIGINAL_HEADER"
"LINK_LIBRARIES;INCLUDE_DIRS" ${ARGN} )
# A security check:
......@@ -717,10 +725,20 @@ function( atlas_generate_reflex_dictionary dictfile dictname )
# The path to the genreflex executable:
set( genreflex ${ROOT_BINARY_PATH}/genreflex )
# The name of the generated dependency file:
set( depfile "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" )
set( depfile "${depfile}/${dictname}ReflexDict.d" )
# The full command to generate the reflex dictionary:
set( cmd "set -e\n" )
set( cmd "${cmd}tmpdir=`mktemp -d make${dictname}ReflexDict.XXXXXX`\n" )
set( cmd "${cmd}cd \${tmpdir}\n" )
set( cmd "${cmd}${CMAKE_CXX_COMPILER} -I\"$<JOIN:${incdirs},\" -I\">\"" )
set( cmd "${cmd} -D$<JOIN:${definitions}, -D>" )
if( CMAKE_OSX_SYSROOT )
set( cmd "${cmd} -isysroot ${CMAKE_OSX_SYSROOT}" )
endif()
set( cmd "${cmd} -MM -MT ${rootmap_name} -MF ${dictname}.d ${ARG_HEADER}\n" )
set( cmd "${cmd}${genreflex} ${ARG_HEADER}" )
set( cmd "${cmd} -o ${dictname}ReflexDict.cxx" )
set( cmd "${cmd} --noIncludePaths" )
......@@ -737,6 +755,9 @@ function( atlas_generate_reflex_dictionary dictfile dictname )
set( cmd "${cmd}${CMAKE_COMMAND} -E copy" )
set( cmd "${cmd} ${CMAKE_SHARED_LIBRARY_PREFIX}${dictname}_rdict.pcm" )
set( cmd "${cmd} \"${pcm_name}\"\n" )
set( cmd "${cmd}${CMAKE_COMMAND} -E compare_files ${dictname}.d \"${depfile}\" ||" )
set( cmd "${cmd} ${CMAKE_COMMAND} -E copy ${dictname}.d" )
set( cmd "${cmd} \"${depfile}\"\n" )
# Generate a script that will run genreflex. This is necessary because
# there are some bugs currently (3.3.2) in how add_custom_command handles
......@@ -746,15 +767,29 @@ function( atlas_generate_reflex_dictionary dictfile dictname )
file( GENERATE OUTPUT ${scriptName}
CONTENT "${cmd}" )
# Extra arguments (for Ninja).
set( extraArgs )
if( "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
set( extraArgs DEPFILE "${depfile}" )
endif()
# Extra implicit dependency, when the header was made during the build.
set( _extraImpDep )
if( ARG_ORIGINAL_HEADER )
set( _extraImpDep CXX ${ARG_ORIGINAL_HEADER} )
endif()
# Call the generated script to create the dictionary files:
add_custom_command( OUTPUT ${rootmap_name}
BYPRODUCTS ${dictsource} ${pcm_name}
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
COMMAND sh ${scriptName}
DEPENDS ${ARG_HEADER} ${ARG_SELECTION} ${pkgName}Pkg
IMPLICIT_DEPENDS CXX ${ARG_HEADER}
DEPENDS ${ARG_HEADER} ${ARG_ORIGINAL_HEADER} ${ARG_SELECTION}
${pkgName}Pkg
IMPLICIT_DEPENDS CXX ${ARG_HEADER} ${_extraImpDep}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}
${extraArgs}
COMMENT "Generating ${dictname}ReflexDict.cxx" )
set_property( SOURCE ${dictsource} ${pcm_name} ${rootmap_name}
PROPERTY LABELS ${pkgName} )
......@@ -764,7 +799,7 @@ function( atlas_generate_reflex_dictionary dictfile dictname )
set_property( TARGET ${dictname}DictGen PROPERTY LABELS ${pkgName} )
set_property( TARGET ${dictname}DictGen PROPERTY FOLDER ${pkgDir}/Internals )
# Set the INCLUDE_DIRECTORIS property on it. To allow the "implicit"
# Set the INCLUDE_DIRECTORIES property on it. To allow the "implicit"
# dependency generator code to find the headers referred to by the
# dictionary header.
set_property( TARGET ${dictname}DictGen
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment