Additional libraries to link hltdimserver
[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
ca331a9c 29# - DATE_LIBS - DATE libs to be linked against to
56966a5e 30# - DATE_MONLIBS - monitorlibs reported by date-config
6db31708 31
32find_program(DATE_CONFIG date-config)
56966a5e 33
6db31708 34if(DATE_CONFIG)
56966a5e 35 # Checking DATE version
36 execute_process(COMMAND ${DATE_CONFIG} --version OUTPUT_VARIABLE DATE_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
37 if(error)
38 message(FATAL_ERROR "Error retrieving DATE version : ${error}")
39 endif(error)
40 string(STRIP ${DATE_VERSION} DATE_VERSION)
41
42 # Extract major, minor, and patch versions from
43 string(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" DATE_VERSION_MAJOR "${DATE_VERSION}")
44 string(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" DATE_VERSION_MINOR "${DATE_VERSION}")
45 message(STATUS "DATE version ${DATE_VERSION_MAJOR}.${DATE_VERSION_MINOR} found.")
46
47 # Checking if the environment is properly set
ca331a9c 48# if(NOT DEFINED ENV{DATE_ROOT})
49# message(FATAL_ERROR "date-config found. Please set DATE_ROOT environment variable")
50# else()
51# set(DATE_ROOT ENV{DATE_ROOT})
52# message(STATUS "DATE_ROOT found ${DATE_ROOT}")
53# endif()
56966a5e 54
ca331a9c 55# if(NOT DEFINED ENV{DATE_COMMON_DEFS})
56# message(FATAL_ERROR "date-config found. Please set DATE_COMMON_DEFS environment variable")
57# else()
58# set(DATE_COMMON_DEFS ENV{DATE_COMMON_DEFS})
59# message(STATUS "DATE_COMMON_DEFS found ${DATE_COMMON_DEFS}")
60# endif()
56966a5e 61
ca331a9c 62# if(NOT DEFINED ENV{DATE_MONITOR_DIR})
63# message(FATAL_ERROR "date-config found. Please set DATE_MONITOR_DIR environment variable")
64# else()
65# set(DATE_MONITOR_DIR ENV{DATE_MONITOR_DIR})
66# message(STATUS "DATE_MONITOR_DIR found ${DATE_MONITOR_DIR}")
67# endif()
56966a5e 68
69 # setting the cflags
70 execute_process(COMMAND ${DATE_CONFIG} --cflags OUTPUT_VARIABLE DATE_CFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
71 if(error)
72 message(FATAL_ERROR "Error retrieving DATE cflags : ${error}")
73 endif(error)
ca331a9c 74
75 # If flags not empty we strip them
76 if(DATE_CFLAGS)
77 string(STRIP ${DATE_CFLAGS} DATE_CFLAGS)
78 endif()
56966a5e 79
80 set(DATE_CFLAGS "-DALI_DATE ${DATE_CFLAGS}")
81
82 # setting the ldflags
83 execute_process(COMMAND ${DATE_CONFIG} --ldflags OUTPUT_VARIABLE DATE_LDFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
84 if(error)
85 message(FATAL_ERROR "Error retrieving DATE ldflags : ${error}")
86 endif(error)
ca331a9c 87
88 # If the flags are not empty we strip them
89 if(DATE_LDFLAGS)
90 string(STRIP ${DATE_LDFLAGS} DATE_LDFLAGS)
91 endif()
92
93 # setting the libs
94 execute_process(COMMAND ${DATE_CONFIG} --libs OUTPUT_VARIABLE DATE_LIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
95 if(error)
96 message(FATAL_ERROR "Error retrieving DATE libs : ${error}")
97 endif(error)
98
99 # If the flags are not empty we strip them
100 if(DATE_LIBS)
101 string(STRIP ${DATE_LIBS} DATE_LIBS)
102 endif()
56966a5e 103
104 # setting the monlibs
105 execute_process(COMMAND ${DATE_CONFIG} --monitorlibs OUTPUT_VARIABLE DATE_MONLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
106 if(error)
107 message(FATAL_ERROR "Error retrieving DATE monitorlibs : ${error}")
108 endif(error)
56966a5e 109
ca331a9c 110 # If the flags are not empty we strip them
111 if(DATE_MONLIBS)
112 string(STRIP ${DATE_MONLIBS} DATE_MONLIBS)
113 endif()
114
56966a5e 115 set(DATE_FOUND TRUE)
6db31708 116else()
56966a5e 117 message(STATUS "DATE not found")
118
119# set(DATEFLAGS "-D${CMAKE_SYSTEM_NAME} -DDATE_SYS=${CMAKE_SYSTEM_NAME} -Dlong32='int' -Dlong64='long long' -DdatePointer='long'")
6db31708 120endif(DATE_CONFIG)
575bfc03 121