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