Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
IF(APPLE)
SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH )
ELSE()
SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH )
ENDIF()
SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} )
#MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" )
#MESSAGE( STATUS "ROOT_CINT_EXECUTABLE: ${ROOT_CINT_EXECUTABLE}" )
SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOT_CINT_EXECUTABLE} )
IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR )
SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" )
ENDIF()
# clean generated header files with 'make clean'
SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" )
IF( NOT ROOT_FIND_QUIETLY )
MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" )
MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" )
ENDIF()
# ============================================================================
# helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES
# sorts LinkDef.h to be the last header (required by rootcint)
#
# arguments:
# input_dir - directory to search for headers matching *.h
#
# returns:
# ROOT_DICT_INPUT_HEADERS - all header files found in input_dir with
# LinkDef.h as the last header (if found)
#
# ----------------------------------------------------------------------------
MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir )
FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" )
FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" )
#LIST( FIND ROOT_DICT_INPUT_HEADERS ${_linkdef_hdr} _aux )
#IF( ${_aux} EQUAL 0 OR ${_aux} GREATER 0 )
# LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
# LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
#ENDIF()
IF( _linkdef_hdr )
LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" )
LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}")
ENDIF()
#MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" )
ENDMACRO( PREPARE_ROOT_DICT_HEADERS )
# ============================================================================
# helper macro to generate Linkdef.h files for rootcint
#
# arguments:
# namespace - prefix used for creating header <namespace>_Linkdef.h
# ARGN - list of sources to be used for generating Linkdef.h
#
# returns:
# ROOT_DICT_INPUT_HEADERS - all header files + <namespace>_LinkDef.h in the
# correct order to be used by macro GEN_ROOT_DICT_SOURCES
#
# ----------------------------------------------------------------------------
MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace )
SET( _input_headers ${ARGN} )
SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" )
FOREACH( _header ${_input_headers} )
SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link C++ defined_in \\\"${_header}\\\"\\;\\\\n" )
ENDFOREACH()
ADD_CUSTOM_COMMAND(
OUTPUT ${_linkdef_header}
COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR}
COMMAND printf "${${_namespace}_file_contents}" > ${_linkdef_header}
DEPENDS ${_input_headers}
COMMENT "generating: ${_linkdef_header}"
)
SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} )
ENDMACRO()
# ============================================================================
# macro for generating root dict sources with rootcint
#
# arguments:
# dict_src_filename - filename of the dictionary source (to be generated)
#
# requires following variables:
# ROOT_DICT_INPUT_HEADERS - list of headers needed to generate dict source
# * if LinkDef.h is in the list it must be at the end !!
# ROOT_DICT_INCLUDE_DIRS - list of include dirs to pass to rootcint -I..
# ROOT_DICT_CINT_DEFINITIONS - extra definitions to pass to rootcint
# ROOT_DICT_OUTPUT_DIR - where dictionary source should be generated
#
# returns:
# ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other
# previously generated sources
# ----------------------------------------------------------------------------
MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename )
# TODO check for ROOT_CINT_EXECUTABLE
# need to prefix all include dirs with -I
set( _dict_includes )
FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} )
SET( _dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion
#SET( _dict_includes ${_dict_includes} -I${_inc} )
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}" )
#message("${ROOT_DICT_INPUT_HEADERS}")
ADD_CUSTOM_COMMAND(
OUTPUT ${_dict_src_file} ${_dict_hdr_file}
COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR}
COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" -c ${ROOT_DICT_CINT_DEFINITIONS} ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${ROOT_DICT_INPUT_HEADERS}
COMMENT "generating: ${_dict_src_file} ${_dict_hdr_file}"
)
LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} )
ENDMACRO()
# for backwards compatibility
MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename )
#MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." )
SET( ROOT_DICT_OUTPUT_SOURCES )
GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} )
ENDMACRO()
# ============================================================================