]> git.uio.no Git - u/mrichter/AliRoot.git/blame - cmake/FindDATE.cmake
No need for extension in the rootmap file
[u/mrichter/AliRoot.git] / cmake / FindDATE.cmake
CommitLineData
56966a5e 1# **************************************************************************
2# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3# * *
4# * Author: The ALICE Off-line Project. *
5# * Contributors are mentioned in the code where appropriate. *
6# * *
7# * Permission to use, copy, modify and distribute this software and its *
8# * documentation strictly for non-commercial purposes is hereby granted *
9# * without fee, provided that the above copyright notice appears in all *
10# * copies and that both the copyright notice and this permission notice *
11# * appear in the supporting documentation. The authors make no claims *
12# * about the suitability of this software for any purpose. It is *
13# * provided "as is" without express or implied warranty. *
14# **************************************************************************
6db31708 15
56966a5e 16# Find DATE DAQ installation using date-config
17# Requires:
18# - date-config has to be found in the PATH
19# - Environment variables
ca331a9c 20# - DATE_ROOT // try to not use
21# - DATE_COMMON_DEFS // try to not use
22# - DATE_MONITOR_DIR //try not to use
56966a5e 23# - DATE_VERSION - DATE version as reported by date-config
24# - DATE_VERSION_MAJOR
25# - DATE_VERSIOM_MINOR
26# - DATE_CONFIG - path to date-config script
27# - DATE_CFLAGS - cflags reported by date-config
28# - DATE_LDFLAGS - ldflags reported by date-config
f82bfa66 29# - DATE_LIBS - DATE libs to be linked against to reported by date-config --libs
30# - DATE_LIBRARIES - DATE libs as as list as extracted from date-config --libs
4d31eb1c 31# - DATE_MONLIBS - static monitorlibs reported by date-config --monitorlibs without shift
32# - DATE_DYNMONLIBS - dynamic monitorlibs reported by date-config --monitorlibs without shift
f82bfa66 33# - DATE_MONLIBRARIES - DATE monitor libs as a list extracted from the date-config --monitorlibs
34# - DATE_STATICMON - DATE static monitor libs needed by the DA
35# - DATE_RCPROXYLIBS - rcproxylibs reported by date-config --rcproxylibs
36# - DATE_RCPROXYLIBRARIES - rcproxylibs as a list as extracted from date-config --rcproxylibs
6db31708 37
f82bfa66 38#########################
39# Functions definitions
40#########################
56966a5e 41
f82bfa66 42# A function to find all the libraries listed in library_list. The list contains the short
43# names of libraries (ie. Db instead of libDb.so).
44# Libraries are search in library_paths.
45# It returns the list of libraries, with full path and full name.
46# Author: Barthelemy Von Haller
47function(find_date_libraries _output library_list library_paths)
48 FOREACH (LIB ${library_list})
49 # Find first static, this is used by the DA
50 find_library(DATE_LIBRARY_${LIB} NAMES "lib${LIB}.a" PATHS ${library_paths})
51
52 if(NOT DATE_LIBRARY_${LIB})
53 find_library(DATE_LIBRARY_${LIB} NAMES ${LIB} PATHS ${library_paths})
54 endif()
55
56 mark_as_advanced(DATE_LIBRARY_${LIB})
57 set(_output_tmp ${_output_tmp} ${DATE_LIBRARY_${LIB}})
58 ENDFOREACH (LIB ${library_list})
59
60 set(${_output} ${_output_tmp} PARENT_SCOPE)
61endfunction(find_date_libraries _output library_list library_paths)
62
63# DATE_CONFIG set from the configuration
6db31708 64if(DATE_CONFIG)
ec8c8ea6 65 # Setting DIMDIR, ODIR and ROOTSYS in the environment, they are needed by date-config
66 set(ENV{DIMDIR} ${DIMDIR})
67 set(ENV{ODIR} ${ODIR})
68 set(ENV{ROOTSYS} ${ROOTSYS})
69
56966a5e 70 # Checking DATE version
71 execute_process(COMMAND ${DATE_CONFIG} --version OUTPUT_VARIABLE DATE_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
72 if(error)
73 message(FATAL_ERROR "Error retrieving DATE version : ${error}")
74 endif(error)
75 string(STRIP ${DATE_VERSION} DATE_VERSION)
76
77 # Extract major, minor, and patch versions from
78 string(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" DATE_VERSION_MAJOR "${DATE_VERSION}")
79 string(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" DATE_VERSION_MINOR "${DATE_VERSION}")
80 message(STATUS "DATE version ${DATE_VERSION_MAJOR}.${DATE_VERSION_MINOR} found.")
81
56966a5e 82 # setting the cflags
83 execute_process(COMMAND ${DATE_CONFIG} --cflags OUTPUT_VARIABLE DATE_CFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
84 if(error)
85 message(FATAL_ERROR "Error retrieving DATE cflags : ${error}")
86 endif(error)
ca331a9c 87
88 # If flags not empty we strip them
89 if(DATE_CFLAGS)
90 string(STRIP ${DATE_CFLAGS} DATE_CFLAGS)
91 endif()
56966a5e 92
93 set(DATE_CFLAGS "-DALI_DATE ${DATE_CFLAGS}")
94
95 # setting the ldflags
96 execute_process(COMMAND ${DATE_CONFIG} --ldflags OUTPUT_VARIABLE DATE_LDFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
97 if(error)
98 message(FATAL_ERROR "Error retrieving DATE ldflags : ${error}")
99 endif(error)
ca331a9c 100
101 # If the flags are not empty we strip them
102 if(DATE_LDFLAGS)
103 string(STRIP ${DATE_LDFLAGS} DATE_LDFLAGS)
104 endif()
105
106 # setting the libs
107 execute_process(COMMAND ${DATE_CONFIG} --libs OUTPUT_VARIABLE DATE_LIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
108 if(error)
109 message(FATAL_ERROR "Error retrieving DATE libs : ${error}")
110 endif(error)
111
112 # If the flags are not empty we strip them
113 if(DATE_LIBS)
114 string(STRIP ${DATE_LIBS} DATE_LIBS)
115 endif()
56966a5e 116
f82bfa66 117 # DATE_LIBRARIES
118 # Extracting the list of dynamic and static libraries from the --libs
119 # The list is needed during the generation of the DAs
120 # using a find_library in order to get the full path and not need to use -L during linking of the DAs
121 string(REGEX MATCHALL "[-]l[^- ]+" DATE_LIBRARIES_TMP ${DATE_LIBS})
122 string(REGEX REPLACE "[-]l" ";" DATE_LIBRARIES_TMP ${DATE_LIBRARIES_TMP})
123 # Get the list of search path using -Lyyy -> yyy
124 string(REGEX MATCHALL "[-]L[^- ]+" DATE_LIBRARIES_PATH_TMP ${DATE_LIBS})
125 string(REGEX REPLACE "[-]L" ";" DATE_LIBRARIES_PATH_TMP ${DATE_LIBRARIES_PATH_TMP})
126 find_date_libraries(DATE_LIBRARIES "${DATE_LIBRARIES_TMP}" "${DATE_LIBRARIES_PATH_TMP}")
f82bfa66 127
128 # Fix for mysql bug https://bugs.launchpad.net/percona-server/+bug/1287374
129 set(DATE_LIBS "${DATE_LIBS} -L/usr/lib64/mysql/")
130
56966a5e 131 # setting the monlibs
f82bfa66 132 execute_process(COMMAND ${DATE_CONFIG} --monitorlibs=noshift OUTPUT_VARIABLE DATE_MONLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
56966a5e 133 if(error)
134 message(FATAL_ERROR "Error retrieving DATE monitorlibs : ${error}")
135 endif(error)
56966a5e 136
ca331a9c 137 # If the flags are not empty we strip them
138 if(DATE_MONLIBS)
139 string(STRIP ${DATE_MONLIBS} DATE_MONLIBS)
140 endif()
141
f82bfa66 142 # DATE_MONLIBRARIES
143 # Extracting the list of dynamic and static libraries from the --libs
144 # The list is needed during the generation of the DAs
145 # Removing everything that starts with - to leave all the static libraries
146 # Replacing space with ; to create a list that will be sent to the linked
147 string(REGEX REPLACE "-[^ \r\n\t].+( |$)?" "" DATE_STATICMON ${DATE_MONLIBS})
148 if(DATE_STATICMON)
149 string(REPLACE " " ";" DATE_STATICMON ${DATE_STATICMON})
150 endif(DATE_STATICMON)
151
152 # Extracting all the shared libraries
153 # using a find_library in order to get the full path and not need to use -L during linking of the DAs
154 string(REGEX MATCHALL "[-]l[^- ]+" DATE_MONLIBRARIES_TMP ${DATE_MONLIBS})
155 string(REGEX REPLACE "[-]l" ";" DATE_MONLIBRARIES_TMP ${DATE_MONLIBRARIES_TMP})
156 # Get the list of search path using -Lyyy -> yyy
157 string(REGEX MATCHALL "[-]L[^- ]+" DATE_MONLIBRARIES_PATH_TMP ${DATE_MONLIBS})
158 string(REGEX REPLACE "[-]L" ";" DATE_MONLIBRARIES_PATH_TMP ${DATE_MONLIBRARIES_PATH_TMP})
159 find_date_libraries(DATE_MONLIBRARIES "${DATE_MONLIBRARIES_TMP}" "${DATE_MONLIBRARIES_PATH_TMP}")
160 set(DATE_MONLIBRARIES ${DATE_STATICMON} ${DATE_MONLIBRARIES})
f82bfa66 161
162 # Fix for mysql bug https://bugs.launchpad.net/percona-server/+bug/1287374
163 set(DATE_MONLIBS "${DATE_MONLIBS} -L/usr/lib64/mysql/")
164
4d31eb1c 165 # setting the rclibs
f82bfa66 166 execute_process(COMMAND ${DATE_CONFIG} --rcproxylibs OUTPUT_VARIABLE DATE_RCPROXYLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
167 if(error)
168 message(FATAL_ERROR "Error retrieving DATE rcproxylibs")
169 endif(error)
170
171 # If the flags are not empty we strip them
172 if(DATE_RCPROXYLIBS)
173 string(STRIP ${DATE_RCPROXYLIBS} DATE_RCPROXYLIBS)
174 endif()
175
176 # DATE_LIBRARIES
177 # Extracting the list of dynamic and static libraries from the --libs
178 # The list is needed during the generation of the DAs
179 string(REGEX MATCHALL "[-]l[^- ]+" DATE_RCPROXYLIBRARIES_TMP ${DATE_RCPROXYLIBS})
180 string(REGEX REPLACE "[-]l" ";" DATE_RCPROXYLIBRARIES_TMP ${DATE_RCPROXYLIBRARIES_TMP})
181 # Get the list of search path using -Lyyy -> yyy
182 string(REGEX MATCHALL "[-]L[^- ]+" DATE_RCPROXYLIBRARIES_PATH_TMP ${DATE_RCPROXYLIBS})
183 string(REGEX REPLACE "[-]L" ";" DATE_RCPROXYLIBRARIES_PATH_TMP ${DATE_RCPROXYLIBRARIES_PATH_TMP})
184 find_date_libraries(DATE_RCPROXYLIBRARIES "${DATE_RCPROXYLIBRARIES_TMP}" "${DATE_RCPROXYLIBRARIES_PATH_TMP}")
f82bfa66 185
4d31eb1c 186 # setting the monlibs
187 execute_process(COMMAND ${DATE_CONFIG} --monitorlibs=dyn OUTPUT_VARIABLE DATE_DYNMONLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
188 if(error)
189 message(FATAL_ERROR "Error retrieving DATE monitorlibs : ${error}")
190 endif(error)
191
192 # If the flags are not empty we strip them
193 if(DATE_DYNMONLIBS)
194 string(STRIP ${DATE_DYNMONLIBS} DATE_DYNMONLIBS)
195 endif()
196
ec8c8ea6 197 # unsetting all environment variables
198 unset(ENV{DIMDIR})
199 unset(ENV{ODIR})
200 unset(ENV{ROOTSYS})
201
56966a5e 202 set(DATE_FOUND TRUE)
6db31708 203else()
56966a5e 204 message(STATUS "DATE not found")
6db31708 205endif(DATE_CONFIG)
575bfc03 206