Update: removed request of 4 points in ITS (Renu)
[u/mrichter/AliRoot.git] / cmake / modules / WriteConfigFile.cmake
1 MACRO (WRITE_CONFIG_FILE filename)
2
3   IF(${filename} MATCHES "[.]csh")
4     SET(CSH_OUT TRUE)
5   ELSE(${filename} MATCHES "[.]csh")
6     SET(CSH_OUT FALSE)
7   ENDIF(${filename} MATCHES "[.]csh")
8
9   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
10     SET(LD_LIBRARY_PATH /usr/lib /usr/X11R6/lib ${CBMLIBDIR} ${LD_LIBRARY_PATH})
11   ELSE(CMAKE_SYSTEM_NAME MATCHES Linux)
12     IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
13       SET(LD_LIBRARY_PATH ${CBMLIBDIR} ${LD_LIBRARY_PATH})
14     ENDIF(CMAKE_SYSTEM_NAME MATCHES Darwin)
15   ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
16   
17   WRITE_TO_FILE(${filename} SIMPATH ${SIMPATH} "") 
18   WRITE_TO_FILE(${filename} ROOTSYS ${ROOTSYS} APPEND) 
19
20   IF (GEANT4_FOUND AND GEANT4VMC_FOUND AND CLHEP_FOUND)
21     CONVERT_LIST_TO_STRING(${GEANT4_LIBRARY_DIR})
22     WRITE_TO_FILE(${filename} GEANT4_LIBRARY_DIR ${output} APPEND)
23
24     CONVERT_LIST_TO_STRING(${GEANT4_INCLUDE_DIR})
25     WRITE_TO_FILE(${filename} GEANT4_INCLUDE_DIR ${output} APPEND)
26  
27     CONVERT_LIST_TO_STRING(${GEANT4VMC_INCLUDE_DIR})
28     WRITE_TO_FILE(${filename} GEANT4VMC_INCLUDE_DIR ${output} APPEND)
29  
30     CONVERT_LIST_TO_STRING(${GEANT4VMC_LIBRARY_DIR})
31     WRITE_TO_FILE(${filename} GEANT4VMC_LIBRARY_DIR ${output} APPEND)
32
33     CONVERT_LIST_TO_STRING(${CLHEP_INCLUDE_DIR})
34     WRITE_TO_FILE(${filename} CLHEP_INCLUDE_DIR ${output}  APPEND)
35
36     CONVERT_LIST_TO_STRING(${CLHEP_LIBRARY_DIR})
37     WRITE_TO_FILE(${filename} CLHEP_LIBRARY_DIR ${output} APPEND)
38   ENDIF (GEANT4_FOUND AND GEANT4VMC_FOUND AND CLHEP_FOUND) 
39   
40   CONVERT_LIST_TO_STRING(${PLUTO_LIBRARY_DIR})
41   WRITE_TO_FILE(${filename} PLUTO_LIBRARY_DIR ${output} APPEND)
42
43   CONVERT_LIST_TO_STRING(${PLUTO_INCLUDE_DIR})
44   WRITE_TO_FILE(${filename} PLUTO_INCLUDE_DIR ${output} APPEND)
45
46   CONVERT_LIST_TO_STRING(${PYTHIA6_LIBRARY_DIR})
47   WRITE_TO_FILE(${filename} PYTHIA6_LIBRARY_DIR ${output} APPEND)
48
49   CONVERT_LIST_TO_STRING(${GEANT3_SYSTEM_DIR})
50   WRITE_TO_FILE(${filename} G3SYS ${output} APPEND)
51
52   CONVERT_LIST_TO_STRING(${GEANT3_INCLUDE_DIR})
53   WRITE_TO_FILE(${filename} GEANT3_INCLUDE_DIR ${output} APPEND)
54
55   CONVERT_LIST_TO_STRING(${GEANT3_LIBRARY_DIR})
56   WRITE_TO_FILE(${filename} GEANT3_LIBRARY_DIR ${output} APPEND)
57
58   CONVERT_LIST_TO_STRING(${GEANT3_LIBRARIES})
59   WRITE_TO_FILE(${filename} GEANT3_LIBRARIES ${output} APPEND)
60
61   CONVERT_LIST_TO_STRING(${ROOT_LIBRARY_DIR})
62   WRITE_TO_FILE(${filename} ROOT_LIBRARY_DIR ${output} APPEND)
63
64   CONVERT_LIST_TO_STRING(${ROOT_LIBRARIES})
65   WRITE_TO_FILE(${filename} ROOT_LIBRARIES ${output} APPEND)
66
67   CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_DIR})
68   WRITE_TO_FILE(${filename} ROOT_INCLUDE_DIR ${output}  APPEND)
69
70   WRITE_TO_FILE(${filename} VMCWORKDIR ${CMAKE_SOURCE_DIR} APPEND)
71
72   WRITE_TO_FILE(${filename} CBMLIBDIR ${CBMLIBDIR} APPEND)
73
74   CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
75   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
76     WRITE_TO_FILE(${filename} LD_LIBRARY_PATH ${output} APPEND)
77   ELSE(CMAKE_SYSTEM_NAME MATCHES Linux)
78     IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
79       WRITE_TO_FILE(${filename} DYLD_LIBRARY_PATH ${output} APPEND)
80     ENDIF(CMAKE_SYSTEM_NAME MATCHES Darwin)
81   ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
82
83   WRITE_TO_FILE(${filename} USE_VGM 1 APPEND)
84
85 #  STRING(REGEX MATCHALL "[^:]+" PATH1 ${PATH})
86   SET (PATH ${ROOTSYS}/bin ${PATH})
87   UNIQUE(PATH "${PATH}")
88   CONVERT_LIST_TO_STRING(${PATH})
89   WRITE_TO_FILE(${filename} PATH ${output} APPEND)
90
91   IF (GEANT4_FOUND AND GEANT4VMC_FOUND AND CLHEP_FOUND)
92     WRITE_FILE(${filename} ". ${GEANT4_DIR}/env.sh" APPEND)
93   ENDIF (GEANT4_FOUND AND GEANT4VMC_FOUND AND CLHEP_FOUND)
94
95   IF(RULE_CHECKER_FOUND)
96     CONVERT_LIST_TO_STRING($ENV{NEW_CLASSPATH})
97     WRITE_TO_FILE(${filename} CLASSPATH ${output} APPEND)
98   ENDIF(RULE_CHECKER_FOUND)
99
100
101
102 ENDMACRO (WRITE_CONFIG_FILE)
103
104
105 MACRO (WRITE_MINIMAL_CONFIG_FILE filename)
106
107   IF(${filename} MATCHES "[.]csh")
108     SET(CSH_OUT TRUE)
109   ELSE(${filename} MATCHES "[.]csh")
110     SET(CSH_OUT FALSE)
111   ENDIF(${filename} MATCHES "[.]csh")
112
113   SET(CBMLIBDIR ${CMAKE_CURRENT_BINARY_DIR}/lib)
114   
115   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
116     SET(LD_LIBRARY_PATH /usr/lib /usr/X11R6/lib ${CBMLIBDIR} ${LD_LIBRARY_PATH})
117   ELSE(CMAKE_SYSTEM_NAME MATCHES Linux)
118     IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
119       SET(LD_LIBRARY_PATH ${CBMLIBDIR} ${LD_LIBRARY_PATH})
120     ENDIF(CMAKE_SYSTEM_NAME MATCHES Darwin)
121   ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
122   
123   WRITE_TO_FILE(${filename} ROOTSYS ${ROOTSYS} APPEND) 
124
125   CONVERT_LIST_TO_STRING(${ROOT_LIBRARY_DIR})
126   WRITE_TO_FILE(${filename} ROOT_LIBRARY_DIR ${output} APPEND)
127
128   CONVERT_LIST_TO_STRING(${ROOT_LIBRARIES})
129   WRITE_TO_FILE(${filename} ROOT_LIBRARIES ${output} APPEND)
130
131   CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_DIR})
132   WRITE_TO_FILE(${filename} ROOT_INCLUDE_DIR ${output}  APPEND)
133
134   WRITE_TO_FILE(${filename} VMCWORKDIR ${CMAKE_SOURCE_DIR} APPEND)
135
136   WRITE_TO_FILE(${filename} CBMLIBDIR ${CBMLIBDIR} APPEND)
137
138   CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
139   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
140     WRITE_TO_FILE(${filename} LD_LIBRARY_PATH ${output} APPEND)
141   ELSE(CMAKE_SYSTEM_NAME MATCHES Linux)
142     IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
143       WRITE_TO_FILE(${filename} DYLD_LIBRARY_PATH ${output} APPEND)
144     ENDIF(CMAKE_SYSTEM_NAME MATCHES Darwin)
145   ENDIF(CMAKE_SYSTEM_NAME MATCHES Linux)
146
147 #  STRING(REGEX MATCHALL "[^:]+" PATH1 ${PATH})
148   SET (PATH ${ROOTSYS}/bin $ENV{PATH})
149   UNIQUE(PATH "${PATH}")
150   CONVERT_LIST_TO_STRING(${PATH})
151   WRITE_TO_FILE(${filename} PATH ${output} APPEND)
152
153
154 ENDMACRO (WRITE_MINIMAL_CONFIG_FILE)
155
156
157 MACRO (CONVERT_LIST_TO_STRING)
158
159   set (tmp "")
160   foreach (_current ${ARGN})
161
162     set(tmp1 ${tmp})
163     set(tmp "")
164     set(tmp ${tmp1}:${_current})
165
166   endforeach (_current ${ARGN})
167   STRING(REGEX REPLACE "^:(.*)" "\\1" output ${tmp}) 
168
169 ENDMACRO (CONVERT_LIST_TO_STRING LIST)
170
171 MACRO (WRITE_TO_FILE FILENAME ENVVARIABLE VALUE OPTION)
172
173   IF(CSH_OUT)
174     WRITE_FILE(${FILENAME} "setenv ${ENVVARIABLE} \"${VALUE}\"" ${OPTION})
175   ELSE(CSH_OUT)
176     WRITE_FILE(${FILENAME} "export ${ENVVARIABLE}=\"${VALUE}\"" ${OPTION})
177   ENDIF(CSH_OUT)
178
179 ENDMACRO (WRITE_TO_FILE)
180
181
182
183
184
185
186
187