]> git.uio.no Git - u/mrichter/AliRoot.git/blob - cmake/FindDATE.cmake
Fix for ROOT include paths
[u/mrichter/AliRoot.git] / cmake / FindDATE.cmake
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 # **************************************************************************
15
16 # Find DATE DAQ installation using date-config
17 # Requires: 
18 #       - date-config has to be found in the PATH
19 #       - Environment variables
20 #               - DATE_ROOT
21 #               - DATE_COMMON_DEFS
22 #               - DATE_MONITOR_DIR
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_MONLIBS - monitorlibs reported by date-config
30
31 find_program(DATE_CONFIG date-config)
32
33 if(DATE_CONFIG)
34     # Checking DATE version
35     execute_process(COMMAND ${DATE_CONFIG} --version OUTPUT_VARIABLE DATE_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
36     if(error)
37         message(FATAL_ERROR "Error retrieving DATE version : ${error}")
38     endif(error)
39     string(STRIP ${DATE_VERSION} DATE_VERSION)
40
41     # Extract major, minor, and patch versions from
42     string(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" DATE_VERSION_MAJOR "${DATE_VERSION}")
43     string(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" DATE_VERSION_MINOR "${DATE_VERSION}")
44     message(STATUS "DATE version ${DATE_VERSION_MAJOR}.${DATE_VERSION_MINOR} found.")
45     
46     # Checking if the environment is properly set
47     if(NOT DEFINED ENV{DATE_ROOT})
48         message(FATAL_ERROR "date-config found. Please set DATE_ROOT environment variable")
49     else()
50         set(DATE_ROOT ENV{DATE_ROOT})
51         message(STATUS "DATE_ROOT found ${DATE_ROOT}")
52     endif()
53
54     if(NOT DEFINED ENV{DATE_COMMON_DEFS})
55         message(FATAL_ERROR "date-config found. Please set DATE_COMMON_DEFS environment variable")
56     else()
57         set(DATE_COMMON_DEFS ENV{DATE_COMMON_DEFS})
58         message(STATUS "DATE_COMMON_DEFS found ${DATE_COMMON_DEFS}")
59     endif()
60
61     if(NOT DEFINED ENV{DATE_MONITOR_DIR})
62         message(FATAL_ERROR "date-config found. Please set DATE_MONITOR_DIR environment variable")
63     else()
64         set(DATE_MONITOR_DIR ENV{DATE_MONITOR_DIR})
65         message(STATUS "DATE_MONITOR_DIR found ${DATE_MONITOR_DIR}")
66     endif()
67
68     # setting the cflags
69     execute_process(COMMAND ${DATE_CONFIG} --cflags OUTPUT_VARIABLE DATE_CFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
70     if(error)
71         message(FATAL_ERROR "Error retrieving DATE cflags : ${error}")
72     endif(error)
73     string(STRIP ${DATE_CFLAGS} DATE_CFLAGS)
74     
75     set(DATE_CFLAGS "-DALI_DATE ${DATE_CFLAGS}")
76
77     # setting the ldflags
78     execute_process(COMMAND ${DATE_CONFIG} --ldflags OUTPUT_VARIABLE DATE_LDFLAGS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
79     if(error)
80         message(FATAL_ERROR "Error retrieving DATE ldflags : ${error}")
81     endif(error)
82     string(STRIP ${DATE_LDFLAGS} DATE_LDFLAGS)
83     
84     # setting the monlibs
85     execute_process(COMMAND ${DATE_CONFIG} --monitorlibs OUTPUT_VARIABLE DATE_MONLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
86     if(error)
87         message(FATAL_ERROR "Error retrieving DATE monitorlibs : ${error}")
88     endif(error)
89     string(STRIP ${DATE_MONLIBS} DATE_MONLIBS)
90
91     # Set the proper compilation flags
92     set(CMAKE_C_FLAGS ${DATE_CFLAGS} ${CMAKE_C_FLAGS})
93     set(CMAKE_CXX_FLAGS ${DATE_CFLAGS} ${CMAKE_CXX_FLAGS})
94     set(CMAKE_SHARED_LINKER_FLAGS ${DATE_LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS})
95     
96     set(DATE_FOUND TRUE)
97 else()
98     message(STATUS "DATE not found")
99     
100 #    set(DATEFLAGS "-D${CMAKE_SYSTEM_NAME} -DDATE_SYS=${CMAKE_SYSTEM_NAME} -Dlong32='int' -Dlong64='long long' -DdatePointer='long'")
101 endif(DATE_CONFIG)
102