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