Completely reengineered version of CMake build system (Johny)
[u/mrichter/AliRoot.git] / cmake / CMakelinuxx8664gcc.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_LINUX -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' 
68                 COMMAND xargs --replace basename {} .so 
69                 COMMAND sed -e "s/lib64/ -l/"
70                 OUTPUT_VARIABLE LIBNOVER
71                 OUTPUT_STRIP_TRAILING_WHITESPACE)
72                 
73
74 set(SYSLIBS "-ldl -lcrypt -L/usr/X11R6/lib -lX11 ${LIBNOVER}")
75
76 if(${CMAKE_Fortran_COMPILER} MATCHES "g95")
77   
78   add_definitions(-DFORTRAN_G95)
79   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --print-search-dirs 
80                   OUTPUT_VARIABLE SHLIB
81                   OUTPUT_STRIP_TRAILING_WHITESPACE)
82   string(REGEX MATCH "^.*install:[^\n]*" SHLIB ${SHLIB})
83   string(REGEX REPLACE "^.*install: " "" SHLIB ${SHLIB})
84   set(SHLIB "-L${SHLIB} -lf95")
85
86 elseif(${CMAKE_Fortran_COMPILER} MATCHES "gfortran")
87   
88   set(FFLAGS "-DFORTRAN_GFORTRAN ${FFLAGS}")
89   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -m32 -print-file-name=libgfortran.so
90                   OUTPUT_VARIABLE _shlib
91                   OUTPUT_STRIP_TRAILING_WHITESPACE)
92   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -m32 -print-file-name=libgfortranbegin.a
93                   OUTPUT_VARIABLE SHLIB
94                   OUTPUT_STRIP_TRAILING_WHITESPACE)
95   set(SHLIB "${_shlib} ${SHLIB}")
96   set(SYSLIBS "${SYSLIBS} ${SHLIB}")
97
98 else()
99
100   set(SHLIB "-lg2c")
101   set(SYSLIBS "-lg2c")
102   
103 endif(${CMAKE_Fortran_COMPILER} MATCHES "g95")
104
105 set(LDFLAGS "${OPT}")
106 set(SOFLAGS "${OPT} -shared -Wl")
107 set(ALLIB)
108
109
110