Untitled diff

Created Diff never expires
185 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
602 lines
194 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
605 lines
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
# RootNewMacros.cmake
# RootNewMacros.cmake
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
cmake_policy(SET CMP0003 NEW) # See "cmake --help-policy CMP0003" for more details
cmake_policy(SET CMP0003 NEW) # See "cmake --help-policy CMP0003" for more details
cmake_policy(SET CMP0011 NEW) # See "cmake --help-policy CMP0011" for more details
cmake_policy(SET CMP0011 NEW) # See "cmake --help-policy CMP0011" for more details
cmake_policy(SET CMP0009 NEW) # See "cmake --help-policy CMP0009" for more details
cmake_policy(SET CMP0009 NEW) # See "cmake --help-policy CMP0009" for more details
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
cmake_policy(SET CMP0022 OLD) # See "cmake --help-policy CMP0022" for more details
cmake_policy(SET CMP0022 OLD) # See "cmake --help-policy CMP0022" for more details
endif()
endif()




set(THISDIR ${CMAKE_CURRENT_LIST_DIR})
set(THISDIR ${CMAKE_CURRENT_LIST_DIR})


set(lib lib)
set(lib lib)
set(bin bin)
set(bin bin)
if(WIN32)
if(WIN32)
set(ssuffix .bat)
set(ssuffix .bat)
set(scomment rem)
set(scomment rem)
set(libprefix lib)
set(libprefix lib)
set(ld_library_path PATH)
set(ld_library_path PATH)
set(libsuffix .dll)
set(libsuffix .dll)
set(localruntimedir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_BINDIR})
set(runtimedir ${CMAKE_INSTALL_BINDIR})
elseif(APPLE)
elseif(APPLE)
set(ld_library_path DYLD_LIBRARY_PATH)
set(ld_library_path DYLD_LIBRARY_PATH)
set(ssuffix .csh)
set(ssuffix .csh)
set(scomment \#)
set(scomment \#)
set(libprefix lib)
set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX})
set(libsuffix .so)
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(libsuffix .so)
else()
set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_LIBDIR})
set(runtimedir ${CMAKE_INSTALL_LIBDIR})
else()
else()
set(ld_library_path LD_LIBRARY_PATH)
set(ld_library_path LD_LIBRARY_PATH)
set(ssuffix .csh)
set(ssuffix .csh)
set(scomment \#)
set(scomment \#)
set(libprefix lib)
set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX})
set(libsuffix .so)
set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(runtimedir ${CMAKE_INSTALL_LIBDIR})
set(runtimedir ${CMAKE_INSTALL_LIBDIR})
endif()
endif()


if(soversion)
if(soversion)
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
VERSION ${ROOT_VERSION}
VERSION ${ROOT_VERSION}
SOVERSION ${ROOT_MAJOR_VERSION}
SOVERSION ${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION}
SUFFIX ${libsuffix}
SUFFIX ${libsuffix}
PREFIX ${libprefix} )
PREFIX ${libprefix} )
else()
else()
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
SUFFIX ${libsuffix}
SUFFIX ${libsuffix}
PREFIX ${libprefix}
PREFIX ${libprefix}
IMPORT_PREFIX ${libprefix} )
IMPORT_PREFIX ${libprefix} )
endif()
endif()


#---Modify the behaviour for local and non-local builds--------------------------------------------
#---Modify the behaviour for local and non-local builds--------------------------------------------


if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(rootcint_cmd rootcling_tmp)
set(rootcint_cmd rootcling_stage1)
set(rlibmap_cmd rlibmap)
set(genreflex_cmd genreflex)
set(genreflex_cmd genreflex)
set(ROOTCINTDEP rootcling_tmp)
set(ROOTCINTDEP rootcling_stage1)
else()
else()
set(rootcint_cmd rootcling)
set(rootcint_cmd rootcling)
set(rlibmap_cmd rlibmap)
set(genreflex_cmd genreflex)
set(genreflex_cmd genreflex)
set(ROOTCINTDEP)
set(ROOTCINTDEP)
endif()
endif()


set(CMAKE_VERBOSE_MAKEFILES OFF)
set(CMAKE_VERBOSE_MAKEFILES OFF)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)


include(CMakeParseArguments)
include(CMakeParseArguments)


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#---ROOT_GLOB_FILES( <variable> [REALTIVE path] [FILTER regexp] <sources> ...)
#---ROOT_GLOB_FILES( <variable> [REALTIVE path] [FILTER regexp] <sources> ...)
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function(ROOT_GLOB_FILES variable)
function(ROOT_GLOB_FILES variable)
CMAKE_PARSE_ARGUMENTS(ARG "" "RELATIVE;FILTER" "" ${ARGN})
CMAKE_PARSE_ARGUMENTS(ARG "RECURSE" "RELATIVE;FILTER" "" ${ARGN})
set(_possibly_recurse "")
if (ARG_RECURSE)
set(_possibly_recurse "_RECURSE")
endif()
if(ARG_RELATIVE)
if(ARG_RELATIVE)
file(GLOB _sources RELATIVE ${ARG_RELATIVE} ${ARG_UNPARSED_ARGUMENTS})
file(GLOB${_possibly_recurse} _sources RELATIVE ${ARG_RELATIVE} ${ARG_UNPARSED_ARGUMENTS})
else()
else()
file(GLOB _sources ${ARG_UNPARSED_ARGUMENTS})
file(GLOB${_possibly_recurse} _sources ${ARG_UNPARSED_ARGUMENTS})
endif()
endif()
if(ARG_FILTER)
if(ARG_FILTER)
foreach(s ${_sources})
foreach(s ${_sources})
if(s MATCHES ${ARG_FILTER})
if(s MATCHES ${ARG_FILTER})
list(REMOVE_ITEM _sources ${s})
list(REMOVE_ITEM _sources ${s})
endif()
endif()
endforeach()
endforeach()
endif()
endif()
set(${variable} ${_sources} PARENT_SCOPE)
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
endfunction()


