Requested CMake version >= 2.8.4
[u/mrichter/AliRoot.git] / cmake / CMakelinuxx8664gcc.cmake
1 # -*- mode: cmake -*-
2
3 #--------------------------------------------------------------------------------#
4 # Linuxx8664gcc CMake System configuration file for the AliRoot Build System     #
5 #                                                                                # 
6 # Author: Johny Jose (johny.jose@cern.ch)                                        #
7 #                                                                                #
8 #--------------------------------------------------------------------------------#
9
10
11 cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
12
13 #Retrieve Compiler Version
14
15
16 execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion | cut -d. -f1 
17                  OUTPUT_VARIABLE CCMAJORV
18                  OUTPUT_STRIP_TRAILING_WHITESPACE) 
19 execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion | cut -d. -f2
20                  OUTPUT_VARIABLE CCMINORV
21                  OUTPUT_STRIP_TRAILING_WHITESPACE)
22
23
24 # Global Optimization
25 set(OPT "-O -g")
26 set(NOOPT "-g")
27
28 set(CXXOPT ${OPT})
29 set(CXXNOPT ${NOOPT})
30 set(COPT ${OPT})
31 set(FOPT ${OPT})
32
33 #CERNLIB defines
34 set(CLIBDEFS "-DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ")
35 set(CLIBCXXOPTS)
36 set(CLIBCOPT)
37 set(CLIBFOPT ${CLIBDEFS})
38
39 set(CXXWARN "-Wall -Wno-long-long -W -Weffc++ -Wshadow -Woverloaded-virtual -ansi")
40
41 if(CCMAJORV STREQUAL "2")
42
43   set(CXXFLAGS "${OPT} -fPIC -pipe")
44   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe")
45
46 elseif(CCMAJORV STREQUAL "3")
47
48   set(CXXFLAGS "${OPT} -fPIC -pipe -fmessage-length=0 -Dlinux")
49   add_definitions(-Dlinux)
50   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe -fmessage-length=0")
51
52 elseif(CCMAJORV STREQUAL "4")
53   
54   set(CXXFLAGS "${OPT} -fPIC -pipe -fmessage-length=0 -Dlinux")
55   add_definitions(-Dlinux)
56   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe -fmessage-length=0")
57
58 else ()
59
60   set(CXXFLAGS "${OPT} -pipe -fmessage-length=0 -Dlinux")
61   add_definitions(-Dlinux)
62   set(CXXFLAGSNO "${NOOPT} -pipe -fmessage-length=0") 
63
64 endif(CCMAJORV STREQUAL "2")
65
66 set(CFLAGS      "${OPT} -Wall -Werror -fPIC -pipe -Wno-long-long -pedantic-errors -ansi")
67 set(FFLAGS "${CLIBFOPT} ${FOPT} -fPIC -fno-second-underscore -fPIC -fno-f2c")
68
69 execute_process(COMMAND find /lib64 -name 'libNoVersion*.so' 
70                 COMMAND xargs --replace basename {} .so 
71                 COMMAND sed -e "s/lib64/ -l/"
72                 OUTPUT_VARIABLE LIBNOVER
73                 OUTPUT_STRIP_TRAILING_WHITESPACE)
74                 
75
76 set(SYSLIBS "-ldl -lcrypt -L/usr/X11R6/lib -lX11 ${LIBNOVER}")
77
78 if(${CMAKE_Fortran_COMPILER} MATCHES "g95")
79   
80   add_definitions(-DFORTRAN_G95)
81   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --print-search-dirs 
82                   OUTPUT_VARIABLE SHLIB
83                   OUTPUT_STRIP_TRAILING_WHITESPACE)
84   string(REGEX MATCH "^.*install:[^\n]*" SHLIB ${SHLIB})
85   string(REGEX REPLACE "^.*install: " "" SHLIB ${SHLIB})
86   set(SHLIB "-L${SHLIB} -lf95")
87
88 elseif(${CMAKE_Fortran_COMPILER} MATCHES "gfortran")
89   
90   set(FFLAGS "-DFORTRAN_GFORTRAN ${FFLAGS}")
91   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortran.so
92                   OUTPUT_VARIABLE _shlib
93                   OUTPUT_STRIP_TRAILING_WHITESPACE)
94   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortranbegin.a
95                   OUTPUT_VARIABLE SHLIB
96                   OUTPUT_STRIP_TRAILING_WHITESPACE)
97   set(SHLIB "${_shlib} ${SHLIB}")
98   set(SYSLIBS "${SYSLIBS} ${SHLIB}")
99
100 else()
101
102   set(SHLIB "-lg2c")
103   set(SYSLIBS "-lg2c")
104   
105 endif(${CMAKE_Fortran_COMPILER} MATCHES "g95")
106
107 set(LDFLAGS "${OPT}")
108 set(SOFLAGS "${OPT} -shared -Wl")
109 set(ALLIB)
110
111
112