Preliminary files for CMake
[u/mrichter/AliRoot.git] / cmake / modules / CheckCompiler.cmake
1 # -*- mode: cmake -*-
2 MACRO ( Check_Compiler )
3
4
5 # Set a default build type for single-configuration
6 # CMake generators if no build type is set.
7 if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
8 #   set(CMAKE_BUILD_TYPE RelWithDebInfo)
9 endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
10
11 if (CMAKE_SYSTEM_NAME MATCHES Linux)
12    MESSAGE("--- Found a Linux ssytem")
13    if (CMAKE_COMPILER_IS_GNUCXX)
14       MESSAGE("--- Found GNU compiler collection")
15 #      set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
16 #      set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
17       # we profile...
18 #      if(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
19 #        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
20 #        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
21 #      endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
22
23    # Select flags.
24    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
25    set(CMAKE_CXX_FLAGS_RELEASE        "-O2")
26 #   set(CMAKE_CXX_FLAGS_DEBUG          "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
27    set(CMAKE_CXX_FLAGS_DEBUG          "-g")
28    set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g3 -fno-inline")
29    set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
30    set(CMAKE_CXX_FLAGS_ARRAY_CHECK    "-g3 -fno-inline -ftest-coverage -fprofile-arcs -fstack-protector")
31    set(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g")
32    set(CMAKE_C_FLAGS_RELEASE          "-O2")
33 #   set(CMAKE_C_FLAGS_DEBUG            "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
34    set(CMAKE_C_FLAGS_DEBUG            "-g")
35    set(CMAKE_C_FLAGS_DEBUGFULL        "-g3 -fno-inline")
36    set(CMAKE_C_FLAGS_PROFILE          "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
37    set(CMAKE_C_FLAGS_ARRAY_CHECK      "-g3 -fno-inline -ftest-coverage -fprofile-arcs -fstack-protector")
38
39 #   set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
40 #   set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common")
41    endif (CMAKE_COMPILER_IS_GNUCXX)
42
43    if (CMAKE_C_COMPILER MATCHES "icc")
44       MESSAGE("--- Found Intel compiler collection")
45 #      set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
46 #      set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
47
48    # Select flags.
49    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
50    set(CMAKE_CXX_FLAGS_RELEASE        "-O2")
51    set(CMAKE_CXX_FLAGS_DEBUG          "-O2 -g -0b0 -noalign")
52    set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g -Ob0 -noalign")
53    set(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g")
54    set(CMAKE_C_FLAGS_RELEASE          "-O2")
55    set(CMAKE_C_FLAGS_DEBUG            "-O2 -g -Ob0 -noalign")
56    set(CMAKE_C_FLAGS_DEBUGFULL        "-g -Ob0 -noalign")
57
58 #   set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -ansi -Wpointer-arith -fno-common")
59 #   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wpointer-arith -fno-exceptions -fno-common")
60
61    endif (CMAKE_C_COMPILER MATCHES "icc")
62 endif (CMAKE_SYSTEM_NAME MATCHES Linux)
63
64
65 #STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
66
67 SET (BLA CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER})
68
69 MESSAGE("--- Build Type: ${CMAKE_BUILD_TYPE}")
70 MESSAGE("--- Compiler Flags: ${CMAKE_CXX_FLAGS} ${${BLA}}")
71
72 ENDMACRO ( Check_Compiler )