function(ROOT_GLOB_SOURCES variable)
function(ROOT_GLOB_SOURCES variable)
ROOT_GLOB_FILES(_sources FILTER "(^|/)G__" ${ARGN})
ROOT_GLOB_FILES(_sources FILTER "(^|/)G__" ${ARGN})
set(${variable} ${_sources} PARENT_SCOPE)
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
endfunction()


function(ROOT_GLOB_HEADERS variable)
function(ROOT_GLOB_HEADERS variable)
ROOT_GLOB_FILES(_sources FILTER "LinkDef" ${ARGN})
ROOT_GLOB_FILES(_sources FILTER "LinkDef" ${ARGN})
set(${variable} ${_sources} PARENT_SCOPE)
set(${variable} ${_sources} PARENT_SCOPE)
endfunction()
endfunction()


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#---ROOT_GET_SOURCES( <variable> cwd <sources> ...)
#---ROOT_GET_SOURCES( <variable> cwd <sources> ...)
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function(ROOT_GET_SOURCES variable cwd )
function(ROOT_GET_SOURCES variable cwd )
set(sources)
set(sources)
foreach( fp ${ARGN})
foreach( fp ${ARGN})
if( IS_ABSOLUTE ${fp})
if( IS_ABSOLUTE ${fp})
file(GLOB files ${fp})
file(GLOB files ${fp})
else()
else()
if(root7)
if(root7)
set(root7glob v7/src/${fp})
set(root7glob v7/src/${fp})
endif()
endif()
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${cwd}/${fp} ${root7glob})
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${cwd}/${fp} ${root7glob})
endif()
endif()
if(files)
if(files)
foreach(s ${files})
foreach(s ${files})
if(fp MATCHES "[*]" AND s MATCHES "(^|/)G__") # Eliminate G__* files
if(fp MATCHES "[*]" AND s MATCHES "(^|/)G__") # Eliminate G__* files
elseif(s MATCHES "${cwd}/G__")
elseif(s MATCHES "${cwd}/G__")
set(sources ${fp} ${sources})
set(sources ${fp} ${sources})
else()
else()
set(sources ${sources} ${s})
set(sources ${sources} ${s})
endif()
endif()
endforeach()
endforeach()
else()
else()
if(fp MATCHES "(^|/)G__")
if(fp MATCHES "(^|/)G__")
set(sources ${fp} ${sources})
set(sources ${fp} ${sources})
else()
else()
set(sources ${sources} ${fp})
set(sources ${sources} ${fp})
endif()
endif()
endif()
endif()
endforeach()
endforeach()
set(${variable} ${sources} PARENT_SCOPE)
set(${variable} ${sources} PARENT_SCOPE)
endfunction()
endfunction()


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#---REFLEX_GENERATE_DICTIONARY( dictionary headerfiles SELECTION selectionfile OPTIONS opt1 opt2 ...)
#---REFLEX_GENERATE_DICTIONARY( dictionary headerfiles SELECTION selectionfile OPTIONS opt1 opt2 ...)
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
macro(REFLEX_GENERATE_DICTIONARY dictionary)
macro(REFLEX_GENERATE_DICTIONARY dictionary)
CMAKE_PARSE_ARGUMENTS(ARG "" "SELECTION" "OPTIONS" ${ARGN})
CMAKE_PARSE_ARGUMENTS(ARG "" "SELECTION" "OPTIONS" ${ARGN})
#---Get List of header files---------------
#---Get List of header files---------------
set(headerfiles)
set(headerfiles)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
file(GLOB files inc/${fp})
file(GLOB files inc/${fp})
if(files)
if(files)
foreach(f ${files})
foreach(f ${files})
if(NOT f MATCHES LinkDef)
if(NOT f MATCHES LinkDef)
set(headerfiles ${headerfiles} ${f})
set(headerfiles ${headerfiles} ${f})
endif()
endif()
endforeach()
endforeach()
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
set(headerfiles ${headerfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
set(headerfiles ${headerfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
else()
else()
set(headerfiles ${headerfiles} ${fp})
set(headerfiles ${headerfiles} ${fp})
endif()
endif()
endforeach()
endforeach()
#---Get Selection file------------------------------------
#---Get Selection file------------------------------------
if(IS_ABSOLUTE ${ARG_SELECTION})
if(IS_ABSOLUTE ${ARG_SELECTION})
set(selectionfile ${ARG_SELECTION})
set(selectionfile ${ARG_SELECTION})
else()
else()
set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION})
set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION})
endif()
endif()


set(gensrcdict ${dictionary}.cxx)
set(gensrcdict ${dictionary}.cxx)


