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