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