#---roottest compability---------------------------------
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_NOROOTMAP)
if(CMAKE_ROOTTEST_NOROOTMAP)
set(rootmapname )
set(rootmapname )
set(rootmapopts )
set(rootmapopts )
elseif(DEFINED CMAKE_ROOTTEST_NOROOTMAP) # Follow the roottest dictionary library naming
elseif(DEFINED CMAKE_ROOTTEST_NOROOTMAP) # Follow the roottest dictionary library naming
set(rootmapname ${dictionary}.rootmap)
set(rootmapname ${dictionary}.rootmap)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}_dictrflx)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}_dictrflx)
else()
else()
set(rootmapname ${dictionary}Dict.rootmap)
set(rootmapname ${dictionary}Dict.rootmap)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict)
set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict)
endif()
endif()


set(include_dirs -I${CMAKE_CURRENT_SOURCE_DIR})
set(include_dirs -I${CMAKE_CURRENT_SOURCE_DIR})
get_directory_property(incdirs INCLUDE_DIRECTORIES)
get_directory_property(incdirs INCLUDE_DIRECTORIES)
foreach( d ${incdirs})
foreach( d ${incdirs})
set(include_dirs ${include_dirs} -I${d})
set(include_dirs ${include_dirs} -I${d})
endforeach()
endforeach()


get_directory_property(defs COMPILE_DEFINITIONS)
get_directory_property(defs COMPILE_DEFINITIONS)
foreach( d ${defs})
foreach( d ${defs})
set(definitions ${definitions} -D${d})
set(definitions ${definitions} -D${d})
endforeach()
endforeach()


add_custom_command(
add_custom_command(
OUTPUT ${gensrcdict} ${rootmapname}
OUTPUT ${gensrcdict} ${rootmapname}
COMMAND ${ROOT_genreflex_CMD}
COMMAND ${ROOT_genreflex_CMD}
ARGS ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile}
ARGS ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile}
--gccxmlpath=${GCCXML_home}/bin ${ARG_OPTIONS} ${include_dirs} ${definitions}
--gccxmlpath=${GCCXML_home}/bin ${ARG_OPTIONS} ${include_dirs} ${definitions}
DEPENDS ${headerfiles} ${selectionfile})
DEPENDS ${headerfiles} ${selectionfile})


#---roottest compability---------------------------------
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_DICT)
if(CMAKE_ROOTTEST_DICT)
ROOTTEST_TARGETNAME_FROM_FILE(targetname ${dictionary})
ROOTTEST_TARGETNAME_FROM_FILE(targetname ${dictionary})


set(targetname "${targetname}-dictgen")
set(targetname "${targetname}-dictgen")


add_custom_target(${targetname} DEPENDS ${gensrcdict} ${ROOT_LIBRARIES})
add_custom_target(${targetname} DEPENDS ${gensrcdict} ${ROOT_LIBRARIES})
else()
else()
set(targetname "${dictionary}-dictgen")
set(targetname "${dictionary}-dictgen")
# Creating this target at ALL level enables the possibility to generate dictionaries (genreflex step)
# Creating this target at ALL level enables the possibility to generate dictionaries (genreflex step)
# well before the dependent libraries of the dictionary are build
# well before the dependent libraries of the dictionary are build
add_custom_target(${targetname} ALL DEPENDS ${gensrcdict})
add_custom_target(${targetname} ALL DEPENDS ${gensrcdict})
endif()
endif()


endmacro()
endmacro()


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#---ROOT_GENERATE_DICTIONARY( dictionary headerfiles MODULE module DEPENDENCIES dep1 dep2
#---ROOT_GENERATE_DICTIONARY( dictionary headerfiles MODULE module DEPENDENCIES dep1 dep2
# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...)
# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...)
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function(ROOT_GENERATE_DICTIONARY dictionary)
function(ROOT_GENERATE_DICTIONARY dictionary)
CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT" "MODULE" "LINKDEF;OPTIONS;DEPENDENCIES" ${ARGN})
CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL" "MODULE" "LINKDEF;OPTIONS;DEPENDENCIES" ${ARGN})

# Check if OPTIONS start with a dash.
if (ARG_OPTIONS)
foreach(ARG_O ${ARG_OPTIONS})
if (NOT ARG_O MATCHES "^-*")
message(FATAL_ERROR "Wrong rootcling option: ${ARG_OPTIONS}")
endif()
endforeach()
endif(ARG_OPTIONS)


#---roottest compability---------------------------------
#---roottest compability---------------------------------
if(CMAKE_ROOTTEST_DICT)
if(CMAKE_ROOTTEST_DICT)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INSTALL_LIBDIR ${CMAKE_CURRENT_BINARY_DIR})
set(libprefix "")
set(libprefix "")
endif()
endif()


