source: PSPA/madxPSPA/cmake/setupCompilerSpecifics.cmake @ 465

Last change on this file since 465 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 3.0 KB
Line 
1###
2#
3# This file sets compiler specific flags
4# and runs some special stuff needed for specific
5# compiler selections
6#
7###
8
9set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_LIST_DIR}/compilers")
10
11# These two compilers can be mixed at will...
12include(setupGNU)
13include(setupIntel)
14
15# Only Fortran..
16if(CMAKE_Fortran_COMPILER MATCHES "lf95")
17   message( WARNING " This compiler is not supported for Mad-X")
18   include(setupLahey)
19elseif(CMAKE_Fortran_COMPILER MATCHES "nagfor")
20   message( WARNING " This compiler is not supported for Mad-X")
21   include(setupNAGFOR)
22elseif(CMAKE_Fortran_COMPILER MATCHES "g77")
23   message( WARNING " This compiler is not supported for Mad-X")
24   message( "--- ifort is recommended fortran compiler ---")
25   set(CMAKE_Fortran_FLAGS_RELEASE " -funroll-loops -fno-f2c -O3 ")
26   set(CMAKE_Fortran_FLAGS_DEBUG   " -fno-f2c -O0 -g ")
27   if ( MADX_STATIC )
28      set(CMAKE_Fortran_LINK_FLAGS   "${CMAKE_Fortran_LINK_FLAGS} -static ")
29   endif ()
30elseif(CMAKE_Fortran_COMPILER MATCHES "g95")
31   message( WARNING " This compiler is not supported for Mad-X")
32   set(CMAKE_Fortran_FLAGS_RELEASE " -funroll-loops -fno-second-underscore -fshort-circuit -O2 ")
33   set(CMAKE_Fortran_FLAGS_DEBUG   " -fno-second-underscore -O3 -g -Wall -pedantic -ggdb3") 
34   if ( MADX_STATIC )
35      set(CMAKE_Fortran_LINK_FLAGS   "${CMAKE_Fortran_LINK_FLAGS} -static ")
36   endif ()
37elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PathScale")
38   message( WARNING " This compiler is not supported for Mad-X")
39   include(setupPathScale)
40endif()
41#end fortran compiler stuff...
42
43
44# General compile flags:
45set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g ${CMAKE_Fortran_FLAGS_RELEASE}")
46set(CMAKE_C_FLAGS_DEBUG   " ${CMAKE_C_FLAGS_DEBUG} -Wall -pedantic")
47if(NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel"))
48   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funroll-loops -std=c99")
49endif()
50set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops") #needed for c++ linking
51set(CMAKE_CXX_FLAGS_DEBUG " ${CMAKE_CXX_FLAGS_DEBUG} -Wall")
52if(MADX_DEBUG)
53   add_definitions(-D_DEBUG -DDEBUG_ALL)
54endif()
55
56add_definitions(-D_FULL -D_VERSION=${MADX_VERSION} -D_VERSION_DATE=${VERSION_DATE} -D_VERSION_OSTYPE=${CMAKE_SYSTEM_NAME})
57
58# C stuff:
59# -- not needed for gnu/intel --
60if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
61   execute_process(COMMAND ${C_COMPILER_NAME} -print-search-dirs
62      OUTPUT_VARIABLE gccsearchdirs)
63   string(REGEX REPLACE ".*libraries: =(.*)\n"  "\\1" gcclibs "${gccsearchdirs}")
64   # need to do this many times because lf95 segfaults on lists with :
65   string(REPLACE "/:/"  "/ -L/" gcclibs "${gcclibs}")
66   # adding these to the linking process which is handled by a non-gnu fortran compiler in your case
67   link_directories(${gcclibs}) 
68endif()
69# -- end of not needed for gnu/intel --
70# end C stuff
71
72if(MADX_ONLINE)
73   message(STATUS "Online model turned on")
74   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ONLINE ")
75   set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D_ONLINE ")
76endif()
Note: See TracBrowser for help on using the repository browser.