remove the -ansi flag and prevent install dir to equal build dir but allowing them...
[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
17                  COMMAND cut -d. -f1
18                  OUTPUT_VARIABLE CCMAJORV
19                  OUTPUT_STRIP_TRAILING_WHITESPACE) 
20 execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion
21                  COMMAND cut -d. -f2
22                  OUTPUT_VARIABLE CCMINORV
23                  OUTPUT_STRIP_TRAILING_WHITESPACE)
24
25
26 # Global Optimization
27 set(OPT)
28
29 # ------- Setting optimization flags for default configuration -------
30
31 if((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "None"))
32     set(DEFAULT_CXX_FLAGS "-O -g")
33     set(OPT "${DEFAULT_CXX_FLAGS}")
34     message("-- Setting compiler flags for default configuration: ${DEFAULT_CXX_FLAGS}")
35 endif((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "None"))
36
37 # --------------------------------------------------------------------
38
39
40 set(NOOPT "-g")
41
42 set(CXXOPT ${OPT})
43 set(CXXNOPT ${NOOPT})
44 set(COPT ${OPT})
45 set(FOPT ${OPT})
46
47 #CERNLIB defines
48 set(CLIBDEFS "-DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ")
49 set(CLIBCXXOPTS)
50 set(CLIBCOPT)
51 set(CLIBFOPT ${CLIBDEFS})
52
53 set(CXXWARN "-Wall -Wno-long-long -W -Weffc++ -Wshadow -Woverloaded-virtual")
54
55 if(CCMAJORV STREQUAL "2")
56
57   set(CXXFLAGS "${OPT} -fPIC -pipe")
58   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe")
59
60 elseif(CCMAJORV STREQUAL "3")
61
62   set(CXXFLAGS "${OPT} -fPIC -pipe -fmessage-length=0 -Dlinux")
63   add_definitions(-Dlinux)
64   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe -fmessage-length=0")
65
66 elseif(CCMAJORV STREQUAL "4")
67   
68   set(CXXFLAGS "${OPT} -fPIC -pipe -fmessage-length=0 -Dlinux")
69   add_definitions(-Dlinux)
70   set(CXXFLAGSNO "${NOOPT} -fPIC -pipe -fmessage-length=0")
71
72 else ()
73
74   set(CXXFLAGS "${OPT} -pipe -fmessage-length=0 -Dlinux")
75   add_definitions(-Dlinux)
76   set(CXXFLAGSNO "${NOOPT} -pipe -fmessage-length=0") 
77
78 endif(CCMAJORV STREQUAL "2")
79
80 set(CFLAGS      "${OPT} -Wall -Werror -fPIC -pipe -Wno-long-long -pedantic-errors")
81 set(FFLAGS "${CLIBFOPT} ${FOPT} -fPIC -fno-second-underscore -fPIC -fno-f2c")
82
83 execute_process(COMMAND find /lib64 -name 'libNoVersion*.so' 
84                 COMMAND xargs --replace basename {} .so 
85                 COMMAND sed -e "s/lib64/ -l/"
86                 OUTPUT_VARIABLE LIBNOVER
87                 OUTPUT_STRIP_TRAILING_WHITESPACE)
88                 
89
90 #set(SYSLIBS "-ldl -lcrypt -L/usr/X11R6/lib -lX11 -lGL -lGLU ${LIBNOVER}")
91 set(SYSLIBS "-ldl -lcrypt -L/usr/X11R6/lib -lX11 ${LIBNOVER}")
92
93 if(${CMAKE_Fortran_COMPILER} MATCHES "g95")
94   
95   add_definitions(-DFORTRAN_G95)
96   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --print-search-dirs 
97                   OUTPUT_VARIABLE SHLIB
98                   OUTPUT_STRIP_TRAILING_WHITESPACE)
99   string(REGEX MATCH "^.*install:[^\n]*" SHLIB ${SHLIB})
100   string(REGEX REPLACE "^.*install: " "" SHLIB ${SHLIB})
101   set(SHLIB "-L${SHLIB} -lf95")
102
103 elseif(${CMAKE_Fortran_COMPILER} MATCHES "gfortran")
104   
105   set(FFLAGS "-DFORTRAN_GFORTRAN ${FFLAGS} -fPIC")
106   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortran.so
107                   OUTPUT_VARIABLE _shlib
108                   OUTPUT_STRIP_TRAILING_WHITESPACE)
109   execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortranbegin.a
110                   OUTPUT_VARIABLE SHLIB
111                   OUTPUT_STRIP_TRAILING_WHITESPACE)
112   set(SHLIB "${_shlib} ${SHLIB}")
113   set(SYSLIBS "${SYSLIBS} ${SHLIB}")
114
115 else()
116
117   set(SHLIB "-lg2c")
118   set(SYSLIBS "-lg2c")
119   
120 endif(${CMAKE_Fortran_COMPILER} MATCHES "g95")
121
122 set(LDFLAGS "${OPT}")
123 set(SOFLAGS "${OPT} -shared")
124 set(ALLIB)
125
126
127