#---Get the list of include directories------------------
get_directory_property(incdirs INCLUDE_DIRECTORIES)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
set(localinclude ${CMAKE_CURRENT_SOURCE_DIR}/inc)
endif()
#---Get the list of header files-------------------------
#---Get the list of header files-------------------------
set(headerfiles)
set(headerfiles)
set(_list_of_header_dependencies)
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
foreach(fp ${ARG_UNPARSED_ARGUMENTS})
file(GLOB files inc/${fp})
if(${fp} MATCHES "[*?]") # Is this header a globbing expression?
if(files)
file(GLOB files inc/${fp} ${fp})
foreach(f ${files})
foreach(f ${files})
if(NOT f MATCHES LinkDef)
if(NOT f MATCHES LinkDef) # skip LinkDefs from globbing result
set(headerfiles ${headerfiles} ${f})
list(APPEND headerfiles ${f})
list(APPEND _list_of_header_dependencies ${f})
endif()
endif()
endforeach()
endforeach()
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
elseif(CMAKE_PROJECT_NAME STREQUAL ROOT AND
set(headerfiles ${headerfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp}) # only for ROOT project
list(APPEND headerfiles ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
list(APPEND _list_of_header_dependencies ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
elseif(IS_ABSOLUTE ${fp})
list(APPEND headerfiles ${fp})
list(APPEND _list_of_header_dependencies ${fp})
else()
else()
set(headerfiles ${headerfiles} ${fp})
find_file(headerFile ${fp} HINTS ${localinclude} ${incdirs})
list(APPEND headerfiles ${fp})
if(headerFile)
list(APPEND _list_of_header_dependencies ${headerFile})
endif()
unset(headerFile CACHE)
endif()
endif()
endforeach()
endforeach()
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" rheaderfiles "${headerfiles}")
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" headerfiles "${headerfiles}")
#---Get the list of include directories------------------
# Replace the non-standard folder layout of Core.
get_directory_property(incdirs INCLUDE_DIRECTORIES)
if (ARG_STAGE1 AND ARG_MODULE STREQUAL "Core")
# FIXME: Glob these folders.
set(core_folders "base|clib|clingutils|cont|dictgen|doc|foundation|lzma|lz4|macosx|meta|metacling|multiproc|newdelete|pcre|rint|rootcling_stage1|textinput|thread|unix|winnt|zip")
string(REGEX REPLACE "${CMAKE_SOURCE_DIR}/core/(${core_folders})/inc/" "" headerfiles "${headerfiles}")
endif()

if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(includedirs -I${CMAKE_SOURCE_DIR}
set(includedirs -I${CMAKE_SOURCE_DIR}
-I${CMAKE_SOURCE_DIR}/interpreter/cling/include # This is for the RuntimeUniverse
-I${CMAKE_BINARY_DIR}/include)
-I${CMAKE_BINARY_DIR}/include)
set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
set(includedirs -I${CMAKE_CURRENT_SOURCE_DIR}/inc)
set(includedirs -I${CMAKE_CURRENT_SOURCE_DIR}/inc)
endif()
endif()
foreach( d ${incdirs})
foreach( d ${incdirs})
set(includedirs ${includedirs} -I${d})
set(includedirs ${includedirs} -I${d})
endforeach()
endforeach()
list(REMOVE_DUPLICATES includedirs)
list(REMOVE_DUPLICATES includedirs)
#---Get the list of definitions---------------------------
#---Get the list of definitions---------------------------
get_directory_property(defs COMPILE_DEFINITIONS)
get_directory_property(defs COMPILE_DEFINITIONS)
foreach( d ${defs})
foreach( d ${defs})
if((NOT d MATCHES "=") AND (NOT d MATCHES "^[$]<.*>$")) # avoid generator expressions
if((NOT d MATCHES "=") AND (NOT d MATCHES "^[$]<.*>$")) # avoid generator expressions
set(definitions ${definitions} -D${d})
set(definitions ${definitions} -D${d})
endif()
endif()
endforeach()
endforeach()
#---Get LinkDef.h file------------------------------------
#---Get LinkDef.h file------------------------------------
foreach( f ${ARG_LINKDEF})
foreach( f ${ARG_LINKDEF})
if( IS_ABSOLUTE ${f})
if( IS_ABSOLUTE ${f})
set(_linkdef ${_linkdef} ${f})
set(_linkdef ${_linkdef} ${f})
else()
else()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
else()
else()
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f})
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f})
endif()
endif()
endif()
endif()
endforeach()
endforeach()


#---Build the names for library, pcm and rootmap file ----
#---Build the names for library, pcm and rootmap file ----
get_filename_component(dict_base_name ${dictionary} NAME_WE)
get_filename_component(dict_base_name ${dictionary} NAME_WE)
if(dict_base_name MATCHES "^G__")
if(dict_base_name MATCHES "^G__")
string(SUBSTRING ${dictionary} 3 -1 deduced_arg_module)
string(SUBSTRING ${dictionary} 3 -1 deduced_arg_module)
else()
else()
set(deduced_arg_module ${dict_base_name})
set(deduced_arg_module ${dict_base_name})
endif()
endif()


#---Set the library output directory-----------------------
#---Set the library output directory-----------------------
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY AND NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY STREQUAL "")
set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
else()
set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR})
set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()


