1 # **************************************************************************
2 # * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
4 # * Author: The ALICE Off-line Project. *
5 # * Contributors are mentioned in the code where appropriate. *
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 # **************************************************************************
16 # Find DATE DAQ installation using date-config
18 # - date-config has to be found in the PATH
19 # - Environment variables
20 # - DATE_ROOT // try to not use
21 # - DATE_COMMON_DEFS // try to not use
22 # - DATE_MONITOR_DIR //try not to use
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
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
31 # - DATE_MONLIBS - monitorlibs reported by date-config --monitorlibs
32 # - DATE_MONLIBRARIES - DATE monitor libs as a list extracted from the date-config --monitorlibs
33 # - DATE_STATICMON - DATE static monitor libs needed by the DA
34 # - DATE_RCPROXYLIBS - rcproxylibs reported by date-config --rcproxylibs
35 # - DATE_RCPROXYLIBRARIES - rcproxylibs as a list as extracted from date-config --rcproxylibs
37 #########################
38 # Functions definitions
39 #########################
41 # A function to find all the libraries listed in library_list. The list contains the short
42 # names of libraries (ie. Db instead of libDb.so).
43 # Libraries are search in library_paths.
44 # It returns the list of libraries, with full path and full name.
45 # Author: Barthelemy Von Haller
46 function(find_date_libraries _output library_list library_paths)
47 FOREACH (LIB ${library_list})
48 # Find first static, this is used by the DA
49 find_library(DATE_LIBRARY_${LIB} NAMES "lib${LIB}.a" PATHS ${library_paths})
51 if(NOT DATE_LIBRARY_${LIB})
52 find_library(DATE_LIBRARY_${LIB} NAMES ${LIB} PATHS ${library_paths})
55 mark_as_advanced(DATE_LIBRARY_${LIB})
56 set(_output_tmp ${_output_tmp} ${DATE_LIBRARY_${LIB}})
57 ENDFOREACH (LIB ${library_list})
59 set(${_output} ${_output_tmp} PARENT_SCOPE)
60 endfunction(find_date_libraries _output library_list library_paths)
62 # DATE_CONFIG set from the configuration
64 # Checking DATE version
65 execute_process(COMMAND ${DATE_CONFIG} --version OUTPUT_VARIABLE DATE_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
67 message(FATAL_ERROR "Error retrieving DATE version : ${error}")
69 string(STRIP ${DATE_VERSION} DATE_VERSION)
71 # Extract major, minor, and patch versions from
72 string(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" DATE_VERSION_MAJOR "${DATE_VERSION}")
73 string(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" DATE_VERSION_MINOR "${DATE_VERSION}")
74 message(STATUS "DATE version ${DATE_VERSION_MAJOR}.${DATE_VERSION_MINOR} found.")
77 execute_process(COMMAND ${DATE_CONFIG} --cflags OUTPUT_VARIABLE DATE_CFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
79 message(FATAL_ERROR "Error retrieving DATE cflags : ${error}")
82 # If flags not empty we strip them
84 string(STRIP ${DATE_CFLAGS} DATE_CFLAGS)
87 set(DATE_CFLAGS "-DALI_DATE ${DATE_CFLAGS}")
90 execute_process(COMMAND ${DATE_CONFIG} --ldflags OUTPUT_VARIABLE DATE_LDFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
92 message(FATAL_ERROR "Error retrieving DATE ldflags : ${error}")
95 # If the flags are not empty we strip them
97 string(STRIP ${DATE_LDFLAGS} DATE_LDFLAGS)
101 execute_process(COMMAND ${DATE_CONFIG} --libs OUTPUT_VARIABLE DATE_LIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
103 message(FATAL_ERROR "Error retrieving DATE libs : ${error}")
106 # If the flags are not empty we strip them
108 string(STRIP ${DATE_LIBS} DATE_LIBS)
112 # Extracting the list of dynamic and static libraries from the --libs
113 # The list is needed during the generation of the DAs
114 # using a find_library in order to get the full path and not need to use -L during linking of the DAs
115 string(REGEX MATCHALL "[-]l[^- ]+" DATE_LIBRARIES_TMP ${DATE_LIBS})
116 string(REGEX REPLACE "[-]l" ";" DATE_LIBRARIES_TMP ${DATE_LIBRARIES_TMP})
117 # Get the list of search path using -Lyyy -> yyy
118 string(REGEX MATCHALL "[-]L[^- ]+" DATE_LIBRARIES_PATH_TMP ${DATE_LIBS})
119 string(REGEX REPLACE "[-]L" ";" DATE_LIBRARIES_PATH_TMP ${DATE_LIBRARIES_PATH_TMP})
120 find_date_libraries(DATE_LIBRARIES "${DATE_LIBRARIES_TMP}" "${DATE_LIBRARIES_PATH_TMP}")
121 message(STATUS "DATE LIBs ${DATE_LIBRARIES}")
123 # Fix for mysql bug https://bugs.launchpad.net/percona-server/+bug/1287374
124 set(DATE_LIBS "${DATE_LIBS} -L/usr/lib64/mysql/")
126 # setting the monlibs
127 execute_process(COMMAND ${DATE_CONFIG} --monitorlibs=noshift OUTPUT_VARIABLE DATE_MONLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
129 message(FATAL_ERROR "Error retrieving DATE monitorlibs : ${error}")
132 # If the flags are not empty we strip them
134 string(STRIP ${DATE_MONLIBS} DATE_MONLIBS)
138 # Extracting the list of dynamic and static libraries from the --libs
139 # The list is needed during the generation of the DAs
140 # Removing everything that starts with - to leave all the static libraries
141 # Replacing space with ; to create a list that will be sent to the linked
142 string(REGEX REPLACE "-[^ \r\n\t].+( |$)?" "" DATE_STATICMON ${DATE_MONLIBS})
144 string(REPLACE " " ";" DATE_STATICMON ${DATE_STATICMON})
145 endif(DATE_STATICMON)
147 # Extracting all the shared libraries
148 # using a find_library in order to get the full path and not need to use -L during linking of the DAs
149 string(REGEX MATCHALL "[-]l[^- ]+" DATE_MONLIBRARIES_TMP ${DATE_MONLIBS})
150 string(REGEX REPLACE "[-]l" ";" DATE_MONLIBRARIES_TMP ${DATE_MONLIBRARIES_TMP})
151 # Get the list of search path using -Lyyy -> yyy
152 string(REGEX MATCHALL "[-]L[^- ]+" DATE_MONLIBRARIES_PATH_TMP ${DATE_MONLIBS})
153 string(REGEX REPLACE "[-]L" ";" DATE_MONLIBRARIES_PATH_TMP ${DATE_MONLIBRARIES_PATH_TMP})
154 find_date_libraries(DATE_MONLIBRARIES "${DATE_MONLIBRARIES_TMP}" "${DATE_MONLIBRARIES_PATH_TMP}")
155 set(DATE_MONLIBRARIES ${DATE_STATICMON} ${DATE_MONLIBRARIES})
156 message(STATUS "MONSTATIC ${DATE_STATICMON}")
158 # Fix for mysql bug https://bugs.launchpad.net/percona-server/+bug/1287374
159 set(DATE_MONLIBS "${DATE_MONLIBS} -L/usr/lib64/mysql/")
161 # setting the monlibs
162 execute_process(COMMAND ${DATE_CONFIG} --rcproxylibs OUTPUT_VARIABLE DATE_RCPROXYLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
164 message(FATAL_ERROR "Error retrieving DATE rcproxylibs")
167 # If the flags are not empty we strip them
169 string(STRIP ${DATE_RCPROXYLIBS} DATE_RCPROXYLIBS)
173 # Extracting the list of dynamic and static libraries from the --libs
174 # The list is needed during the generation of the DAs
175 string(REGEX MATCHALL "[-]l[^- ]+" DATE_RCPROXYLIBRARIES_TMP ${DATE_RCPROXYLIBS})
176 string(REGEX REPLACE "[-]l" ";" DATE_RCPROXYLIBRARIES_TMP ${DATE_RCPROXYLIBRARIES_TMP})
177 # Get the list of search path using -Lyyy -> yyy
178 string(REGEX MATCHALL "[-]L[^- ]+" DATE_RCPROXYLIBRARIES_PATH_TMP ${DATE_RCPROXYLIBS})
179 string(REGEX REPLACE "[-]L" ";" DATE_RCPROXYLIBRARIES_PATH_TMP ${DATE_RCPROXYLIBRARIES_PATH_TMP})
180 find_date_libraries(DATE_RCPROXYLIBRARIES "${DATE_RCPROXYLIBRARIES_TMP}" "${DATE_RCPROXYLIBRARIES_PATH_TMP}")
181 message(STATUS "DATE RCLIBs ${DATE_RCPROXYLIBRARIES}")
185 message(STATUS "DATE not found")