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