if(ARG_MODULE)
if(ARG_MODULE)
set(library_name ${libprefix}${ARG_MODULE}${libsuffix})
set(library_name ${libprefix}${ARG_MODULE}${libsuffix})
if(ARG_MULTIDICT)
if(ARG_MULTIDICT)
set(newargs -s ${library_output_dir}/${library_name} -multiDict)
set(newargs -s ${library_output_dir}/${library_name} -multiDict)
set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_${dictionary}_rdict.pcm)
set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_${dictionary}_rdict.pcm)
set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap)
set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap)
else()
else()
set(newargs -s ${library_output_dir}/${library_name})
set(newargs -s ${library_output_dir}/${library_name})
set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_rdict.pcm)
set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_rdict.pcm)
set(rootmap_name ${library_output_dir}/${libprefix}${ARG_MODULE}.rootmap)
set(rootmap_name ${library_output_dir}/${libprefix}${ARG_MODULE}.rootmap)
endif()
endif()
else()
else()
set(library_name ${libprefix}${deduced_arg_module}${libsuffix})
set(library_name ${libprefix}${deduced_arg_module}${libsuffix})
set(pcm_name ${dictionary}_rdict.pcm)
set(newargs -s ${library_output_dir}/${library_name})
set(pcm_name ${library_output_dir}/${libprefix}${deduced_arg_module}_rdict.pcm)
set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap)
set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap)
endif()
endif()


if(CMAKE_ROOTTEST_NOROOTMAP)
if(CMAKE_ROOTTEST_NOROOTMAP)
set(rootmapname )
set(rootmapname )
set(rootmapargs )
set(rootmapargs )
else()
else()
set(rootmapargs -rml ${library_name} -rmf ${rootmap_name})
set(rootmapargs -rml ${library_name} -rmf ${rootmap_name})
endif()
endif()


#---Get the library and module dependencies-----------------
#---Get the library and module dependencies-----------------
if(ARG_DEPENDENCIES)
if(ARG_DEPENDENCIES)
foreach(dep ${ARG_DEPENDENCIES})
foreach(dep ${ARG_DEPENDENCIES})
set(newargs ${newargs} -m ${libprefix}${dep}_rdict.pcm)
set(newargs ${newargs} -m ${libprefix}${dep}_rdict.pcm)
endforeach()
endforeach()
endif()
endif()


#---what rootcling command to use--------------------------
#---what rootcling command to use--------------------------
if(ARG_STAGE1)
if(ARG_STAGE1)
set(command rootcling_tmp)
set(command rootcling_stage1)
set(pcm_name)
set(pcm_name)
else()
else()
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(command rootcling -rootbuild)
set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
set(ROOTCINTDEP rootcling)
set(ROOTCINTDEP rootcling)
else()
else()
set(command rootcling)
set(command rootcling)
endif()
endif()
endif()
endif()


#---build the path exclusion switches----------------------
set(excludepathsargs "")
foreach(excludepath ${excludepaths})
set(excludepathsargs ${excludepathsargs} -excludePath ${excludepath})
endforeach()

#---build the implicit dependencies arguments
foreach(_dep ${_linkdef} ${_list_of_header_dependencies})
list(APPEND _implicitdeps CXX ${_dep})
endforeach()

#---call rootcint------------------------------------------
#---call rootcint------------------------------------------
add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name}
add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name}
COMMAND ${command} -f ${dictionary}.cxx ${newargs} ${rootmapargs}
COMMAND ${command} -f ${dictionary}.cxx ${newargs} ${excludepathsargs} ${rootmapargs}
${ARG_OPTIONS} ${definitions} ${includedirs} ${rheaderfiles} ${_linkdef}
${ARG_OPTIONS} ${definitions} ${includedirs} ${headerfiles} ${_linkdef}
IMPLICIT_DEPENDS CXX ${_linkdef}
IMPLICIT_DEPENDS ${_implicitdeps}
DEPENDS ${headerfiles} ${_linkdef} ${ROOTCINTDEP})
DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP})
get_filename_component(dictname ${dictionary} NAME)
get_filename_component(dictname ${dictionary} NAME)


#---roottest compability
#---roottest compability
if(CMAKE_ROOTTEST_DICT OR (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY))
if(ARG_NOINSTALL OR CMAKE_ROOTTEST_DICT OR (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY))
add_custom_target(${dictname} DEPENDS ${dictionary}.cxx)
add_custom_target(${dictname} DEPENDS ${dictionary}.cxx)
else()
else()
add_custom_target(${dictname} DEPENDS ${dictionary}.cxx)
add_custom_target(${dictname} DEPENDS ${dictionary}.cxx)


set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_TARGETS ${dictname})
set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_TARGETS ${dictname})
set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_FILES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx)
set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_FILES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx)


if(ARG_STAGE1)
if(ARG_STAGE1)
install(FILES ${rootmap_name}
install(FILES ${rootmap_name}
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
else()
else()
install(FILES ${pcm_name} ${rootmap_name}
install(FILES ${pcm_name} ${rootmap_name}
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
endif()
endif()
endif()
if(cxxmodules)
# FIXME: Support mulptiple dictionaries. In some cases (libSMatrix and
# libGenVector) we have to have two or more dictionaries (eg. for math,
# we need the two for double vs Double32_t template specializations).
# In some other cases, eg. libTreePlayer.so we add in a separate dictionary
# files which for some reason (temporarily?) cannot be put in the PCH. Eg.
# all rest of the first dict is in the PCH but this file is not and it
# cannot be present in the original dictionary.
if(NOT ARG_MULTIDICT)
ROOT_CXXMODULES_APPEND_TO_MODULEMAP("${library_name}" "${headerfiles}")
endif()
endif(cxxmodules)
endfunction()
endfunction()


#---------------------------------------------------------------------------------------------------
#---ROOT_CXXMODULES_APPEND_TO_MODULEMAP( library library_headers )
#---------------------------------------------------------------------------------------------------
function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers)
if(NOT cxxmodules)
message(FATAL_ERROR "Calling ROOT_CXXMODULES_APPEND_TO_MODULEMAP on non-modules build.")
endif()

ROOT_FIND_DIRS_WITH_HEADERS(dirs)

# Variable 'dirs' is the return result of ROOT_FIND_DIRS_WITH_HEADERS.
if(NOT DEFINED dirs)
message(SEND_ERROR "Error, the variable ${dirs} is not defined!")
endif()

set(found_headers "")
set(dir_headers "")
foreach(d ${dirs})
ROOT_GLOB_FILES(dir_headers
RECURSE
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d}
FILTER "LinkDef" ${d}/*)
list(APPEND found_headers "${dir_headers}")
endforeach()

if (APPLE)
# FIXME: Krb5Auth.h triggers "declaration of '__mb_cur_max' has a different language linkage"
# problem.
# FIXME: error: declaration of 'NSObject' must be imported from module 'ROOT.libBonjour.so.TBonjourBrowser.h' before it is required
if (${library} MATCHES "libKrb5Auth.so" OR ${library} MATCHES "(libGCocoa|libGQuartz)\..*")
return()
endif()
endif(APPLE)

set(excluded_headers "RConfig.h RVersion.h RtypesImp.h TVersionCheck.h
Rtypes.h RtypesCore.h TClassEdit.h
TIsAProxy.h TVirtualIsAProxy.h
DllImport.h TGenericClassInfo.h
TSchemaHelper.h ESTLType.h RStringView.h Varargs.h
RootMetaSelection.h libcpp_string_view.h
RWrap_libcpp_string_view.h
TException.h ThreadLocalStorage.h
TBranchProxyTemplate.h TGLIncludes.h TGLWSIncludes.h
snprintf.h strlcpy.h")

# Deprecated header files.
set (excluded_headers "${excluded_headers} TSelectorCint.h")

set(modulemap_entry "module \"${library}\" {")
# For modules GCocoa and GQuartz we need objc context.
if (${library} MATCHES "(libGCocoa|libGQuartz)\..*")
set (modulemap_entry "${modulemap_entry}\n requires objc\n")
else()
set (modulemap_entry "${modulemap_entry}\n requires cplusplus\n")
endif()
if (library_headers)
set(found_headers ${library_headers})
endif()
foreach(header ${found_headers})
#message (STATUS "header: ${header}")
set(textual_header "")
if (${header} MATCHES ".*\.icc$")
set(textual_header "textual ")
endif()
if (NOT ${excluded_headers} MATCHES ${header})
set(modulemap_entry "${modulemap_entry} module \"${header}\" { ${textual_header}header \"${header}\" export * }\n")
endif()
endforeach()
#set(modulemap_entry "${modulemap_entry} link \"lib/${library}\"\n")
set(modulemap_entry "${modulemap_entry} export *\n}\n\n")
set_property(GLOBAL APPEND PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT ${modulemap_entry})
endfunction()


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#---ROOT_LINKER_LIBRARY( <name> source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT]
#---ROOT_LINKER_LIBRARY( <name> source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT]
# [NOINSTALL] LIBRARIES library1 library2 ...)
# [NOINSTALL] LIBRARIES library1 library2 ...
# BUILTINS dep1 dep2)
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function(ROOT_LINKER_LIBRARY library)
function(ROOT_LINKER_LIBRARY library)
CMAKE_PARSE_ARGUMENTS(ARG "DLLEXPORT;CMAKENOEXPORT;TEST;NOINSTALL" "TYPE" "LIBRARIES;DEPENDENCIES" ${ARGN})
CMAKE_PARSE_ARGUMENTS(ARG "DLLEXPORT;CMAKENOEXPORT;TEST;NOINSTALL" "TYPE" "LIBRARIES;DEPENDENCIES;BUILTINS" ${ARGN})
ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS})
ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS})
if(NOT ARG_TYPE)
if(NOT ARG_TYPE)
set(ARG_TYPE SHARED)
set(ARG_TYPE SHARED)
endif()
endif()
if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL
if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL
set(_all EXCLUDE_FROM_ALL)
set(_all EXCLUDE_FROM_ALL)
endif()
endif()
include_directories(${CMAKE_BINARY_DIR}/include) # This is a copy and certainly should last one
include_directories(BEFORE ${CMAKE_BINARY_DIR}/include)
set(library_name ${library})
set(library_name ${library})
if(TARGET ${library})
if(TARGET ${library})
message("Target ${library} already exists. Renaming target name to ${library}_new")
message("Target ${library} already exists. Renaming target name to ${library}_new")
set(library ${library}_new)
set(library ${library}_new)
endif()
endif()
if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT)
if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT)
#---create a list of all the object files-----------------------------
#---create a list of all the object files-----------------------------
if(CMAKE_GENERATOR MATCHES "Visual Studio")
if(CMAKE_GENERATOR MATCHES "Visual Studio")
#foreach(src1 ${lib_srcs})
#foreach(src1 ${lib_srcs})
# if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$")
# if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$")
# string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1})
# string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1})
# string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2})
# string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2})
# string (REPLACE ".." "__" src ${src3})
# string (REPLACE ".." "__" src ${src3})
# get_filename_component(name ${src} NAME_WE)
# get_filename_component(name ${src} NAME_WE)
# set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/${name}.obj)
# set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/${name}.obj)
# endif()
# endif()
#endforeach()
#endforeach()
set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/*.obj)
set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/*.obj)
else()
else()
foreach(src1 ${lib_srcs})
foreach(src1 ${lib_srcs})
if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$")
if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$")
string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1})
string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1})
string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2})
string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2})
string (REPLACE ".." "__" src ${src3})
string (REPLACE ".." "__" src ${src3})
get_filename_component(name ${src} NAME)
get_filename_component(name ${src} NAME)
get_filename_component(path ${src} PATH)
get_filename_component(path ${src} PATH)
set(lib_objs ${lib_objs} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${path}/${name}.obj)
set(lib_objs ${lib_objs} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${path}/${name}.obj)
endif()
endif()
endforeach()
endforeach()
endif()
endif()
#---create a shared library with the .def file------------------------
#---create a shared library with the .def file------------------------
add_library(${library} ${_all} SHARED ${lib_srcs})
add_library(${library} ${_all} SHARED ${lib_srcs})
target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES})
target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES})
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} LINK_FLAGS -DEF:${library}.def)
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} LINK_FLAGS -DEF:${library}.def)

#---set the .def file as generated------------------------------------
#---set the .def file as generated------------------------------------
set_source_files_properties(${library}.def PROPERTIES GENERATED 1)
set_source_files_properties(${library}.def PROPERTIES GENERATED 1)
#---create a custom pre-link command that runs bindexplib
#---create a custom pre-link command that runs bindexplib
add_custom_command(TARGET ${library} PRE_LINK
add_custom_command(TARGET ${library} PRE_LINK
COMMAND bindexplib
COMMAND bindexplib
ARGS -o ${library}.def ${libprefix}${library} ${lib_objs}
ARGS -o ${library}.def ${libprefix}${library} ${lib_objs}
DEPENDS bindexplib )
DEPENDS bindexplib )
else()
else()
#---Need to add a dummy source file if all sources are OBJECT libraries (Xcode, ...)
#---Need to add a dummy source file if all sources are OBJECT libraries (Xcode, ...)
if(NOT lib_srcs MATCHES "(^|[;])[^$][^<]")
if(NOT lib_srcs MATCHES "(^|[;])[^$][^<]")
add_custom_command(OUTPUT dummy.cxx COMMAND ${CMAKE_COMMAND} -E touch dummy.cxx)
add_custom_command(OUTPUT dummy.cxx COMMAND ${CMAKE_COMMAND} -E touch dummy.cxx)
set(lib_srcs ${lib_srcs} dummy.cxx)
set(lib_srcs ${lib_srcs} dummy.cxx)
endif()
endif()
add_library( ${library} ${_all} ${ARG_TYPE} ${lib_srcs})
add_library( ${library} ${_all} ${ARG_TYPE} ${lib_srcs})
if(ARG_TYPE STREQUAL SHARED)
if(ARG_TYPE STREQUAL SHARED)
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} )
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} )
endif()
endif()
if(explicitlink OR ROOT_explicitlink_FOUND)
if(explicitlink OR ROOT_explicitlink_FOUND)
target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES})
target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES})
else()
else()
target_link_libraries(${library} ${ARG_LIBRARIES})
target_link_libraries(${library} ${ARG_LIBRARIES})
endif()
endif()
endif()
endif()
if(TARGET G__${library})
if(TARGET G__${library})
add_dependencies(${library} G__${library})
add_dependencies(${library} G__${library})
endif()
endif()
if(TARGET move_headers)
add_dependencies(${library} move_headers)
add_dependencies(${library} move_headers)
endif()
set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name})
set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name})
set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_DEPENDENCIES}")
set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_DEPENDENCIES}")
# Do not add -Dname_EXPORTS to the command-line when building files in this
# target. Doing so is actively harmful for the modules build because it
# creates extra module variants, and not useful because we don't use these
# macros.
set_target_properties(${library} PROPERTIES DEFINE_SYMBOL "")
if(ARG_BUILTINS)
foreach(arg1 ${ARG_BUILTINS})
if(${arg1}_TARGET)
add_dependencies(${library} ${${arg1}_TARGET})
endif()
endforeach()
endif()

#----Installation details-------------------------------------------------------
#----Installation details-------------------------------------------------------
if(NOT ARG_TEST AND NOT ARG_NOINSTALL AND CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(NOT ARG_TEST AND NOT ARG_NOINSTALL AND CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(ARG_CMAKENOEXPORT)
if(ARG_CMAKENOEXPORT)
install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
else()
else()
install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports
install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
endif()
if(WIN32 AND ARG_TYPE STREQUAL SHARED)
if(WIN32 AND ARG_TYPE STREQUAL SHARED)
install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${library}.pdb
install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${library}.pdb
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT libraries)
endif()
endif()
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_OBJECT_LIBRARY( <name> source1 source2 ...)
#---------------------------------------------------------------------------------------------------
function(ROOT_OBJECT_LIBRARY library)
ROOT_GET_SOURCES(lib_srcs src ${ARGN})
include_directories(AFTER ${CMAKE_BINARY_DIR}/include)
add_library( ${library} OBJECT ${lib_srcs})
if(lib_srcs MATCHES "(^|/)(G__[^.]*)[.]cxx.*")
add_dependencies(${library} ${CMAKE_MATCH_2})
endif()
if(TARGET move_headers)
add_dependencies(${library} move_headers)
endif()

#--- Only for building shared libraries
set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE 1)

#--- Fill the property OBJECTS with all the object files
# This is needed becuase the generator expression $<TARGET_OBJECTS:target>
# does not get expanded when used in custom command dependencies
get_target_property(sources ${library} SOURCES)
foreach(s ${sources})
if(CMAKE_GENERATOR MATCHES Xcode)
get_filename_component(name ${s} NAME_WE)
set(obj ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.build/${CMAKE_CFG_INTDIR}/${library}.build/Objects-normal/x86_64/${name}${CMAKE_CXX_OUTPUT_EXTENSION})
else()
if(IS_ABSOLUTE ${s})
string(REGEX REPLACE "([][.?*+|()$^-])" "\\\\\\1" escaped_source_dir "${CMAKE_CURRENT_SOURCE_DIR}")
string(REGEX REPLACE "([][.?*+|()$^-])" "\\\\\\1" escaped_binary_dir "${CMAKE_CURRENT_BINARY_DIR}")
if(${s} MATCHES "^${escaped_source_dir}")
string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s})
elseif(${s} MATCHES "^${escaped_binary_dir}")
string(REPLACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s})
else()
#message(WARNING "Unknown location of source ${s} for object library ${library}")
endif()
else()
set(src ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${s})
endif()
set(obj ${src}${CMAKE_CXX_OUTPUT_EXTENSION})
endif()
set_property(TARGET ${library} APPEND PROPERTY OBJECTS ${obj})
endforeach()
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_MODULE_LIBRARY( <name> source1 source2 ... [DLLEXPORT] LIBRARIES library1 library2 ...)
#---------------------------------------------------------------------------------------------------
function(ROOT_MODULE_LIBRARY library)
CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES" ${ARGN})
ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS})
include_directories(${CMAKE_BINARY_DIR}/include)
add_library( ${library} SHARED ${lib_srcs})
if(TARGET move_headers)
add_dependencies(${library} move_headers)
endif()
set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
target_link_libraries(${library} ${ARG_LIBRARIES})
#----Installation details-------------------------------------------------------
install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_GENERATE_ROOTMAP( library LINKDEF linkdef LIBRRARY lib DEPENDENCIES lib1 lib2 )
#---------------------------------------------------------------------------------------------------
function(ROOT_GENERATE_ROOTMAP library)
return() #--- No needed anymore
CMAKE_PARSE_ARGUMENTS(ARG "" "LIBRARY" "LINKDEF;DEPENDENCIES" ${ARGN})
get_filename_component(libname ${library} NAME_WE)
get_filename_component(path ${library} PATH)

#---Set the library output directory-----------------------
if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else()
set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()

set(outfile ${library_output_dir}/${libprefix}${libname}.rootmap)
foreach( f ${ARG_LINKDEF})
if( IS_ABSOLUTE ${f})
set(_linkdef ${_linkdef} ${f})
else()
set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
endif()
endforeach()
foreach(d ${ARG_DEPENDENCIES})
get_filename_component(_ext ${d} EXT)
if(_ext)
set(_dependencies ${_dependencies} ${d})
else()
set(_dependencies ${_dependencies} ${libprefix}${d}${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
endforeach()
if(ARG_LIBRARY)
set(_library ${ARG_LIBRARY})
else()
set(_library ${libprefix}${library}${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
#---Build the rootmap file--------------------------------------
add_custom_command(OUTPUT ${outfile}
COMMAND ${rlibmap_cmd} -o ${outfile} -l ${_library} -d ${_dependencies} -c ${_linkdef}
DEPENDS ${_linkdef} ${rlibmap_cmd} )
add_custom_target( ${libprefix}${library}.rootmap ALL DEPENDS ${outfile})
set_target_properties(${libprefix}${library}.rootmap PROPERTIES FOLDER RootMaps )
#---Install the rootmap file------------------------------------
install(FILES ${outfile} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] OPTIONS [options])
#---------------------------------------------------------------------------------------------------
function(ROOT_INSTALL_HEADERS)
CMAKE_PARSE_ARGUMENTS(ARG "" "" "OPTIONS" ${ARGN})
if( ARG_UNPARSED_ARGUMENTS )
set(dirs ${ARG_UNPARSED_ARGUMENTS})
else()
set(dirs inc/)
if(root7)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc/)
set(dirs inc/ v7/inc/)
endif()
endif()
endif()
foreach(d ${dirs})
install(DIRECTORY ${d} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers
PATTERN ".svn" EXCLUDE
REGEX "LinkDef" EXCLUDE
${ARG_OPTIONS})
set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${d})
endforeach()
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_STANDARD_LIBRARY_PACKAGE(libname DEPENDENCIES lib1 lib2)
#---------------------------------------------------------------------------------------------------
function(ROOT_STANDARD_LIBRARY_PACKAGE libname)
CMAKE_PARSE_ARGUMENTS(ARG "" "" "DEPENDENCIES;DICTIONARY_OPTIONS" ${ARGN})
ROOT_GENERATE_DICTIONARY(G__${libname} *.